Example #1
0
    def test_game02(self):
        """
        testing:
        x o x o x
        o x o x o
        x o x o x
        x o x o x
        x o x o o
        """
        game = Game(5, 4)
        moves = [
            (1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (1, 2), (2, 2), (3, 2),
            (4, 2), (5, 2), (1, 3), (2, 3), (3, 3), (4, 3), (5, 3), (5, 5),
            (1, 4), (2, 4), (3, 4), (4, 4), (1, 5), (2, 5), (3, 5), (4, 5)
        ]
        for move in moves:
            game.makemove(game.next_player(), move)
            status, _ = game.game_status()
            #game.printboard()
            assert_equal(status, None)

        game.makemove(game.next_player(), (5, 4))
        status, _ = game.game_status()
        game.printboard()
        assert_equal(status, 0)
Example #2
0
def main():
    np.random.seed(seed=int(time.time()))

    parser = argparse.ArgumentParser(description='Tournament generator.')
    parser.add_argument('--class',
                        type=str,
                        action='append',
                        dest='clazz',
                        help='ML Class',
                        required=True)

    args = parser.parse_args()

    clazzs = [getattr(sys.modules[__name__], clazz) for clazz in args.clazz]
    players = [clazz() for clazz in clazzs]
    for player in players:
        if isinstance(player, MLPlayer):
            player.load_model()

    game = Game(5, 4)
    status = None

    while status is None:
        next_player = game.next_player()

        position = game.position.serialize_out(asplayer=next_player)
        positions = [position]  # [?, x, x, 3] shape is required

        moves = players[next_player - 1].make_game_moves(positions=positions)
        xy = moves[0][0] + 1, moves[0][1] + 1

        game.makemove(player=next_player, position=xy)
        game.printboard()
        status, _ = game.game_status()
Example #3
0
    def test_01(self):
        """
        testing:
        x x x x -
        - o - - -
        - - o - -
        - - - o -
        - - - - -
        """
        game = Game(5, 4)
        moves = [(1, 1), (2, 2), (2, 1), (3, 3), (3, 1), (4, 4), (4, 1)]
        for move in moves:
            game.makemove(game.next_player(), move)

        game.printboard()
        print(game.position.serialize_out())
Example #4
0
    def test_game01(self):
        """
        testing:
        x x x x -
        - o - - -
        - - o - -
        - - - o -
        - - - - -
        """
        game = Game(5, 4)
        moves = [(1, 1), (2, 2), (2, 1), (3, 3), (3, 1), (4, 4)]
        for move in moves:
            game.makemove(game.next_player(), move)
            status, _ = game.game_status()
            assert_equal(status, None)

        game.makemove(game.next_player(), (4, 1))
        status, _ = game.game_status()
        game.printboard()
        assert_equal(status, 1)