本文整理汇总了C#中Portfish.Position.see方法的典型用法代码示例。如果您正苦于以下问题:C# Position.see方法的具体用法?C# Position.see怎么用?C# Position.see使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfish.Position
的用法示例。
在下文中一共展示了Position.see方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: connected_threat
// connected_threat() tests whether it is safe to forward prune a move or if
// is somehow connected to the threat move returned by null search.
static bool connected_threat(Position pos, Move m, Move threat)
{
Debug.Assert(Utils.is_ok_M(m));
Debug.Assert(Utils.is_ok_M(threat));
Debug.Assert(!pos.is_capture_or_promotion(m));
Debug.Assert(!pos.is_passed_pawn_push(m));
Square mfrom, mto, tfrom, tto;
mfrom = Utils.from_sq(m);
mto = Utils.to_sq(m);
tfrom = Utils.from_sq(threat);
tto = Utils.to_sq(threat);
// Case 1: Don't prune moves which move the threatened piece
if (mfrom == tto)
return true;
// Case 2: If the threatened piece has value less than or equal to the
// value of the threatening piece, don't prune moves which defend it.
if (pos.is_capture(threat)
&& (Position.PieceValueMidgame[pos.piece_on(tfrom)] >= Position.PieceValueMidgame[pos.piece_on(tto)]
|| Utils.type_of(pos.piece_on(tfrom)) == PieceTypeC.KING)
&& pos.move_attacks_square(m, tto))
return true;
// Case 3: If the moving piece in the threatened move is a slider, don't
// prune safe moves which block its ray.
if (piece_is_slider(pos.piece_on(tfrom))
&& (Utils.bit_is_set(Utils.between_bb(tfrom, tto), mto) != 0)
&& pos.see(m, true) >= 0)
return true;
return false;
}
示例2: search
//.........这里部分代码省略.........
ThreadHelper.lock_release(sp.Lock);
}
else
moveCount++;
if (RootNode)
{
SignalsFirstRootMove = (moveCount == 1);
if (thisThread == Threads.main_thread() && SearchTime.ElapsedMilliseconds > 2000)
{
Plug.Write("info depth ");
Plug.Write((depth / DepthC.ONE_PLY).ToString());
Plug.Write(" currmove ");
Plug.Write(Utils.move_to_uci(move, Chess960));
Plug.Write(" nodes ");
Plug.Write(pos.nodes.ToString());
Plug.Write(" currmovenumber ");
Plug.Write((moveCount + PVIdx).ToString());
Plug.Write(Constants.endl);
}
}
isPvMove = (PvNode && moveCount <= 1);
captureOrPromotion = pos.is_capture_or_promotion(move);
givesCheck = pos.move_gives_check(move, ci);
dangerous = givesCheck || is_dangerous(pos, move, captureOrPromotion);
ext = DepthC.DEPTH_ZERO;
// Step 12. Extend checks and, in PV nodes, also dangerous moves
if (PvNode && dangerous)
ext = DepthC.ONE_PLY;
else if (givesCheck && pos.see(move, true) >= 0)
ext = DepthC.ONE_PLY / 2;
// Singular extension search. If all moves but one fail low on a search of
// (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move
// is singular and should be extended. To verify this we do a reduced search
// on all the other moves but the ttMove, if result is lower than ttValue minus
// a margin then we extend ttMove.
if (singularExtensionNode
&& (ext == 0)
&& move == ttMove
&& pos.pl_move_is_legal(move, ci.pinned))
{
if (Math.Abs(ttValue) < ValueC.VALUE_KNOWN_WIN)
{
Value rBeta = ttValue - (int)(depth);
ss[ssPos].excludedMove = move;
ss[ssPos].skipNullMove = 1;
value = search(NodeTypeC.NonPV, pos, ss, ssPos, rBeta - 1, rBeta, depth / 2);
ss[ssPos].skipNullMove = 0;
ss[ssPos].excludedMove = MoveC.MOVE_NONE;
if (value < rBeta)
ext = DepthC.ONE_PLY;
}
}
// Update current move (this must be done after singular extension search)
newDepth = depth - DepthC.ONE_PLY + ext;
// Step 13. Futility pruning (is omitted in PV nodes)
if (!PvNode && !inCheck
&& !captureOrPromotion
&& !dangerous
示例3: qsearch
//.........这里部分代码省略.........
// Loop through the moves until no moves remain or a beta cutoff occurs
while (bestValue < beta
&& (move = mp.next_move()) != MoveC.MOVE_NONE)
{
Debug.Assert(Utils.is_ok_M(move));
givesCheck = pos.move_gives_check(move, ci);
// Futility pruning
if (!PvNode
&& !inCheck
&& !givesCheck
&& move != ttMove
&& enoughMaterial
&& ((move & (3 << 14)) != (1 << 14))
&& !pos.is_passed_pawn_push(move))
{
futilityValue = futilityBase
+ Position.PieceValueEndgame[pos.board[move & 0x3F]]
+ (((move & (3 << 14)) == (2 << 14)) ? Constants.PawnValueEndgame : ValueC.VALUE_ZERO);
if (futilityValue < beta)
{
if (futilityValue > bestValue)
bestValue = futilityValue;
continue;
}
// Prune moves with negative or equal SEE
if (futilityBase < beta
&& depth < DepthC.DEPTH_ZERO
&& pos.see(move, false) <= 0)
continue;
}
// Detect non-capture evasions that are candidate to be pruned
evasionPrunable = !PvNode
&& inCheck
&& bestValue > ValueC.VALUE_MATED_IN_MAX_PLY
&& !(((pos.board[move & 0x3F] != PieceC.NO_PIECE) && !((move & (3 << 14)) == (3 << 14))) || ((move & (3 << 14)) == (2 << 14)))
&& ((pos.st.castleRights & (CastleRightC.WHITE_ANY << (pos.sideToMove << 1))) == 0);
// Don't search moves with negative SEE values
if (!PvNode
&& move != ttMove
&& (!inCheck || evasionPrunable)
&& (move & (3 << 14)) != (1 << 14)
&& pos.see(move, true) < 0)
continue;
// Don't search useless checks
if (!PvNode
&& !inCheck
&& givesCheck
&& move != ttMove
&& !(((move & (3 << 14)) != 0) ? ((move & (3 << 14)) != (3 << 14)) : (pos.board[move & 0x3F] != PieceC.NO_PIECE))
&& ss[ssPos].eval + Constants.PawnValueMidgame / 4 < beta
&& !check_is_dangerous(pos, move, futilityBase, beta))
continue;
// Check for legality only before to do the move
if (!pos.pl_move_is_legal(move, ci.pinned))
continue;
示例4: MovePickerC
internal void MovePickerC(Position p, Move ttm, History h, PieceType pt)
{
pos = p;
H = h;
curMovePos = 0;
lastMovePos = 0;
Debug.Assert(!pos.in_check());
depth = 0;
ttMove = 0;
lastQuietPos = 0; lastBadCapturePos = 0;
mpos = 0;
phase = SequencerC.PROBCUT;
// In ProbCut we generate only captures better than parent's captured piece
captureThreshold = Position.PieceValueMidgame[pt];
ttMove = ((ttm != 0) && pos.is_pseudo_legal(ttm) ? ttm : MoveC.MOVE_NONE);
if ((ttMove != 0) && (!pos.is_capture(ttMove) || pos.see(ttMove, false) <= captureThreshold))
ttMove = MoveC.MOVE_NONE;
lastMovePos += ((ttMove != MoveC.MOVE_NONE) ? 1 : 0);
}
示例5: search
//.........这里部分代码省略.........
Plug.Write("info depth ");
Plug.Write((depth / DepthC.ONE_PLY).ToString());
Plug.Write(" currmove ");
Plug.Write(Utils.move_to_uci(move, pos.chess960));
Plug.Write(" nodes ");
Plug.Write(pos.nodes.ToString());
Plug.Write(" currmovenumber ");
Plug.Write((moveCount + PVIdx).ToString());
Plug.Write(Constants.endl);
}
}
ext = DepthC.DEPTH_ZERO;
captureOrPromotion = pos.is_capture_or_promotion(move);
givesCheck = pos.move_gives_check(move, ci);
dangerous = givesCheck
|| pos.is_passed_pawn_push(move)
|| Utils.type_of_move(move) == MoveTypeC.CASTLING
|| (captureOrPromotion // Entering a pawn endgame?
&& Utils.type_of(pos.piece_on(Utils.to_sq(move))) != PieceTypeC.PAWN
&& Utils.type_of_move(move) == MoveTypeC.NORMAL
&& (pos.non_pawn_material(ColorC.WHITE) + pos.non_pawn_material(ColorC.BLACK)
- Position.PieceValue[PhaseC.MG][pos.piece_on(Utils.to_sq(move))] == ValueC.VALUE_ZERO));
// Step 12. Extend checks and, in PV nodes, also dangerous moves
if (PvNode && dangerous)
{
ext = DepthC.ONE_PLY;
}
// else if (threatExtension && refutes(pos, move, threatMove))
// {
// ext = DepthC.ONE_PLY;
// }
else if (givesCheck && pos.see(move, true) >= 0)
{
ext = DepthC.ONE_PLY / 2;
}
// Singular extension search. If all moves but one fail low on a search of
// (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move
// is singular and should be extended. To verify this we do a reduced search
// on all the other moves but the ttMove, if result is lower than ttValue minus
// a margin then we extend ttreMove.
if (singularExtensionNode && move == ttMove && (ext == 0) && pos.pl_move_is_legal(move, ci.pinned))
{
Debug.Assert(ttValue != ValueC.VALUE_NONE);
var rBeta = ttValue - depth;
ss[ssPos].excludedMove = move;
ss[ssPos].skipNullMove = 1;
value = search(NodeTypeC.NonPV, pos, ss, ssPos, rBeta - 1, rBeta, depth / 2);
ss[ssPos].skipNullMove = 0;
ss[ssPos].excludedMove = MoveC.MOVE_NONE;
if (value < rBeta)
{
ext = DepthC.ONE_PLY;
}
}
// Update current move (this must be done after singular extension search)
newDepth = depth - DepthC.ONE_PLY + ext;
// Step 13. Futility pruning (is omitted in PV nodes)
if (!PvNode
&& !captureOrPromotion
&& !inCheck
示例6: refutes
// refutes() tests whether a 'first' move is able to defend against a 'second'
// opponent's move. In this case will not be pruned. Normally the second move
// is the threat (the best move returned from a null search that fails low).
private static bool refutes(Position pos, int move, int threat)
{
Debug.Assert(Utils.is_ok_M(move));
Debug.Assert(Utils.is_ok_M(threat));
Square mfrom = Utils.from_sq(move);
Square mto = Utils.to_sq(move);
Square tfrom = Utils.from_sq(threat);
Square tto = Utils.to_sq(threat);
// Don't prune moves of the threatened piece
if (mfrom == tto)
{
return true;
}
// If the threatened piece has value less than or equal to the value of the
// threat piece, don't prune moves which defend it.
if (pos.is_capture(threat)
&& (Position.PieceValue[PhaseC.MG][pos.piece_on(tfrom)] >= Position.PieceValue[PhaseC.MG][pos.piece_on(tto)]
|| Utils.type_of(pos.piece_on(tfrom)) == PieceTypeC.KING))
{
// Update occupancy as if the piece and the threat are moving
var occ = Utils.xor_bit(Utils.xor_bit(Utils.xor_bit(pos.occupied_squares, mfrom), mto), tfrom);
Piece piece = pos.piece_on(mfrom);
// The piece moved in 'to' attacks the square 's' ?
if (Utils.bit_is_set(Position.attacks_from(piece, mto, occ), tto) != 0)
{
return true;
}
// Scan for possible X-ray attackers behind the moved piece
var xray = (Utils.rook_attacks_bb(tto, occ)
& pos.pieces(PieceTypeC.ROOK, PieceTypeC.QUEEN, Utils.color_of(piece)))
| (Utils.bishop_attacks_bb(tto, occ)
& pos.pieces(PieceTypeC.BISHOP, PieceTypeC.QUEEN, Utils.color_of(piece)));
// Verify attackers are triggered by our move and not already existing
if ((xray != 0) && ((xray ^ (xray & pos.attacks_from_QUEEN(tto))) != 0))
{
return true;
}
}
// Don't prune safe moves which block the threat path
if ((Utils.bit_is_set(Utils.between_bb(tfrom, tto), mto) != 0) && pos.see(move, true) >= 0)
{
return true;
}
return false;
}
示例7: qsearch
//.........这里部分代码省略.........
var ci = CheckInfoBroker.GetObject();
ci.CreateCheckInfo(pos);
// Loop through the moves until no moves remain or a beta cutoff occurs
while ((move = mp.next_move()) != MoveC.MOVE_NONE)
{
Debug.Assert(Utils.is_ok_M(move));
givesCheck = pos.move_gives_check(move, ci);
// Futility pruning
if (!PvNode
&& !InCheck
&& !givesCheck
&& !fromNull
&& move != ttMove
&& enoughMaterial
&& Utils.type_of_move(move) != MoveTypeC.PROMOTION && !pos.is_passed_pawn_push(move))
{
futilityValue = futilityBase + Position.PieceValue[PhaseC.EG][pos.board[move & 0x3F]]
+ (Utils.type_of_move(move) == MoveTypeC.ENPASSANT
? Constants.PawnValueEndgame
: ValueC.VALUE_ZERO);
if (futilityValue < beta)
{
bestValue = Math.Max(bestValue, futilityValue);
continue;
}
// Prune moves with negative or equal SEE
if (futilityBase < beta
&& depth < DepthC.DEPTH_ZERO
&& pos.see(move, false) <= 0)
{
bestValue = Math.Max(bestValue, futilityBase);
continue;
}
}
// Detect non-capture evasions that are candidate to be pruned
evasionPrunable = !PvNode
&& InCheck
&& bestValue > ValueC.VALUE_MATED_IN_MAX_PLY
&& !pos.is_capture(move)
&& (pos.can_castle_C(pos.sideToMove) == 0);
// Don't search moves with negative SEE values
if (!PvNode
&& move != ttMove
&& (!InCheck || evasionPrunable)
&& Utils.type_of_move(move) != MoveTypeC.PROMOTION
&& pos.see(move, true) < 0)
{
continue;
}
// Don't search useless checks
if (!PvNode
&& !InCheck
&& givesCheck
&& move != ttMove
&& !pos.is_capture_or_promotion(move)
&& ss[ssPos].staticEval + Constants.PawnValueMidgame / 4 < beta
&& !check_is_dangerous(pos, move, futilityBase, beta))
{