heryvandoro

Untitled

Feb 19th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. def getMove() :
  2. moveX = 0
  3. moveY = 0
  4.  
  5. if (player == 1):
  6. print "X Turn : "
  7. else:
  8. print "O Turn : "
  9.  
  10. while moveX < 1 or moveX > 3 :
  11. moveX = int(raw_input("Input X : "))
  12.  
  13. while moveY < 1 or moveY > 3 :
  14. moveY = int(raw_input("Input Y : "))
  15.  
  16. if (isAvailable(moveX, moveY)==True) :
  17. doMove(moveX, moveY)
  18. else :
  19. print str(moveX) + "-" + str(moveY) +" position already taken"
  20. raw_input()
  21.  
  22.  
  23. def isAvailable(moveX, moveY) :
  24. if board[moveX-1][moveY-1]== " " :
  25. return True
  26. else :
  27. return False
  28.  
  29. def doMove(moveX, moveY) :
  30. global player
  31. if(player==1) :
  32. board[moveX-1][moveY-1] = "X"
  33. player=2
  34. else :
  35. board[moveX-1][moveY-1] = "O"
  36. player=1
Advertisement
Add Comment
Please, Sign In to add comment