本文整理汇总了C#中Situation.ApplyMove方法的典型用法代码示例。如果您正苦于以下问题:C# Situation.ApplyMove方法的具体用法?C# Situation.ApplyMove怎么用?C# Situation.ApplyMove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Situation
的用法示例。
在下文中一共展示了Situation.ApplyMove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoubleSelfTackleAddsTwoBeers
public void DoubleSelfTackleAddsTwoBeers()
{
var pos = getStartPositions();
pos[0] = Position.Green5;
pos[1] = Position.Green5;
pos[4] = Position.RedStart;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 2);
sit.ApplyMove(moves[0]);
Assert.AreEqual(2, sit.beers[(int)Piece.Green]);
}
示例2: DoubleUnfoldsToStartPosition
public void DoubleUnfoldsToStartPosition()
{
var pos = getStartPositions();
pos[4] = pos[5] = Position.RedGoal1;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Red, 3);
Assert.AreEqual(1, moves.Length);
sit.ApplyMove(moves[0]);
Assert.AreEqual(Piece.Red, sit.board[(int)Position.RedGoal1]);
Assert.AreEqual(Piece.None, sit.board[(int)Position.RedGoal2]);
Assert.AreEqual(Piece.None, sit.board[(int)Position.RedGoal3]);
Assert.AreEqual(Piece.Red, sit.board[(int)Position.RedGoal4]);
}
示例3: DoubleUnfoldsWhenPiecesBeforeItAreFilled
public void DoubleUnfoldsWhenPiecesBeforeItAreFilled()
{
var pos = getStartPositions();
pos[0] = Position.GreenGoal4;
pos[1] = pos[2] = Position.GreenGoal2;
pos[3] = Position.GreenGoal1;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 2);
sit.ApplyMove(moves[0]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal1]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal2]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal3]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal4]);
Assert.AreEqual(Piece.Green, sit.GetWinner());
}
示例4: TestTripleGetEaten
public void TestTripleGetEaten()
{
var pos = getStartPositions();
pos[0] = Position.GreenGoal1;
pos[1] = pos[2] = pos[3] = Position.Yellow6;
pos[4] = Position.Yellow3;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Red, 3);
sit.ApplyMove(moves[0]);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Yellow6, moves[0].EndPosition);
Assert.AreEqual(Piece.None, sit.board[(int)Position.GreenHome1]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenHome2]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenHome3]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenHome4]);
Assert.AreEqual(Position.GreenGoal1, sit.pieces[0]);
Assert.AreEqual(Position.GreenHome2, sit.pieces[1]);
Assert.AreEqual(Position.GreenHome3, sit.pieces[2]);
Assert.AreEqual(Position.GreenHome4, sit.pieces[3]);
}
示例5: TestRedCanQuadruple
public void TestRedCanQuadruple()
{
Position[] pos = getStartPositions();
pos[4] = Position.RedStart;
pos[5] = Position.RedStart;
pos[6] = Position.RedStart;
Situation sit = new Situation(pos);
for (int i = 4; i < 7; i++)
{
Assert.AreEqual(Position.RedStart, sit.pieces[i]);
}
Move[] moves = sit.GetMoves(Piece.Red, 6);
Assert.AreEqual(2, moves.Length);
Assert.AreEqual(Position.RedStart, moves[0].StartPosition);
Assert.AreEqual(Position.Red6, moves[0].EndPosition);
Assert.AreEqual(Position.RedHome4, moves[1].StartPosition);
Assert.AreEqual(Position.RedStart, moves[1].EndPosition);
Assert.AreEqual(MoveType.DoubleUp, moves[1].Type);
sit.ApplyMove(moves[1]);
for (int i = 4; i < 8; i++)
{
Assert.AreEqual(Position.RedStart, sit.pieces[i]);
}
moves = sit.GetMoves(Piece.Red, 3);
Assert.AreEqual(1, moves.Length);
sit.ApplyMove(moves[0]);
for (int i = 4; i < 8; i++)
{
Assert.AreEqual(Position.Red3, sit.pieces[i]);
}
Assert.AreEqual(Piece.None, sit.board[(int)Position.RedStart]);
Assert.AreEqual(Piece.Red, sit.board[(int)Position.Red3]);
}
示例6: TestGreenGoesToGoal
public void TestGreenGoesToGoal()
{
var pos = getStartPositions();
pos[0] = Position.GreenGoal3;
pos[1] = Position.Yellow6;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 1);
Assert.AreEqual(2, moves.Length);
sit.ApplyMove(moves[1]);
Assert.AreEqual(Position.GreenGoal1, sit.pieces[1]);
moves = sit.GetMoves(Piece.Green, 2);
Assert.AreEqual(0, moves.Length);
}
示例7: TestEatingWithMultiplePiecesOnBoard
public void TestEatingWithMultiplePiecesOnBoard()
{
Position[] pos = getStartPositions();
pos[0] = Position.Red1;
pos[4] = Position.GreenStart;
pos[5] = Position.Yellow3;
pos[6] = Position.Red2;
Situation start = new Situation(pos);
Move[] moves = start.GetMoves(Piece.Green, 1);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Red1, moves[0].StartPosition);
Assert.AreEqual(Position.Red2, moves[0].EndPosition);
start.ApplyMove(moves[0]);
Assert.AreEqual(Piece.None, start.board[(int)Position.Red1]);
Assert.AreEqual(Piece.Green, start.board[(int)Position.Red2]);
Assert.AreEqual(Piece.None, start.board[(int)Position.RedHome1]);
Assert.AreEqual(Piece.None, start.board[(int)Position.RedHome2]);
Assert.AreEqual(Piece.Red, start.board[(int)Position.RedHome4]);
Assert.AreEqual(Piece.Red, start.board[(int)Position.RedHome3]);
Assert.AreEqual(Position.RedHome3, start.pieces[6]);
}
示例8: Test2DoublePieces
public void Test2DoublePieces()
{
var pos = getStartPositions();
pos[0] = pos[1] = Position.Yellow2;
pos[2] = pos[3] = Position.Red2;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 4);
sit.ApplyMove(moves[1]);
Assert.AreEqual(2, moves.Length);
Assert.AreEqual(0, moves[0].Piece);
Assert.AreEqual(Position.Yellow2, moves[0].StartPosition);
Assert.AreEqual(Position.Yellow6, moves[0].EndPosition);
Assert.AreEqual(2, moves[1].Piece);
Assert.AreEqual(Position.Red2, moves[1].StartPosition);
Assert.AreEqual(Position.Red6, moves[1].EndPosition);
Assert.AreEqual(Position.Red6, sit.pieces[2]);
Assert.AreEqual(Position.Red6, sit.pieces[3]);
Assert.AreEqual(Piece.None, sit.board[(int)Position.Red2]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.Red6]);
}
示例9: TestDoublePieceMovesTogether
public void TestDoublePieceMovesTogether()
{
Position[] pos = getStartPositions();
pos[0] = Position.GreenStart;
pos[1] = Position.GreenStart;
Situation sit = new Situation(pos);
Move[] moves = sit.GetMoves(Piece.Green, 3);
Assert.AreEqual(1, moves.Length);
sit.ApplyMove(moves[0]);
Assert.AreEqual(Piece.None, sit.board[(int)Position.GreenStart]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.Green3]);
Assert.AreEqual(Position.Green3, sit.pieces[0]);
Assert.AreEqual(Position.Green3, sit.pieces[1]);
}
示例10: TestDoubleGetsEatenAndGetsOut
public void TestDoubleGetsEatenAndGetsOut()
{
var pos = getStartPositions();
pos[0] = pos[1] = Position.RedStart;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Red, 6);
sit.ApplyMove(moves[0]);
moves = sit.GetMoves(Piece.Green, 6);
sit.ApplyMove(moves[0]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenStart]);
Assert.AreEqual(Piece.None, sit.board[(int)Position.GreenHome1]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenHome2]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenHome3]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenHome4]);
Assert.IsTrue(sit.Validate());
}
示例11: TestDoubleArrivesToGoalWithPieceAlreadyInGoal
public void TestDoubleArrivesToGoalWithPieceAlreadyInGoal()
{
var pos = getStartPositions();
pos[0] = Position.GreenGoal1;
pos[1] = pos[2] = Position.Yellow6;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 4);
sit.ApplyMove(moves[0]);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.GreenGoal4, moves[0].EndPosition);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal2]);
Assert.AreEqual(Piece.None, sit.board[(int)Position.GreenGoal3]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal4]);
}
示例12: TestDoubleArrivesToGoal3
public void TestDoubleArrivesToGoal3()
{
var pos = getStartPositions();
pos[0] = pos[1] = Position.Yellow6;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 3);
sit.ApplyMove(moves[0]);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.GreenGoal3, moves[0].EndPosition);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal1]);
Assert.AreEqual(Piece.None, sit.board[(int)Position.GreenGoal2]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal3]);
Assert.AreEqual(Piece.None, sit.board[(int)Position.GreenGoal4]);
Assert.IsTrue(sit.Validate());
}
示例13: TestCloning
public void TestCloning()
{
Situation s = Situation.GameStart();
s.ApplyMove(new Move(0, s.pieces[0], Position.Green4, MoveType.Move));
Situation clone = new Situation(s);
Assert.AreEqual(Piece.Green, clone.board[(int)Position.Green4], "Move should be ok on the clone");
s.ApplyMove(new Move(0, s.pieces[0], Position.Green6, MoveType.Move));
Assert.AreEqual(Piece.None, s.board[(int)Position.Green4], "Move should be have happened on the original");
Assert.AreEqual(Piece.Green, s.board[(int)Position.Green6], "Move should be have happened on the original");
Assert.AreEqual(Piece.Green, clone.board[(int)Position.Green4], "Clone should not be affected");
Assert.AreEqual(Piece.None, clone.board[(int)Position.Green6], "Clone should not be affected");
clone.ApplyMove(new Move(1, clone.pieces[1], Position.GreenGoal2, MoveType.Move));
Assert.AreEqual(Position.GreenGoal2, clone.pieces[1], "Move should be have happened on the clone");
Assert.AreEqual(Position.GreenHome2, s.pieces[1], "Move should be have happened on the clone");
}
示例14: TestAfterEatingHomePiecesShouldBeLastInPieceList
public void TestAfterEatingHomePiecesShouldBeLastInPieceList()
{
Position[] pos = getStartPositions();
pos[0] = Position.Yellow1;
pos[4] = Position.GreenStart;
pos[5] = Position.Yellow3;
pos[6] = Position.Red2;
Situation start = new Situation(pos);
Move[] moves = start.GetMoves(Piece.Green, 2);
start.ApplyMove(moves[0]);
Assert.AreEqual(Position.GreenStart, start.pieces[4]);
Assert.AreEqual(Position.Red2, start.pieces[5]);
Assert.AreEqual(Position.RedHome3, start.pieces[6]);
Assert.AreEqual(Position.RedHome4, start.pieces[7]);
}
示例15: TripleFinishesOverOwnPiece
public void TripleFinishesOverOwnPiece()
{
var pos = getStartPositions();
pos[0] = Position.GreenGoal2;
pos[1] = pos[2] = pos[3] = Position.GreenGoal1;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 3);
sit.ApplyMove(moves[0]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal1]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal2]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal3]);
Assert.AreEqual(Piece.Green, sit.board[(int)Position.GreenGoal4]);
Assert.AreEqual(Piece.Green, sit.GetWinner());
}