Advertisement
Guest User

tic_tca_toep

a guest
Oct 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. board=[[0,0,0,0],[0,3,5,3],[0,5,3,5],[0,3,5,3]]
  2. def initialize():
  3.     print("before initialize the board")
  4.     print(board)
  5.     for i in range(1,4):
  6.         for j in range(1,4):
  7.             board[i][j]=2;
  8.     print("\nThe board is initailize=n")
  9.     print("After initialize the board")
  10.     print(board)
  11.  
  12.  
  13. def print_board():
  14.     for i in range(1,4):
  15.         for j in range(1,4):
  16.              if j!=3:
  17.                if board[i][j]==2:
  18.                 print("   |",end="")
  19.  
  20.                elif board[i][j]==3:
  21.                 print(" X |",end="")
  22.                else:
  23.                 print(" 0 |",end="")
  24.              else:
  25.                  if board[i][j]==2:
  26.                   print("   ",end="")
  27.  
  28.                  elif board[i][j]==3:
  29.                   print(" X ",end="")
  30.                  else:
  31.                   print(" 0 ",end="")
  32.         if i!=3:
  33.             print("\n----------\n",end="")
  34.                  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.        
  45. def tictactoe():
  46.     while True:
  47.         print("\nEnter 3 for play as X :")
  48.         print("Enter 5 for play as O :")
  49.         print("Enter 100 for exit :")
  50.         choice=int(input("enter your choice :"))
  51.         if  choice==100:
  52.            break
  53.         elif choice==3 :
  54.               print("player is x")
  55.         elif choice==5 :
  56.               print("player is 0")
  57.         elif choice==1 :
  58.               initialize()
  59.         elif choice==2 :
  60.               print_board()      
  61.         else:
  62.               print("\n your choice is wrong!!")
  63. tictactoe();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement