示例#1
0
def runWorker(pipe, lines, i, moveTime):
    nrPassed = 0
    for rawLine in lines:
        i += 1
        pos, operations = parseEpd(rawLine)
        bm = [
            chessmoves.move(pos, bm, notation='uci')[0]
            for bm in operations['bm'].split()
        ]  # best move
        am = [
            chessmoves.move(pos, am, notation='uci')[0]
            for am in operations['am'].split()
        ]  # avoid move
        dm = [int(dm) for dm in operations['dm'].split()]  # mate distance
        score, move = engine.search(pos, movetime=moveTime, info=None)
        mate = None
        if score >= 31.0: mate = 32.0 - score
        if score <= -31.0: mate = -32.0 - score
        if mate is not None:
            mate = (int(round(mate * 1000.0)) + 1) // 2
        if (len(bm) == 0 or move in bm) and\
           (len(am) == 0 or move not in am) and\
           (len(dm) == 0 or mate in dm):
            print '%5d OK  bestmove %-5s score %+7.3f mate %-4s epd %s' % (
                i, move, score, mate, rawLine),
            nrPassed += 1
        else:
            print '%5d NOK bestmove %-5s score %+7.3f mate %-4s epd %s' % (
                i, move, score, mate, rawLine),
    pipe.send((nrPassed, len(lines)))
示例#2
0
文件: epdtest.py 项目: kervinck/floyd
def runWorker(pipe, lines, i, moveTime):
        nrPassed = 0
        for rawLine in lines:
                i += 1
                pos, operations = parseEpd(rawLine)
                bm = [chessmoves.move(pos, bm, notation='uci')[0] for bm in operations['bm'].split()] # best move
                am = [chessmoves.move(pos, am, notation='uci')[0] for am in operations['am'].split()] # avoid move
                dm = [int(dm) for dm in operations['dm'].split()] # mate distance
                score, move = engine.search(pos, movetime=moveTime, info=None)
                mate = None
                if score >=  31.0: mate =  32.0 - score
                if score <= -31.0: mate = -32.0 - score
                if mate is not None:
                        mate = (int(round(mate * 1000.0)) + 1) // 2
                if (len(bm) == 0 or move in bm) and\
                   (len(am) == 0 or move not in am) and\
                   (len(dm) == 0 or mate in dm):
                        print '%5d OK  bestmove %-5s score %+7.3f mate %-4s epd %s' % (i, move, score, mate, rawLine),
                        nrPassed += 1
                else:
                        print '%5d NOK bestmove %-5s score %+7.3f mate %-4s epd %s' % (i, move, score, mate, rawLine),
        pipe.send((nrPassed, len(lines)))
示例#3
0
                 ('rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6',
                  0x22a48b5a8e47ff78),
                 ('rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPPKPPP/RNBQ1BNR b kq -',
                  0x652a607ca3f242c1),
                 ('rnbq1bnr/ppp1pkpp/8/3pPp2/8/8/PPPPKPPP/RNBQ1BNR w - -',
                  0x00fdd303c946bdd9),
                 ('rnbqkbnr/p1pppppp/8/8/PpP4P/8/1P1PPPP1/RNBQKBNR b KQkq c3',
                  0x3c8123ea7b067637),
                 ('rnbqkbnr/p1pppppp/8/8/P6P/R1p5/1P1PPPP1/1NBQKBNR b Kkq -',
                  0x5c3f9b829b279560)]:
    hash = cm.hash(pos)
    result = 'OK' if hash == ref else 'NOK'
    print '0x%016x [ref: 0x%016x] %s %s' % (hash, ref, result, pos)

# Test move parsing

parsePos = '6k1/1P6/8/b1PpP3/4PN2/2N5/8/R3K2R w KQ d6'

