예제 #1
0
def game_over(state):
    if c4.isWinner(state, PLAYER_X):
        return PLAYER_X
    if c4.isWinner(state, PLAYER_O):
        return PLAYER_O
    if c4.isBoardFull(state):
        return DRAW
    else:
        return EMPTY
def game_over(state):
    if c4.isWinner(state, PLAYER_X):
        return PLAYER_X
    if c4.isWinner(state, PLAYER_O):
        return PLAYER_O
    if c4.isBoardFull(state):
        return DRAW
    else:
        return EMPTY
예제 #3
0
 def play(self):
     state = c4.getNewBoard()
     player = 1
     while not c4.isBoardFull(state):
         if player == 1:
             move = self.action(state, player)
         else:
             move = c4.getRandomMove(state)
         state = c4.makeMove(state, player, move)
         if c4.isWinner(state, player):
             return player
         player *= -1
     return 0.5  # draw
예제 #4
0
 def play(self):
     state = c4.getNewBoard()
     player = 1
     while not c4.isBoardFull(state):
         if player == 1:
             move = self.action(state, player)
         else:
             move = c4.getRandomMove(state)
         state = c4.makeMove(state, player, move)
         if c4.isWinner(state, player):
             return player
         player *= -1
     return 0.5  # draw