Example #1
0
def main():
    # create a game, and two players.
    b = Board()
    p = Player(4)  # minimax player
    nnp = nn_player()  # neural net player
    while not b.gameover():
        move = p.choose_move(b)  # get a move using minimax
        nnp.correct_move(b, move)  # train the neural net with that move
        b = b.apply(move)  # play the move

    nnp.save_net()  # after each game, save the neural net
    print()  # then print out the board and score
    b.printBoard()
    print()
    print("Score:", b.score)
    print()
    print("Wow, good game!")
Example #2
0
def main():
    # create a game, and two players.
    b = Board()
    nnp = nn_player()  # neural net player
    while not b.gameover():
        print()  # then print out the board and score
        b.printBoard()
        print()
        print("Score:", b.score)
        print()
        move = nnp.choose_move(b)  # get a move using the neural net
        b = b.apply(move)  # play the move

    nnp.save_net()  # after each game, save the neural net
    print()  # then print out the board and score
    b.printBoard()
    print()
    print("Score:", b.score)
    print()
    print("Wow, good game!")