Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. the_board = {'1': '', '2': '', '3': '', '4': '', '5': '', '6': '', '7': '', '8': '', '9': ''}
  5.  
  6. def print_board(board):
  7.     print board['1'] + '|' + board['2'] + '|' + board['3']
  8.     print '-+-+-'
  9.     print board['4'] + '|' + board['5'] + '|' + board['6']
  10.     print '-+-+-'
  11.     print board['7'] + '|' + board['8'] + '|' + board['9']
  12.  
  13.  
  14. turn = 'X'
  15. for i in range(9):
  16.     print_board(the_board)
  17.  
  18.     print 'You will play as ' + turn + '. Make your move...'
  19.  
  20.     move = raw_input()
  21.  
  22.     the_board[move] = turn
  23.     if turn == 'X':
  24.         turn = 'O'
  25.     else:
  26.         turn = 'X'
  27.  
  28.  
  29.  
  30. print_board(the_board)
  31.  
  32.  
  33.  
  34.  
  35.  
  36. #if turn == 'X':
  37.     #   spaces = range(9)
  38.     #   ai_move = str(random.choice(spaces))
  39.     #   print 'Your opponent has made their move...'
  40.  
  41.     #   the_board[ai_move] = turn
  42.     #else:
  43.     #   turn = 'X'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement