예제 #1
0
def min(brd, aa= -64, depth=10, best=()):
    if depth == 0:
        return ((), calc(brd))
    val = 64
    bestmove = ()
    moves = brd.getMove(brd.w)
    if len(moves) == 0:
       return (bestmove, 64) 
    if best:
        moves.append(best)
    for i in range(len(moves)-1, -1, -1):
        if best and i < len(moves)-1 and moves[i] == best:
            continue;
        w = move(moves[i][0], moves[i][1], brd.w)
        tmp = Brd(brd.b, w)
        Rule.refresh(moves[i][1], tmp.w, tmp.b, tmp)
        response = max(tmp, val, depth - 1, best=())[1]
        if response < aa:
            bestmove = moves[i]
            val = response
            break
        if response < val:
            bestmove = moves[i]
            val = response
    if val == 64: #white lose anyway
        bestmove = moves[0]
    return (bestmove, val)     
예제 #2
0
def max(brd, bb=64, depth=10, best=()):
    if depth == 0:
        return ((), calc(brd))  
    bestmove = () 
    val = -64  
    moves = brd.getMove(brd.b)
    if len(moves) == 0:
       return (bestmove, -64) 
    if len(best) > 0:
        moves.append(best)
    for i in range(len(moves)-1, -1, -1):
        if best and i < len(moves)-1 and moves[i] == best:
            continue;
        b = move(moves[i][0], moves[i][1], brd.b)
        tmp = Brd(b, brd.w)
        Rule.refresh(moves[i][1], tmp.b, tmp.w, tmp)
        response = min(tmp, val, depth - 1, best=())[1]
        if response > bb:
            bestmove = moves[i]
            val = response
            break;
        if response > val:
            bestmove = moves[i]
            val = response
    if val == -64: #black lose anyway
        bestmove = moves[0]
    return (bestmove, val)
예제 #3
0
파일: main.py 프로젝트: coolcooleric/siding
def moveb(frm, to, brd):
    brd.b = move(frm, to, brd.b)
    Rule.refresh(to, brd.b, brd.w, brd)
    return brd
예제 #4
0
파일: main.py 프로젝트: coolcooleric/siding
def movew(frm, to, brd): 
    brd.w = move(frm, to, brd.w)
    Rule.refresh(to, brd.w, brd.b, brd)
    return brd