correction indentation

This commit is contained in:
François Pelletier 2019-04-11 00:08:48 -04:00
parent 3c87d54f68
commit c94685984c
2 changed files with 17 additions and 13 deletions

View file

@ -1,4 +1,5 @@
al.ca# search.py
# -*- coding: utf-8 -*-
# search.py
# ---------
# Licensing Information: You are free to use or extend these projects for
# educational purposes provided that (1) you do not distribute or publish
@ -184,6 +185,7 @@ def uniformCostSearch(problem):
# Decomposer le tuple pour faciliter la lecture
succNoeudCourant, succDirection, succCost = s
# Verifier si le noeud n'est pas deja visite
succCostChemin = None
if (succNoeudCourant not in maListeFermee+[i[0] for i in maFileEtat.heap]):
# obtenir le cout total du chemin
succCostChemin = problem.getCostOfActions(listeDirections+[succDirection])
@ -193,7 +195,7 @@ def uniformCostSearch(problem):
# Ajouter le nouveau chemin dans la file avec son cout
maFileChemin.push(listeDirections+[succDirection],succCostChemin)
# si noeud existant, mettre a jour le cout si meilleur
elif (succNoeudCourant in [i[0] for i in maFileEtat.heap]):
elif succNoeudCourant in [i[0] for i in maFileEtat.heap]:
maFileEtat.update(succNoeudCourant,succCostChemin)
listeDirections = maFileChemin.pop()
# print "pas de solution"
@ -224,7 +226,7 @@ def aStarSearch(problem, heuristic=nullHeuristic):
while (not maFileEtat.isEmpty()):
noeudCourant = maFileEtat.pop()
#print "Noeud courant: ", noeudCourant
# print "Noeud courant: ", noeudCourant
# La marquer comme visite
if noeudCourant not in maListeFermee:
maListeFermee.append(noeudCourant)
@ -235,19 +237,20 @@ def aStarSearch(problem, heuristic=nullHeuristic):
# Effectuer la recherche de successeurs
for s in problem.getSuccessors(noeudCourant):
# Decomposer le tuple pour faciliter la lecture
succNoeudCourant, succDirection, succCost = s
succ_noeud_courant, succDirection, succCost = s
# Verifier si le noeud n'est pas deja visite
if (succNoeudCourant not in maListeFermee+[i[0] for i in maFileEtat.heap]):
succ_cost_chemin = None
if succ_noeud_courant not in maListeFermee+[i[0] for i in maFileEtat.heap]:
# obtenir le cout total du chemin
succCostChemin = problem.getCostOfActions(listeDirections+[succDirection])+heuristic(succNoeudCourant,problem)
succ_cost_chemin = problem.getCostOfActions(listeDirections+[succDirection])+heuristic(succ_noeud_courant,problem)
# Si le noeud est encore dans la file, mettre a jour la priorite si elle devient inferieure
#print "Ajout du noeud a la file: ", succNoeudCourant
maFileEtat.push(succNoeudCourant,succCostChemin)
# print "Ajout du noeud a la file: ", succ_noeud_courant
maFileEtat.push(succ_noeud_courant,succ_cost_chemin)
# Ajouter le nouveau chemin dans la file avec son cout
maFileChemin.push(listeDirections+[succDirection],succCostChemin)
maFileChemin.push(listeDirections+[succDirection],succ_cost_chemin)
# si noeud existant, mettre a jour le cout si meilleur
elif (succNoeudCourant in [i[0] for i in maFileEtat.heap]):
maFileEtat.update(succNoeudCourant,succCostChemin)
elif succ_noeud_courant in [i[0] for i in maFileEtat.heap]:
maFileEtat.update(succ_noeud_courant,succ_cost_chemin)
listeDirections = maFileChemin.pop()
# print "pas de solution"
util.raiseNotDefined()

View file

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# searchAgents.py
# ---------------
# Licensing Information: You are free to use or extend these projects for
@ -11,7 +12,7 @@
# Student side autograding was added by Brad Miller, Nick Hay, and
# Pieter Abbeel (pabbeel@cs.berkeley.edu).
#
# IFT-7025 Hier 2019
# IFT-7025 Hiver 2019
# François Pelletier
# 908144032
@ -396,7 +397,7 @@ def cornersHeuristic(state, problem):
# Liste des distances de Manhattan vers les sommets restants
mh=[]
for i in range(nb_corners):
current_distance = util.manhattanDistance(currentPosition,currentCornerList[i])
current_distance = util.manhattanDistance(currentPosition,currentCornerList[i])
mh.append(current_distance)
# On retourne la plus grande distance, qui est le meilleur scenario possible pour terminer
return max(mh)