Пример #1
0
def main(filename):
    """Takes a filename and attempts to parse it as a position,
       then outputs a few statistics about the possible moves.
    """
    import time
    positionfile = open(filename, 'r')
    ptext = positionfile.readlines()
    if ptext[1][0] == '[':
        ptext = [l.strip() for l in ptext]
        movenum = int(ptext[0][:-1])
        side = "wbgs".index(ptext[0][-1]) % 2
        pos = parse_short_pos(side, 0, ptext[1])
    else:
        movenum, pos = parse_long_pos(ptext)
    print "%d%s" % (movenum, "gs"[pos.color])
    print
    print pos.to_long_board()
    print
    moves = pos.to_placing_moves()
    print moves[0]
    print moves[1]
    print
    steps = pos.get_steps()
    print len(steps), "initial steps"
    starttime = time.time()
    moves = pos.get_moves()
    print len(moves), "unique moves"
    gentime = time.time()

    print "%.2f seconds to generate moves" % (gentime - starttime)

    return

    import board
    mn, opos = board.parse_long_pos(ptext)
    omoves = opos.get_moves()
    del omoves[opos.get_null_move()]
    new_res = set([p.to_short_board() for p in moves.keys()])
    if len(new_res) != len(moves):
        print "duplicate boards in results %d!=%d" % (len(new_res), len(moves))
    old_res = set([p.to_short_str() for p in omoves.keys()])
    if new_res != old_res:
        print "Only in new results:"
        for upos, move in moves.iteritems():
            if upos.to_short_board() not in old_res:
                print pos.steps_to_str(move)
                print upos.to_short_board()
            if upos.color == pos.color:
                print "result position with same color"
            if upos.steps != 0:
                print "result position with steps taken"
            if (upos.last_piece != Piece.EMPTY
                    or upos.last_from != 0x08):
                print "result position with last"
        print
        print "Only in old results:"
        for upos, move in omoves.iteritems():
            if upos.to_short_str() not in new_res:
                print board.steps_to_str(move)
                print upos.to_short_str()
Пример #2
0
import logging 

from subprocess import Popen

import board

from aei import SocketEngine, StdioEngine, EngineController, EngineException

if len(sys.argv) < 2:
    print "usage: analyse boardfile"
    sys.exit()

pfile = open(sys.argv[1], 'r')
plines = pfile.readlines()
movenum, pos = board.parse_long_pos(plines)
pfile.close()

eng = EngineController(StdioEngine("akimot/akimot", logging))

#eng.setoption("tcmove", 120)
#eng.setoption("tcmax", 600)
#eng.setoption("tcmoveused", 0)
#eng.setoption("wreserve", 300)
#eng.setoption("breserve", 300)
#eng.setoption("root_lmr", 0)
#eng.setoption("use_lmr", 0)

#eng.setoption("log_console", 1)
#eng.setoption("depth", "12")
#eng.setoption("hash", 500)
Пример #3
0
import logging

from subprocess import Popen

import board

from aei import SocketEngine, StdioEngine, EngineController, EngineException

if len(sys.argv) < 2:
    print "usage: analyse boardfile"
    sys.exit()

pfile = open(sys.argv[1], 'r')
plines = pfile.readlines()
movenum, pos = board.parse_long_pos(plines)
pfile.close()

eng = EngineController(StdioEngine("akimot/akimot", logging))

#eng.setoption("tcmove", 120)
#eng.setoption("tcmax", 600)
#eng.setoption("tcmoveused", 0)
#eng.setoption("wreserve", 300)
#eng.setoption("breserve", 300)
#eng.setoption("root_lmr", 0)
#eng.setoption("use_lmr", 0)

#eng.setoption("log_console", 1)
#eng.setoption("depth", "12")
#eng.setoption("hash", 500)