本文整理匯總了C#中Board.Promote方法的典型用法代碼示例。如果您正苦於以下問題:C# Board.Promote方法的具體用法?C# Board.Promote怎麽用?C# Board.Promote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Board
的用法示例。
在下文中一共展示了Board.Promote方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestPromoteWhite
public void TestPromoteWhite()
{
var b = new Board();
int pos = 7 * 8 + 4;
b.State[pos] = Colors.Val(Piece.Pawn, Color.White);
bool success = b.Promote(pos, Piece.Queen);
Assert.IsTrue(success);
Assert.AreEqual(Piece.Queen, b.GetPiece(pos));
}
示例2: TestPromoteNotAtEdgeBlack
public void TestPromoteNotAtEdgeBlack()
{
var b = new Board();
int pos = 1 * 8 + 4;
b.State[pos] = Colors.Val(Piece.Pawn, Color.Black);
bool success = b.Promote(pos, Piece.Queen);
Assert.IsFalse(success);
Assert.AreEqual(Piece.Pawn, b.GetPiece(pos));
}
示例3: MakeMove
private PGNMove MakeMove(PGNToken token, Board position)
{
var move = token.GetMove(position);
if (move.Capture && position.State[move.To] == 0 && position.EnPassantTile == 0)
throw new PGNException("Move is not a capture", token);
if (move.Color != position.PlayerTurn)
throw new PGNException("It is not this players turn to move", token);
if (move.Color != position.GetColor(move.From))
throw new PGNException("Moving piece is not of the expected color", token);
if (move.Piece != position.GetPiece(move.From))
throw new PGNException("Moving piece is not of the expected type", token);
var ok = position.Move(move.From, move.To, true);
if (!ok)
throw new PGNException("Illegal move", token);
if (move.Promotion != Piece.None)
{
ok = position.Promote(move.To, move.Promotion);
if(!ok)
throw new PGNException("Illegal promotion", token);
}
if (move.Check && !position.IsChecked(position.PlayerTurn))
throw new PGNException("Move did not cause a check", token);
if (move.Mate && !position.IsCheckMate())
throw new PGNException("Move did not cause a mate", token);
return move;
}
示例4: TestABNFullgame2
public void TestABNFullgame2()
{
// end results
var board = new Board(true);
string data = "1.e4 e5 2.Nf3 Nf6 3.Nxe5 d6 4.Nf3 Nxe4 5.d4 d5 6.Bd3 Nc6 7.O-O Be7 8.c4 Nb4 9.Be2 O-O 10.Nc3 Bf5 11.a3 Nxc3 12.bxc3 Nc6 13.Re1 Re8 14.Bf4 dxc4 15.Bxc4 Bd6 16.Rxe8+ Qxe8 17.Ng5 Bg6 18.Bxd6 cxd6 19.h4 Qe7 20.Qg4 h6 21.Nf3 Qe4 22.Qg3 Rd8 23.Re1 Qf5 24.Ba2 Qf6 25.Nh2 Qf5 26.Ng4 Kf8 27.Bb1 Qh5 28.Qf4 Bxb1 29.Rxb1 Rd7 30.Ne3 Ne7 31.g3 Nd5 32.Nxd5 Qxd5 33.Re1 Re7 34.Rxe7 Kxe7 35.Qe3+ Qe6 1/2";
var game = new PGNParser().ParseGame(data);
var moves = game.GetMainVariation();
foreach (var move in moves)
{
board.Move(move.From, move.To, true);
if (move.Promotion != 0)
{
bool promoted = board.Promote(move.To, move.Promotion);
Assert.IsTrue(promoted);
}
}
var board2 = Notation.ReadFEN("8/pp2kpp1/3pq2p/8/3P3P/P1P1Q1P1/5P2/6K1 w - - 0 36");
Assert.IsTrue(board2.State.SequenceEqual(board.State));
}
示例5: TestABNFullgame1_3
public void TestABNFullgame1_3()
{
// end results
var board = new Board(true);
string data = "1.e4 c5 2.Nf3 g6 3.c3 Bg7 4.d4 cxd4 5.cxd4 d5 6.exd5 Nf6 7.Bb5+ Nbd7 8.d6 exd6 9.Qe2+ Qe7 10.Bf4 Qxe2+ 11.Kxe2 d5 12.Rc1 O-O 13.Nbd2 a6 14.Bd3 Re8+ 15.Kf1 Nf8 16.Be5 Ne6 17.g3 Bd7 18.Nb3 Ne4 19.Bxg7 Kxg7 20.Nc5 N4xc5 21.dxc5 a5 22.Rc2 Rec8 23.Rac1 Rc7 24.Ne5 Be8 25.c6 b6 26.Nd7 Bxd7 27.cxd7 Rxd7 28.Bb5 Rd6 29.Rc8 Rxc8 30.Rxc8 Kf6 31.h4 h5 32.Ke1 Nc5 33.Ke2 Re6+ 34.Kf3 Ke5 35.Rc7 Rf6+ 36.Ke2 Ne4 37.f4+ Kd4 38.Kf3 Nd6 39.Bd7 Nc4 40.b3 Nd2+ 41.Ke2 Ne4 42.Kf3 Nc5 43.Be8 Kc3 44.Rxf7 Re6 45.Rf8 d4 46.f5 gxf5 47.Bxh5 Re3+ 48.Kg2 Re5 49.Bf3 d3 50.h5 Re6 51.Rxf5 d2 52.Rd5 Nd3 53.Bg4 Re4 54.h6 Rxg4";
data += " 55.h7 d1Q 56.h8Q+ Kc2 57.Qc8+ Kd2 58.Qf8 Qe2+ 59.Kh3 Re4 60.Qf6 Qg4+ 0-1";
var game = new PGNParser().ParseGame(data);
var moves = game.GetMainVariation();
foreach (var move in moves)
{
board.Move(move.From, move.To, true);
if (move.Promotion != 0)
{
bool promoted = board.Promote(move.To, move.Promotion);
Assert.IsTrue(promoted);
}
}
var board2 = Notation.ReadFEN("8/8/1p3Q2/p2R4/4r1q1/1P1n2PK/P2k4/8 w - - 0 61");
Assert.IsTrue(board2.State.SequenceEqual(board.State));
}