()
| 16 | |
| 17 | |
| 18 | def main(): |
| 19 | print('Checkers, by Al Sweigart al@inventwithpython.com') |
| 20 | gameBoard = getNewBoard() # Create a new checker board. |
| 21 | turn = 'O' # O goes first. |
| 22 | while True: # Main game loop. |
| 23 | displayBoard(gameBoard) |
| 24 | |
| 25 | # Get the player's move and carry it out: |
| 26 | srcSpace, dstSpace = askForPlayerMove(gameBoard, turn) |
| 27 | if (srcSpace, dstSpace) == (None, None): |
| 28 | displayBoard(gameBoard) |
| 29 | print(turn + ' is blocked and cannot move.') |
| 30 | print(otherCheckers(turn)[1] + ' is the winner!') |
| 31 | sys.exit() |
| 32 | gameBoard = makeMove(gameBoard, srcSpace, dstSpace) |
| 33 | |
| 34 | if hasLost(gameBoard, otherCheckers(turn)[1]): |
| 35 | displayBoard(gameBoard) |
| 36 | print(turn + ' is the winner!') |
| 37 | sys.exit() |
| 38 | |
| 39 | turn = otherCheckers(turn)[1] # Switch turns to other player. |
| 40 | |
| 41 | |
| 42 | def getNewBoard(): |
no test coverage detected