minor fixes
This commit is contained in:
parent
4caef2e9ae
commit
3c5dfc2e34
@ -49,28 +49,28 @@ class PathFinderOnStates:
|
||||
return currState.cost + self.heuristic(currState.agent_position, self.goal)
|
||||
|
||||
def getPositionAfterMove(self, currState: PathFinderState) -> GridLocation:
|
||||
result : GridLocation
|
||||
result: GridLocation = None
|
||||
if currState.agent_position == Direction.top:
|
||||
currState.agent_position[0] += 1
|
||||
result = currState.agent_position
|
||||
elif currState.agent_position == Direction.down:
|
||||
currState.agent_position[0] -= 1
|
||||
result= currState.agent_position
|
||||
elif currState.agent_position == Direction.right:
|
||||
currState.agent_position[1] += 1
|
||||
result = currState.agent_position
|
||||
elif currState.agent_position == Direction.right:
|
||||
elif currState.agent_position == Direction.down:
|
||||
currState.agent_position[1] -= 1
|
||||
result = currState.agent_position
|
||||
elif currState.agent_position == Direction.right:
|
||||
currState.agent_position[0] += 1
|
||||
result = currState.agent_position
|
||||
elif currState.agent_position == Direction.left:
|
||||
currState.agent_position[0] -= 1
|
||||
result = currState.agent_position
|
||||
return result
|
||||
|
||||
def isMovePossible(self, currState: PathFinderState) -> bool:
|
||||
positionAfterMove = self.getPositionAfterMove(currState)
|
||||
if positionAfterMove in self.game_constants.walls:
|
||||
return False
|
||||
elif positionAfterMove in self.game_constants.grid_height:
|
||||
elif positionAfterMove[0] < 0 or positionAfterMove[0] > self.game_constants.grid_width:
|
||||
return False
|
||||
elif positionAfterMove in self.game_constants.grid_width:
|
||||
elif positionAfterMove[1] < 0 or positionAfterMove[1] > self.game_constants.grid_height:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
@ -78,7 +78,8 @@ class PathFinderOnStates:
|
||||
def createState(self, currState: PathFinderState, action: ActionType) -> PathFinderState:
|
||||
cost = currState.cost + 1
|
||||
last_action = action
|
||||
action_taken = currState.action_taken.append(action)
|
||||
action_taken: List[ActionType] = []
|
||||
action_taken.extend(currState.action_taken)
|
||||
agent_position = currState.agent_position
|
||||
agent_direction = currState.agent_direction
|
||||
|
||||
@ -100,7 +101,7 @@ class PathFinderOnStates:
|
||||
# reprezentacja kazdego stanu co moge podjac z tego miejsca
|
||||
# generowanie stanu
|
||||
# sprawdz w ktorym kierunku obrocony
|
||||
possibleNextStates: List[PathFinderState]
|
||||
possibleNextStates: List[PathFinderState] = []
|
||||
if currState.agent_direction == Direction.top:
|
||||
possibleNextStates.append(self.createState(currState, ActionType.ROTATE_RIGHT))
|
||||
possibleNextStates.append(self.createState(currState, ActionType.ROTATE_LEFT))
|
||||
@ -120,7 +121,7 @@ class PathFinderOnStates:
|
||||
if self.isMovePossible(currState):
|
||||
possibleNextStates.append(self.createState(currState, ActionType.MOVE))
|
||||
elif currState.agent_direction == Direction.right:
|
||||
possibleNextStates.append(self.createState(currState, ActionType.ROTATE_UPT))
|
||||
possibleNextStates.append(self.createState(currState, ActionType.ROTATE_UP))
|
||||
possibleNextStates.append(self.createState(currState, ActionType.ROTATE_LEFT))
|
||||
possibleNextStates.append(self.createState(currState, ActionType.ROTATE_DOWN))
|
||||
if self.isMovePossible(currState):
|
||||
|
Loading…
Reference in New Issue
Block a user