コード例 #1
0
def defencive_moves_safety(model, ply, phase):

    board = model.getBoardAtPly(ply).board
    oldboard = model.getBoardAtPly(ply - 1).board

    if board.arBoard[TCORD(model.getMoveAtPly(ply - 1).move)] != KING:
        return

    color = oldboard.color
    opcolor = 1 - color

    delta_eval_king = leval.evalKing(board, color, phase) - \
                      leval.evalKing(oldboard, color, phase)

    # PyChess points tropism to queen for phase <= 3. Thus we set a high phase
    delta_eval_tropism = leval.evalKingTropism(board, opcolor, 10) - \
                         leval.evalKingTropism(oldboard, opcolor, 10)

    # Notice, that tropism was negative
    delta_score = delta_eval_king - delta_eval_tropism / 2

    if delta_score > 35:
        yield _("improves king safety")
    elif delta_score > 15:
        yield _("slightly improves king safety")
コード例 #2
0
ファイル: strateval.py プロジェクト: btrent/knave
def defencive_moves_safety (model, ply, phase):

    board = model.getBoardAtPly(ply).board
    oldboard = model.getBoardAtPly(ply-1).board

    if board.arBoard[TCORD(model.getMoveAtPly(ply-1).move)] != KING:
        return

    color = oldboard.color
    opcolor = 1-color

    delta_eval_king = leval.evalKing(board, color, phase) - \
                      leval.evalKing(oldboard, color, phase)

    # PyChess points tropism to queen for phase <= 3. Thus we set a high phase
    delta_eval_tropism = leval.evalKingTropism(board, opcolor, 10) - \
                         leval.evalKingTropism(oldboard, opcolor, 10)

    # Notice, that tropism was negative
    delta_score = delta_eval_king - delta_eval_tropism/2

    if delta_score > 35:
        yield _("improves king safety")
    elif delta_score > 15:
        yield _("slightly improves king safety")
コード例 #3
0
def simple_tropism(model, ply, phase):

    board = model.getBoardAtPly(ply).board
    oldboard = model.getBoardAtPly(ply - 1).board
    color = oldboard.color

    move = model.getMoveAtPly(ply - 1).move
    fcord = FCORD(move)
    tcord = TCORD(move)
    arBoard = board.arBoard

    if arBoard[tcord] != PAWN:
        score = leval.evalKingTropism(board, color, phase)
        oldscore = leval.evalKingTropism(oldboard, color, phase)
    else:
        if color == WHITE:
            rank23 = brank67[BLACK]
        else:
            rank23 = brank67[WHITE]
        if bitPosArray[fcord] & rank23:
            yield 2, _("develops a pawn: %s") % reprCord[tcord]
        else:            yield 1, _("brings a pawn closer to the backrow: %s") % \
                                                               reprCord[tcord]
        return

    king = board.kings[color]
    opking = board.kings[1 - color]

    if score > oldscore:
        # in FISCHERRANDOMCHESS unusual casting case the tcord is
        # the involved rook's position, not the king's destination!
        flag = move >> 12
        if flag in (KING_CASTLE, QUEEN_CASTLE):
            piece = KING
        else:
            piece = arBoard[tcord]
        if phase >= 5 or distance[piece][fcord][opking] < \
                distance[piece][fcord][king]:
            yield score - oldscore, _(
                "brings a %(piece)s closer to enemy king: %(cord)s") % {
                    'piece': reprPiece[piece],
                    'cord': reprCord[tcord]
                }
        else:
            yield (score -
                   oldscore) * 2, _("develops a %(piece)s: %(cord)s") % {
                       'piece': reprPiece[piece].lower(),
                       'cord': reprCord[tcord]
                   }
コード例 #4
0
ファイル: strateval.py プロジェクト: btrent/knave
def simple_tropism (model, ply, phase):

    board = model.getBoardAtPly(ply).board
    oldboard = model.getBoardAtPly(ply-1).board
    color = oldboard.color

    move = model.getMoveAtPly(ply-1).move
    fcord = FCORD(move)
    tcord = TCORD(move)
    arBoard = board.arBoard

    if arBoard[tcord] != PAWN:
        score = leval.evalKingTropism(board, color, phase)
        oldscore = leval.evalKingTropism(oldboard, color, phase)
    else:
        if color == WHITE:
            rank23 = brank67[BLACK]
        else: rank23 = brank67[WHITE]
        if bitPosArray[fcord] & rank23:
            yield 2, _("develops a pawn: %s") % reprCord[tcord]
        else: yield 1, _("brings a pawn closer to the backrow: %s") % \
                                                                 reprCord[tcord]
        return

    king = board.kings[color]
    opking = board.kings[1-color]

    if score > oldscore:
        # in FISCHERRANDOMCHESS unusual casting case the tcord is
        # the involved rook's position, not the king's destination!
        flag = move >> 12
        if flag in (KING_CASTLE, QUEEN_CASTLE):
            piece = KING
        else:
            piece = arBoard[tcord]
        if phase >= 5 or distance[piece][fcord][opking] < \
                distance[piece][fcord][king]:
            yield score-oldscore, _("brings a %(piece)s closer to enemy king: %(cord)s") % {
                                    'piece': reprPiece[piece], 'cord': reprCord[tcord]}
        else:
            yield (score-oldscore)*2, _("develops a %(piece)s: %(cord)s") % {
                                    'piece': reprPiece[piece].lower(), 'cord': reprCord[tcord]}
コード例 #5
0
ファイル: strateval.py プロジェクト: xaosfiftytwo/veinsbot
def simple_tropism (model, phase):
    
    board = model.boards[-1].board
    oldboard = model.boards[-2].board
    color = oldboard.color

    move = model.moves[-1].move
    fcord = FCORD(move)
    tcord = TCORD(move)
    arBoard = board.arBoard
    
    if arBoard[tcord] != PAWN:
        score = leval.evalKingTropism(board)
        oldboard.setColor(1-oldboard.color)
        oldscore = leval.evalKingTropism(oldboard)
        oldboard.setColor(1-oldboard.color)
    else:
        if color == WHITE:
            rank23 = brank67[BLACK]
        else: rank23 = brank67[WHITE]
        if bitPosArray[fcord] & rank23:
            yield 2, _("develops a %s: %s") % (reprPiece[PAWN], reprCord[tcord])
        else: yield 1, _("brings a pawn closer to the backrow: %s") % \
                                                                 reprCord[tcord]
        return
        
    king = board.kings[color]
    opking = board.kings[1-color]
    
    if score > oldscore:
        if phase >= 5 or distance[fcord][opking] < distance[fcord][king]:
            yield score-oldscore, _("brings a %s closer to enemy king: %s") % \
                    (reprPiece[arBoard[tcord]], reprCord[tcord])
        else:
            yield (score-oldscore)*2, _("develops a %s: %s") % \
                    (reprPiece[arBoard[tcord]], reprCord[tcord])