Created
September 18, 2014 02:10
-
-
Save danhyun/51e76d96eddfea4943b5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def is_within_board(location, direction): | |
| """Tests if the move stays within the boundaries of the board.""" | |
| index = (0, 1) [direction in ['right', 'left']] | |
| limit = (0, 4) [direction in ['right', 'down']] | |
| return (location[index] < limit, location[index] > limit) [direction in ['left', 'up']] |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using this: http://stackoverflow.com/a/470376