예제 #1
0
def test_all_moves2(n):
    res = []
    for i in range(1, 9 + 1):
        for j in range(1, 9 + 1):
            move = i, j
            c_board.make_move(move, CBLACK)
            count = c_board.test_game(n)
            print move, count
            res.append((count, move_as_string(move)))
            c_board.undo_move()
    count = c_board.test_game(n)
    print PASS_MOVE, count
    res.append((count, move_as_string(PASS_MOVE)))
    res.sort()
    pprint(res)
예제 #2
0
def test_all_moves2(n):
    res = []
    for i in range(1, 9+1):
        for j in range(1, 9+1):
            move = i, j
            c_board.make_move(move, CBLACK)
            count = c_board.test_game(n)
            print move, count
            res.append((count, move_as_string(move)))
            c_board.undo_move()
    count = c_board.test_game(n)
    print PASS_MOVE, count
    res.append((count, move_as_string(PASS_MOVE)))
    res.sort()
    pprint(res)
예제 #3
0
def test_n(n):
    #on empty 9x9 board tengen:
    #moves, time, moves/s
    #10000000 1.12345790863 8901090.03923
    #100000000 13.0292351246 7675047.61744

    #make move in first empty position
    #games, time, games/s (each 200 moves + 200 undo)
    #10000 1.0918431282 9158.82487299
    #100000 20.221198082 4945.30539658

    #random moves, no checking for new available empty positions
    #games, time, games/s, moves, moves/s
    #100000 4.22188186646 23686.1198781 8515668 2017031.3309

    #random moves, after capture do init_available();
    #games, time, games/s, moves, moves/s
    #100000 8.87007284164 11273.8645765 12873983 1451395.40902

    #random moves, do init_available() at every move + captures
    #games, time, games/s, moves, moves/s
    #100000 15.042181015 6647.97211921 13141933 873672.041766

    #random moves, pass move also option at frequency of 1/'estimate of available moves' , after capture do init_available();
    #games, time, games/s, moves, moves/s
    #10000 0.666018009186 15014.6090077 1122653 1685619.58463
    #100000 7.72982311249 12936.9066465 11184983 1446990.80913


    t0 = time.time()
    #c_board.test(4, 4, n)
    moves = c_board.test_game(n)
    t1 = time.time()
    t = t1-t0
    if t==0.0:
        t = 1E-300
    print n, t, n/t, moves, moves/t
예제 #4
0
def test_n(n):
    #on empty 9x9 board tengen:
    #moves, time, moves/s
    #10000000 1.12345790863 8901090.03923
    #100000000 13.0292351246 7675047.61744

    #make move in first empty position
    #games, time, games/s (each 200 moves + 200 undo)
    #10000 1.0918431282 9158.82487299
    #100000 20.221198082 4945.30539658

    #random moves, no checking for new available empty positions
    #games, time, games/s, moves, moves/s
    #100000 4.22188186646 23686.1198781 8515668 2017031.3309

    #random moves, after capture do init_available();
    #games, time, games/s, moves, moves/s
    #100000 8.87007284164 11273.8645765 12873983 1451395.40902

    #random moves, do init_available() at every move + captures
    #games, time, games/s, moves, moves/s
    #100000 15.042181015 6647.97211921 13141933 873672.041766

    #random moves, pass move also option at frequency of 1/'estimate of available moves' , after capture do init_available();
    #games, time, games/s, moves, moves/s
    #10000 0.666018009186 15014.6090077 1122653 1685619.58463
    #100000 7.72982311249 12936.9066465 11184983 1446990.80913

    t0 = time.time()
    #c_board.test(4, 4, n)
    moves = c_board.test_game(n)
    t1 = time.time()
    t = t1 - t0
    if t == 0.0:
        t = 1E-300
    print n, t, n / t, moves, moves / t
예제 #5
0
def test_all_moves4(n, size=9):
    t0 = time.time()
    res = []
    seen_patterns = {}
    g = CGame(size)
    for m1 in g.iterate_moves():
        g.make_move(m1)
        g.make_move(PASS_MOVE)
        for m2 in g.iterate_moves():
            moves_tuple = normalize_moves([m1, m2], size)
            if moves_tuple not in seen_patterns:
                seen_patterns[moves_tuple] = True
                g.make_move(m2)
                count = c_board.test_game(n)
                moves = move_list_as_string(moves_tuple)
                res.append((count, moves))
                print len(res), moves, count
                g.undo_move()
        g.undo_move()
        g.undo_move()
    res.sort()
    pprint(res)
    t1 = time.time()
    print t1 - t0
예제 #6
0
def test_all_moves3(n):
    t0 = time.time()
    res = []
    g = Game(9)
    for m1 in g.iterate_moves():
        g.make_move(m1)
        c_board.make_move(m1, CBLACK)
        for m2 in g.iterate_moves():
            g.make_move(m2)
            c_board.make_move(m2, CBLACK)
            count = c_board.test_game(n)
            moves = move_list_as_string([m1, m2])
            res.append((count, moves))
            print len(res), moves, count
            if m2 != PASS_MOVE:
                c_board.undo_move()
            g.undo_move()
        if m2 != PASS_MOVE:
            c_board.undo_move()
        g.undo_move()
    res.sort()
    pprint(res)
    t1 = time.time()
    print t1 - t0
예제 #7
0
def test_all_moves4(n, size=9):
    t0 = time.time()
    res = []
    seen_patterns = {}
    g = CGame(size)
    for m1 in g.iterate_moves():
        g.make_move(m1)
        g.make_move(PASS_MOVE)
        for m2 in g.iterate_moves():
            moves_tuple = normalize_moves([m1, m2], size)
            if moves_tuple not in seen_patterns:
                seen_patterns[moves_tuple] = True
                g.make_move(m2)
                count = c_board.test_game(n)
                moves = move_list_as_string(moves_tuple)
                res.append((count, moves))
                print len(res), moves, count
                g.undo_move()
        g.undo_move()
        g.undo_move()
    res.sort()
    pprint(res)
    t1 = time.time()
    print t1-t0
예제 #8
0
def test_all_moves3(n):
    t0 = time.time()
    res = []
    g = Game(9)
    for m1 in g.iterate_moves():
        g.make_move(m1)
        c_board.make_move(m1, CBLACK)
        for m2 in g.iterate_moves():
            g.make_move(m2)
            c_board.make_move(m2, CBLACK)
            count = c_board.test_game(n)
            moves = move_list_as_string([m1, m2])
            res.append((count, moves))
            print len(res), moves, count
            if m2!=PASS_MOVE:
                c_board.undo_move()
            g.undo_move()
        if m2!=PASS_MOVE:
            c_board.undo_move()
        g.undo_move()
    res.sort()
    pprint(res)
    t1 = time.time()
    print t1-t0