-
-
Save joooyzee/c9fa640b4ee2ebc737388218d2da2aea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# given an adjacent tile location, move us there | |
def move_to_tile(self, location, tile): | |
# see where the tile is relative to our current location | |
diff = tuple(x-y for x, y in zip(tile, self.location)) | |
# return the action that moves in the direction of the tile | |
if diff == (0,1): | |
action = 'u' | |
elif diff == (0,-1): | |
action = 'd' | |
elif diff == (1,0): | |
action = 'r' | |
elif diff == (-1,0): | |
action = 'l' | |
else: | |
action = '' | |
return action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment