Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions grid_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def get_locations():
'''
def move_player(player, move):
x, y = player
if move == "LEFT":
if move == "DOWN":
y += 1
elif move == "LEFT":
x -= 1
if move == "RIGHT":
elif move == "RIGHT":
x += 1
if move == "UP":
elif move == "UP":
y -= 1
Comment on lines -25 to 32
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function move_player refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

if move == "DOWN":
y += 1
return x, y

'''
Expand All @@ -41,11 +41,11 @@ def get_moves(player):
x, y = player
if x == 0:
moves.remove("LEFT") # removes "LEFT" from the list
if x == 4:
elif x == 4:
moves.remove("RIGHT")
if y == 0:
moves.remove("UP")
if y == 4:
elif y == 4:
Comment on lines -44 to +48
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_moves refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

moves.remove("DOWN")
return moves

Expand Down