本文整理汇总了C++中Position::DoMove方法的典型用法代码示例。如果您正苦于以下问题:C++ Position::DoMove方法的具体用法?C++ Position::DoMove怎么用?C++ Position::DoMove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position::DoMove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// [TestMethod, Description("")]
TEST_F(MoveCheckTest, testIsCheck)
{
Position pos;
Sfen::LoadPosition(pos, sfen);
Move movedata = Sfen::ParseMove(pos, "7b8b+");
ASSERT_EQ(MoveCheck::IsCheck(pos), false);
pos.DoMove(movedata);
ASSERT_EQ(MoveCheck::IsCheck(pos), true);
Sfen::LoadPosition(pos, sfen2);
movedata = Sfen::ParseMove(pos, "S*6h");
ASSERT_EQ(MoveCheck::IsCheck(pos), false);
pos.DoMove(movedata);
ASSERT_EQ(MoveCheck::IsCheck(pos), true);
}
示例2: movedata
// [TestMethod, Description("IsValidのテスト")]
TEST_F(MoveCheckTest, testIsValid)
{
Position pos;
Sfen::LoadPosition(pos, sfen2);
int i = 0;
for (auto& str: moves)
{
Move movedata2 = Sfen::ParseMove(pos, str);
if (is_move(movedata2.move_type()))
{
ASSERT_EQ(MoveCheck::IsValid(pos, movedata2), true);
pos.DoMove(movedata2);
}
i++;
}
Sfen::LoadPosition(pos, sfen2);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::PASS)), true);
Move movedata(MoveType::NORMAL);
ASSERT_EQ(MoveCheck::IsValid(pos, movedata), false);
movedata.set_to(Square::SQ_68);
ASSERT_EQ(MoveCheck::IsValid(pos, movedata), false);
movedata.set_piece(Piece::W_SILVER);
movedata.set_side(WHITE);
ASSERT_EQ(MoveCheck::IsValid(pos, movedata), false);
movedata.set_move_type(MoveType::DROP);
ASSERT_EQ(MoveCheck::IsValid(pos, movedata), true);
movedata.set_piece(Piece::B_SILVER);
ASSERT_EQ(MoveCheck::IsValid(pos, movedata), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_36, Piece::W_GOLD, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_37, Piece::W_SILVER, Piece::NO_PIECE)), true);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::NORMAL, Square::SQ_81, Square::SQ_73, Piece::W_KNIGHT, Piece::NO_PIECE)), false);
// Drop可否判定
Sfen::LoadPosition(pos, sfen3);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_99, Piece::W_PAWN, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_28, Piece::W_PAWN, Piece::NO_PIECE)), true);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_69, Piece::W_LANCE, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_38, Piece::W_LANCE, Piece::NO_PIECE)), true);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_89, Piece::W_KNIGHT, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_48, Piece::W_KNIGHT, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_77, Piece::W_KNIGHT, Piece::NO_PIECE)), true);
// 打ち歩詰め判定
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_77, Piece::W_PAWN, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_77, Piece::W_LANCE, Piece::NO_PIECE)), true);
// Drop可否判定
Sfen::LoadPosition(pos, sfen4);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_11, Piece::B_PAWN, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_82, Piece::B_PAWN, Piece::NO_PIECE)), true);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_41, Piece::B_LANCE, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_72, Piece::B_LANCE, Piece::NO_PIECE)), true);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_21, Piece::B_KNIGHT, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_62, Piece::B_KNIGHT, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_33, Piece::B_KNIGHT, Piece::NO_PIECE)), true);
// 打ち歩詰め判定
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_33, Piece::B_PAWN, Piece::NO_PIECE)), false);
ASSERT_EQ(MoveCheck::IsValid(pos, Move(MoveType::DROP, SQ_NONE, Square::SQ_33, Piece::B_LANCE, Piece::NO_PIECE)), true);
}