Advertisement
gruntfutuk

noughts_and_crosses

May 30th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. from itertools import cycle
  2.  
  3. def print_board(board):
  4.     for ridx, row in enumerate(board, start=1):
  5.         for cidx, col in enumerate(row, start=1):
  6.             print(f"{col}{'|' if cidx in (1, 2) else ''}", end="")
  7.         print(f"\n{LINE if ridx in (1, 2) else NULL}")
  8.  
  9. LINE = "-|-|-"
  10. NULL = ""
  11. X = "X"
  12. O = "O"
  13.  
  14. board = [[' ' for _ in range(3)] for _ in range(3)]  # initialise
  15. moves = ((1, 1), (0,2), (2,1), (0,1), (0,0))  # testing
  16. players = cycle((X, O))
  17.  
  18. print_board(board)
  19. for row,col in moves:
  20.     board[row][col] =
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement