update: changed variable name in a_star.py

This commit is contained in:
korzepadawid 2022-04-11 23:56:35 +02:00
parent 6c27199988
commit 2bfaff8a30

View File

@ -94,41 +94,41 @@ def remove_forward(possible_actions: List[str]) -> None:
def result(state: State, action: str) -> State: def result(state: State, action: str) -> State:
new_state = State(state.position, state.direction) next_state = State(state.position, state.direction)
if state.direction == UP: if state.direction == UP:
if action == TURN_LEFT: if action == TURN_LEFT:
new_state.direction = LEFT next_state.direction = LEFT
elif action == TURN_RIGHT: elif action == TURN_RIGHT:
new_state.direction = RIGHT next_state.direction = RIGHT
elif action == FORWARD: elif action == FORWARD:
new_state.position = next_position(state.position, UP) next_state.position = next_position(state.position, UP)
elif state.direction == DOWN: elif state.direction == DOWN:
if action == TURN_LEFT: if action == TURN_LEFT:
new_state.direction = RIGHT next_state.direction = RIGHT
elif action == TURN_RIGHT: elif action == TURN_RIGHT:
new_state.direction = LEFT next_state.direction = LEFT
elif action == FORWARD: elif action == FORWARD:
new_state.position = next_position(state.position, DOWN) next_state.position = next_position(state.position, DOWN)
elif state.direction == LEFT: elif state.direction == LEFT:
if action == TURN_LEFT: if action == TURN_LEFT:
new_state.direction = DOWN next_state.direction = DOWN
elif action == TURN_RIGHT: elif action == TURN_RIGHT:
new_state.direction = UP next_state.direction = UP
elif action == FORWARD: elif action == FORWARD:
new_state.position = next_position(state.position, LEFT) next_state.position = next_position(state.position, LEFT)
elif state.direction == RIGHT: elif state.direction == RIGHT:
if action == TURN_LEFT: if action == TURN_LEFT:
new_state.direction = UP next_state.direction = UP
elif action == TURN_RIGHT: elif action == TURN_RIGHT:
new_state.direction = DOWN next_state.direction = DOWN
elif action == FORWARD: elif action == FORWARD:
new_state.position = next_position(state.position, RIGHT) next_state.position = next_position(state.position, RIGHT)
return new_state return next_state
def goal_test(state: State, goal_list: List[Tuple[int, int]]) -> bool: def goal_test(state: State, goal_list: List[Tuple[int, int]]) -> bool: