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): def succesor(self):
movesList = [Movement.ROTATE_L, Movement.ROTATE_R] movesList = [Movement.ROTATE_L, Movement.ROTATE_R]
# Check if can move forward def succesor(self, elemState):
facingCoord = self.player.getFacingCoord() '''
facingEntity = self.map.getEntityOnCoord(facingCoord) :param elemState: [x, y, Rotation]
if facingEntity is not None: :return: list of (Movement, NewState)
movesList.append(Movement.FORWARD) '''
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): def goalTest(self, coords):
entity = self.map.getEntityOnCoord(coords) entity = self.map.getEntityOnCoord(coords)