Let the player type in their move. Returns the move as [x, y] (or returns the string 'QUIT')
(board)
| 182 | |
| 183 | |
| 184 | def askForPlayerMove(board): |
| 185 | """Let the player type in their move. Returns the move as [x, y] |
| 186 | (or returns the string 'QUIT')""" |
| 187 | while True: |
| 188 | print('Enter your move, or type quit to end the game.') |
| 189 | move = input('> ').upper() |
| 190 | if move == 'QUIT': |
| 191 | return 'QUIT' |
| 192 | |
| 193 | if len(move) == 2 and move[0] in COLS and move[1] in ROWS: |
| 194 | x = 'ABCDEFGH'.find(move[0]) |
| 195 | y = int(move[1]) - 1 |
| 196 | if isValidMove(board, HUMAN, x, y) == False: |
| 197 | print('That is not a valid space to place a tile.') |
| 198 | continue |
| 199 | else: |
| 200 | break |
| 201 | else: |
| 202 | print('Type the column (A-H) and row (1-8).') |
| 203 | print('For example, H1 will be the top-right corner.') |
| 204 | |
| 205 | return (x, y) |
| 206 | |
| 207 | |
| 208 | def makeMove(board, tile, xstart, ystart): |