本文整理汇总了C#中Situation.GetMoves方法的典型用法代码示例。如果您正苦于以下问题:C# Situation.GetMoves方法的具体用法?C# Situation.GetMoves怎么用?C# Situation.GetMoves使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Situation
的用法示例。
在下文中一共展示了Situation.GetMoves方法的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: MoveToGoalIfPossible
public void MoveToGoalIfPossible()
{
var pos = getStartPositions();
pos[0] = Position.Yellow6;
pos[1] = Position.Green1;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 2);
int selected = p.SelectMove(sit, moves, Piece.Green, 2);
var selectedMove = moves[selected];
Assert.AreEqual(Position.Yellow6, selectedMove.StartPosition);
}
示例3: GetOutOfHomeIfPossible
public void GetOutOfHomeIfPossible()
{
var pos = getStartPositions();
pos[0] = Position.Blue2;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 6);
int selected = p.SelectMove(sit, moves, Piece.Green, 6);
var selectedMove = moves[selected];
Assert.AreEqual(Position.GreenStart, selectedMove.EndPosition);
}
示例4: EatIfYouCan
public void EatIfYouCan()
{
var pos = getStartPositions();
pos[0] = Position.Blue1;
pos[1] = Position.Green1;
pos[4] = Position.Green3;
var sit = new Situation(pos);
var moves = sit.GetMoves(Piece.Green, 2);
int selected = p.SelectMove(sit, moves, Piece.Green, 2);
var selectedMove = moves[selected];
Assert.AreEqual(Position.Green1, selectedMove.StartPosition);
}
示例5: 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]);
}
示例6: TestGreenShouldGetToGoal
public void TestGreenShouldGetToGoal()
{
Position[] pos = getStartPositions();
pos[0] = Position.Yellow6;
Situation start = new Situation(pos);
Move[] moves = start.GetMoves(Piece.Green, 1);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Yellow6, moves[0].StartPosition);
Assert.AreEqual(Position.GreenGoal1, moves[0].EndPosition);
moves = start.GetMoves(Piece.Green, 2);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Yellow6, moves[0].StartPosition);
Assert.AreEqual(Position.GreenGoal2, moves[0].EndPosition);
moves = start.GetMoves(Piece.Green, 3);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Yellow6, moves[0].StartPosition);
Assert.AreEqual(Position.GreenGoal3, moves[0].EndPosition);
moves = start.GetMoves(Piece.Green, 4);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Yellow6, moves[0].StartPosition);
Assert.AreEqual(Position.GreenGoal4, moves[0].EndPosition);
moves = start.GetMoves(Piece.Green, 5);
Assert.AreEqual(0, moves.Length);
}
示例7: 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());
}
示例8: 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]);
}
示例9: 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]);
}
示例10: TestYouCannotMoveOntoYourOwnPiece
public void TestYouCannotMoveOntoYourOwnPiece()
{
Position[] pos = getStartPositions();
pos[0] = Position.Green6;
pos[1] = Position.Green4;
pos[2] = Position.Green2;
Situation start = new Situation(pos);
Move[] moves = start.GetMoves(Piece.Green, 2);
Assert.AreEqual(1, moves.Length, "Should only have 1 option, as others move onto your own piece");
Assert.AreEqual(Position.Green6, moves[0].StartPosition);
Assert.AreEqual(Position.Red1, moves[0].EndPosition);
}
示例11: TestBasicMove
public void TestBasicMove()
{
Position[] pos = getStartPositions();
pos[0] = Position.GreenStart;
Situation start = new Situation(pos);
Move[] moves;
for (int i = 1; i < 6; i++)
{
moves = start.GetMoves(Piece.Green, i);
Assert.AreEqual(1, moves.Length, "Should have 1 option for roll " + i);
Assert.AreEqual((Position)((byte)Position.GreenStart + i), moves[0].EndPosition, "Should move correct amount");
}
moves = start.GetMoves(Piece.Green, 6);
Assert.AreEqual(2, moves.Length, "Should have 2 options for 6");
}
示例12: TestRedShouldGetToGoal
public void TestRedShouldGetToGoal()
{
Position[] pos = getStartPositions();
pos[4] = Position.Green5;
Situation start = new Situation(pos);
Move[] moves = start.GetMoves(Piece.Red, 1);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Green5, moves[0].StartPosition);
Assert.AreEqual(Position.Green6, moves[0].EndPosition);
moves = start.GetMoves(Piece.Red, 2);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Green5, moves[0].StartPosition);
Assert.AreEqual(Position.RedGoal1, moves[0].EndPosition);
moves = start.GetMoves(Piece.Red, 3);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Green5, moves[0].StartPosition);
Assert.AreEqual(Position.RedGoal2, moves[0].EndPosition);
moves = start.GetMoves(Piece.Red, 4);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Green5, moves[0].StartPosition);
Assert.AreEqual(Position.RedGoal3, moves[0].EndPosition);
moves = start.GetMoves(Piece.Red, 5);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.Green5, moves[0].StartPosition);
Assert.AreEqual(Position.RedGoal4, moves[0].EndPosition);
moves = start.GetMoves(Piece.Red, 6);
Assert.AreEqual(1, moves.Length);
Assert.AreEqual(Position.RedHome2, moves[0].StartPosition);
Assert.AreEqual(Position.RedStart, moves[0].EndPosition);
}
示例13: 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());
}
示例14: 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]);
}
示例15: 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]);
}