Change succesor method in AutomaticMovement.py

Now succesor takes state as an argument and returns all possible moves for that state.
This commit is contained in:
Michał Czekański 2020-04-26 00:03:38 +02:00
parent cdcf5fb052
commit 5af76a1b16

View File

@ -57,13 +57,21 @@ class AutomaticMovement:
def succesor(self):
movesList = [Movement.ROTATE_L, Movement.ROTATE_R]
# Check if can move forward
facingCoord = self.player.getFacingCoord()
facingEntity = self.map.getEntityOnCoord(facingCoord)
if facingEntity is not None:
movesList.append(Movement.FORWARD)
def succesor(self, elemState):
'''
:param elemState: [x, y, Rotation]
:return: list of (Movement, NewState)
'''
result = [(Movement.ROTATE_R, self.newStateAfterAction(elemState, Movement.ROTATE_R)),
(Movement.ROTATE_L, self.newStateAfterAction(elemState, Movement.ROTATE_L))]
return movesList
stateAfterForward = self.newStateAfterAction(elemState, Movement.FORWARD)
facingEntity = self.map.getEntityOnCoord(stateAfterForward)
if facingEntity is not None:
result.append((Movement.FORWARD, stateAfterForward))
return result
def goalTest(self, coords):
entity = self.map.getEntityOnCoord(coords)