Exemplo n.º 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)))
Exemplo n.º 2
0
def evaluateVector(tests, passive, useCache):
        """
        tests    : list of (fen, result) tuples
        passive  : (in/out) dict of positions whose score has stayed constant
        useCache : flag to indicate when cached values can be used
        """

        sumSquaredErrors = 0.0
        scores = []
        active = 0
        for pos, target in tests:
                if not useCache or pos not in passive:
                        score, move = engine.search(pos, depth) # slow
                        if pos in passive:
                                if  score != passive[pos]:
                                        del passive[pos]
                                        active += 1
                        else:
                                active += 1
                else:
                        score = passive[pos] # fast
                scores.append(score)
                p = scoreToP(score)
                sumSquaredErrors += (p - target) * (p - target) 

        return sumSquaredErrors, scores, active
Exemplo n.º 3
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)))
Exemplo n.º 4
0
import floyd as engine
import sys

depth = int(sys.argv[1])
for rawLine in sys.stdin:
    print rawLine,
    score, move = engine.search(rawLine, depth=depth, info='uci')
    print
Exemplo n.º 5
0
        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
        else:
                print 'result FAILED',
        print 'passed %d total %d' % (nrPassed, nrTests)
Exemplo n.º 6
0
import floyd as engine
import sys

depth = int(sys.argv[1])
for rawLine in sys.stdin:
        print rawLine,
        score, move = engine.search(rawLine, depth=depth, info='uci')
        print