Exemple #1
0
    def time_cube():
        logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                            level=logging.DEBUG)
        import time
        from state import State
        with open("../test_sgf/test1.sgf", 'r') as fin:
            game = gomill.sgf.Sgf_game.from_string(fin.read())

        tt0 = 0
        tt1 = 0
        it = 0

        for i in xrange(2):
            board, movepairs = gomill.sgf_moves.get_setup_and_moves(game)
            history = []
            for color, move in movepairs:
                if move:
                    it += 1
                    row, col = move
                    board.play(row, col, color)

                    s = time.clock()
                    c1 = get_cube_tian_zhu_2015(
                        State(board, None, history,
                              BrWr(Rank.from_string('1p'), None)),
                        gomill.common.opponent_of(color))
                    #c1 = get_cube_clark_storkey_2014(State(board, None, history), gomill.common.opponent_of(color))
                    tt0 += time.clock() - s

                    #s = time.clock()
                    #c2 = get_cube_clark_storkey_2014_2(State(board, None, history), gomill.common.opponent_of(color))
                    #tt1 += time.clock() - s

                    #assert np.array_equal(c1, c2)

                    history.append((color, move))

        logging.debug("tt0 = %.3f, %.5f per one " % (tt0, tt0 / it))
        logging.debug("tt1 = %.3f, %.5f per one " % (tt1, tt1 / it))
Exemple #2
0
    def test_cube():
        import gomill.boards, gomill.ascii_boards, gomill.common

        from state import State

        logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                            level=logging.DEBUG)

        b = gomill.boards.Board(3)
        moves = [('b', (0, 1)), ('w', (2, 0)), ('b', (1, 1))]

        b2 = gomill.boards.Board(3)
        for col, (x, y) in moves:
            b.play(x, y, col)
            b2.play(2 - x, y, col)  # mirror s.t. we have the same coords
            # with numpy arrays

        logging.debug("\n" + gomill.ascii_boards.render_board(b2))
        cube = get_cube_tian_zhu_2015(
            State(b, None, moves, BrWr(Rank.from_string('1p'), None)), 'w')
        for a in xrange(cube.shape[0]):
            logging.debug("%d\n%s" % (a, cube[a]))
        logging.debug("\n" + str(get_label_future3_exp(moves, 3)))
Exemple #3
0
    def time_cube():
        logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                            level=logging.DEBUG)
        import time
        from state import State
        with open("../test_sgf/test1.sgf", 'r') as fin:
            game = gomill.sgf.Sgf_game.from_string(fin.read())

        tt0 = 0
        tt1 = 0
        it = 0

        for i in xrange(2):
            board, movepairs = gomill.sgf_moves.get_setup_and_moves(game)
            history = []
            for color, move in movepairs:
                if move:
                    it += 1
                    row, col = move
                    board.play(row, col, color)


                    s = time.clock()
                    c1 = get_cube_tian_zhu_2015(State(board, None, history, BrWr(Rank.from_string('1p'), None)), gomill.common.opponent_of(color))
                    #c1 = get_cube_clark_storkey_2014(State(board, None, history), gomill.common.opponent_of(color))
                    tt0 += time.clock() - s

                    #s = time.clock()
                    #c2 = get_cube_clark_storkey_2014_2(State(board, None, history), gomill.common.opponent_of(color))
                    #tt1 += time.clock() - s

                    #assert np.array_equal(c1, c2)

                    history.append((color, move))

        logging.debug("tt0 = %.3f, %.5f per one "%(tt0, tt0/it))
        logging.debug("tt1 = %.3f, %.5f per one "%(tt1, tt1/it))
Exemple #4
0
    def test_cube():
        import gomill.boards,  gomill.ascii_boards, gomill.common

        from state import State

        logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                        level=logging.DEBUG)

        b = gomill.boards.Board(3)
        moves = [('b', (0,1)),
                 ('w', (2,0)),
                 ('b', (1,1))]

        b2 = gomill.boards.Board(3)
        for col, (x,y) in moves:
            b.play(x,y, col)
            b2.play(2-x,y, col) # mirror s.t. we have the same coords
                                # with numpy arrays

        logging.debug("\n"+gomill.ascii_boards.render_board(b2))
        cube = get_cube_tian_zhu_2015(State(b, None, moves, BrWr(Rank.from_string('1p'), None)), 'w')
        for a in xrange(cube.shape[0]):
            logging.debug("%d\n%s"%(a,cube[a]))
        logging.debug("\n"+ str(get_label_future3_exp(moves, 3)))