meilleur nom de variable et simplification
This commit is contained in:
parent
02c38bfe43
commit
b7d428324c
1 changed files with 8 additions and 12 deletions
|
@ -308,14 +308,10 @@ class CornersProblem(search.SearchProblem):
|
|||
currentPosition, currentCornerSet = state
|
||||
# print "Validation du but a ", currentPosition, "Coins restants: ", currentCornerSet
|
||||
# On atteint le but s'il reste un seul coin a atteindre, et que c'est l'etat actuel
|
||||
if len(currentCornerSet)==1:
|
||||
if currentPosition in currentCornerSet:
|
||||
# print "But atteint"
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
# print "But atteint"
|
||||
return (len(currentCornerSet)==1 and currentPosition in currentCornerSet)
|
||||
|
||||
|
||||
|
||||
def getSuccessors(self, state):
|
||||
"""
|
||||
|
@ -347,11 +343,11 @@ class CornersProblem(search.SearchProblem):
|
|||
if not hitsWall:
|
||||
# vu que le set est une structure mutable, j'en fais une copie a chaque fois,
|
||||
# sinon elle reste modifiee dans la boucle
|
||||
currentCornerSet2 = currentCornerSet.copy()
|
||||
currentCornerSetCopy = currentCornerSet.copy()
|
||||
# Si la position est un coin, alors enlever de l'ensemble
|
||||
currentCornerSet2.discard(currentPosition)
|
||||
nextCornerState = (nextPosition,currentCornerSet2)
|
||||
successors.append((nextCornerState, action, self.defaultCost))
|
||||
currentCornerSetCopy.discard(currentPosition)
|
||||
nextState = (nextPosition,currentCornerSetCopy)
|
||||
successors.append((nextState, action, self.defaultCost))
|
||||
self._expanded += 1 # DO NOT CHANGE
|
||||
return successors
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue