16 lines
616 B
Python
16 lines
616 B
Python
def movement(environment, x ,y):
|
|
movement = {
|
|
"right": (x + 1, y) if x + 1 < GRID_WIDTH and type(environment[x + 1][y]) == Road else (x, y),
|
|
"left": (x - 1, y) if x - 1 >= 0 and type(environment[x - 1][y]) == Road else (x, y),
|
|
"down": (x, y + 1) if y + 1 < GRID_HEIGHT and type(environment[x][y + 1]) == Road else (x, y),
|
|
"up": (x, y - 1) if y - 1 >= 0 and type(environment[x][y - 1]) == Road else (x, y)
|
|
}
|
|
|
|
forbidden_movement = {
|
|
"right": "left",
|
|
"left": "right",
|
|
"up": "down",
|
|
"down": "up"
|
|
}
|
|
|
|
return (movement, forbidden_movement) |