for move in [
        'Ke2', 'Ke', 'cd', 'exd5', 'exd6', 'RxB', 'xB', 'NxP', 'foo', 'NP',
        '123', 'abc', 'Ae2', 'b', '78', '8', '7b', 'exd', 'b8=Q', 'b8', 'b7b8',
        'b8=N', 'b8=R', 'b8=B', 'b7b8q', 'b7b8r', 'b7b8b', 'b7b8n', 'b8=A',
        'bKe', 'cxd', 'exd', 'O-O', 'O-O-O', 'OO', 'OOO', 'o-o', 'o-o-o', 'oo',
        'ooo', '0-0', '0-0-0', '00', '000', 'O-O-0', 'o-o-o-o', 'o-oo', 'oo-o',
        'O-O-', 'o', '0', 'O', 'O--O'
]:
    try:
        print 'parse:', parsePos, move, '->', cm.move(parsePos, move)
    except ValueError as err:
        print err
示例#4
0
文件: epdtest.py 项目: raimarHD/lcec
        fields = [op for op in line[4].split(';') if len(op) > 0]
        fields = [op.strip().split(' ', 1) for op in fields]
        operations.update(dict(fields))

        return pos, operations

nrPassed = 0
nrTests = 0

movetime = float(sys.argv[1])

for rawLine in sys.stdin:
        print rawLine,
        nrTests += 1
        pos, operations = parseEpd(rawLine)
        bm = [chessmoves.move(pos, bm, notation='uci')[0] for bm in operations['bm'].split()] # best move
        am = [chessmoves.move(pos, am, notation='uci')[0] for am in operations['am'].split()] # avoid move
        dm = [int(dm) for dm in operations['dm'].split()] # mate distance
        score, move = engine.search(pos, movetime=movetime, info='uci')
        mate = None
        if score >=  31.0: mate =  32.0 - score
        if score <= -31.0: mate = -32.0 - score
        if mate is not None:
                mate = (int(round(mate * 1000.0)) + 1) // 2
        print 'bestmove', move, 'score', score, 'mate', mate
        print 'test',
        if (len(bm) == 0 or move in bm) and\
           (len(am) == 0 or move not in am) and\
           (len(dm) == 0 or mate in dm):
                print 'result OK',
                nrPassed += 1
示例#5
0
        ('rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6', 0x22a48b5a8e47ff78),
        ('rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPPKPPP/RNBQ1BNR b kq -', 0x652a607ca3f242c1),
        ('rnbq1bnr/ppp1pkpp/8/3pPp2/8/8/PPPPKPPP/RNBQ1BNR w - -', 0x00fdd303c946bdd9),
        ('rnbqkbnr/p1pppppp/8/8/PpP4P/8/1P1PPPP1/RNBQKBNR b KQkq c3', 0x3c8123ea7b067637),
        ('rnbqkbnr/p1pppppp/8/8/P6P/R1p5/1P1PPPP1/1NBQKBNR b Kkq -', 0x5c3f9b829b279560)
        ]:
        hash = cm.hash(pos)
        result = 'OK' if hash == ref else 'NOK'
        print '0x%016x [ref: 0x%016x] %s %s' % (hash, ref, result, pos)

# Test move parsing

parsePos = '6k1/1P6/8/b1PpP3/4PN2/2N5/8/R3K2R w KQ d6'

for move in [
        'Ke2', 'Ke', 'cd', 'exd5', 'exd6', 'RxB', 'xB', 'NxP',
        'foo', 'NP', '123', 'abc',
        'Ae2', 'b', '78', '8', '7b',
        'exd',
        'b8=Q', 'b8', 'b7b8', 'b8=N', 'b8=R', 'b8=B',
        'b7b8q', 'b7b8r', 'b7b8b', 'b7b8n',
        'b8=A', 'bKe', 'cxd', 'exd',
        'O-O', 'O-O-O', 'OO', 'OOO',
        'o-o', 'o-o-o', 'oo', 'ooo',
        '0-0', '0-0-0', '00', '000',
        'O-O-0', 'o-o-o-o', 'o-oo', 'oo-o', 'O-O-', 'o', '0', 'O', 'O--O']:
        try:
                print 'parse:', parsePos, move, '->', cm.move(parsePos, move)
        except ValueError as err:
                print err