Let the player select a tile to slide.
(board)
| 74 | |
| 75 | |
| 76 | def askForPlayerMove(board): |
| 77 | """Let the player select a tile to slide.""" |
| 78 | blankx, blanky = findBlankSpace(board) |
| 79 | |
| 80 | w = 'W' if blanky != 3 else ' ' |
| 81 | a = 'A' if blankx != 3 else ' ' |
| 82 | s = 'S' if blanky != 0 else ' ' |
| 83 | d = 'D' if blankx != 0 else ' ' |
| 84 | |
| 85 | while True: |
| 86 | print(' ({})'.format(w)) |
| 87 | print('Enter WASD (or QUIT): ({}) ({}) ({})'.format(a, s, d)) |
| 88 | |
| 89 | response = input('> ').upper() |
| 90 | if response == 'QUIT': |
| 91 | sys.exit() |
| 92 | if response in (w + a + s + d).replace(' ', ''): |
| 93 | return response |
| 94 | |
| 95 | |
| 96 | def makeMove(board, move): |
no test coverage detected