Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. for i in range(size):
  2. for j in range(size):
  3. if board[i][j] != ai and board[i][j] != pl:
  4. copy = board[i][j]
  5. board[i][j] = ai
  6.  
  7. if win(ai) == 1 or tie() == 1:
  8. if x:
  9. print(name + ' Moved To Grid', i * size + j + 1)
  10. return
  11.  
  12. board[i][j] = copy
  13.  
  14. for i in range(size):
  15. for j in range(size):
  16. if board[i][j] != ai and board[i][j] != pl:
  17. copy = board[i][j]
  18. board[i][j] = pl
  19.  
  20. if win(pl) == 1 or tie() == 1:
  21. board[i][j] = ai
  22. if x:
  23. print(name + ' Moved To Grid', i * size + j + 1)
  24. return
  25. board[i][j] = copy
  26.  
  27. for i in range(size):
  28. for j in range(size):
  29. if board[i][j] != ai and board[i][j] != pl:
  30. copy = board[i][j]
  31. board[i][j] = ai
  32.  
  33. if countWins(ai, pl) > 1:
  34. l += 1
  35. r = [i, j]
  36. wins2.append(r)
  37.  
  38. board[i][j] = copy
  39.  
  40. for i, j in board.empty_cells():
  41.  
  42. for i, j in empty_cells(board):
  43.  
  44. def would_win_if_moved_to(player, location) -> bool:
  45. ''' Return true if player would win if their glyph was placed at location. '''
  46. # TODO
  47. pass
  48.  
  49. for locn in empty_cells(board):
  50. if would_win_if_moved_to(ai, locn):
  51. # Go for the win!
  52. move_to(locn)
  53.  
  54. for locn in empty_cells(board):
  55. if would_win_if_moved_to(player, locn):
  56. # Block opponent win!
  57. move_to(locn)
  58.  
  59. for locn in moves_to_win(ai):
  60. return locn
  61. for locn in moves_to_block_win(player):
  62. return locn
  63.  
  64. wins2 = [locn for locn in empty_cells(board) if wins_after_move_to(ai, locn) > 1]
  65.  
  66. print("line 1")
  67. print("line 2")
  68. print("line 3")
  69.  
  70. text = """
  71. line 1
  72. line 2
  73. line 3
  74. """.strip('n')
  75. print(textwrap.dedent(text))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement