public void MovesSearchDoesNotChangeBoard() { var board = boardGen.GenerateRandom(8, 4); var logic = new PlayLogic(board); var clone = board.Clone(); logic.AvailableMoves(); Assert.IsTrue(clone.Matches(board), "board matches after searching for available moves"); }
public void AvailableMovesAreSameWhenRotating2() { var board = builder.FromTypeGrid("0111 0011 1100 1100"); var logic = new PlayLogic(board); var movesTop = logic.AvailableMoves(); board.RotateTo(Orientation.Right); var movesRight = logic.AvailableMoves(); board.RotateTo(Orientation.Left); var movesLeft = logic.AvailableMoves(); board.RotateTo(Orientation.Bottom); var movesBottom = logic.AvailableMoves(); CollectionAssert.AreEquivalent(movesTop, movesRight); CollectionAssert.AreEquivalent(movesTop, movesLeft); CollectionAssert.AreEquivalent(movesTop, movesBottom); }
void AvailableMovesAreValid(Board board, int fromType, int numTypes) { var game = new Game(board, GameRules.ClassicRules, PieceType.GetRange(fromType, numTypes)); var logic = new PlayLogic(board); foreach (var move in logic.AvailableMoves()) { System.Console.WriteLine("move: " + move); game.Execute(move); game.Undo(); } }
public void SpecialCaseAvailableMoves() { var board = builder.FromTypeGrid("0111 0011 1100 1100"); board.RotateRight(); var game = new Game(board, GameRules.ClassicRules, PieceType.GetRange(0, 2)); var logic = new PlayLogic(board); foreach (var move in logic.AvailableMoves()) { game.Execute(move); game.Undo(); } Assert.Pass("All moves could be done"); }
public void CanAlwaysSimulateAvailableMovesRnd() { for (int i = 0; i < 10; i++) { var board = generator.GenerateRandom(8, 3); var game = new Game(board, GameRules.ClassicRules, PieceType.GetRange(0, 3)); var logic = new PlayLogic(board); var moves = logic.AvailableMoves(); foreach (var move in moves) { var simulator = MoveSimulator.FromPotentialMove(board, move, game.NextPieceIfPlaying(move)); simulator.Simulate(); Assert.IsTrue(simulator.IsMovePossible()); } } }
public void PiecesInAvailableMovesAreAlone() { var board = builder.FromTypeGrid(new int[, ] { { 0, 1, 2, 0 }, { 1, 0, 0, 2 }, { 1, 1, 1, 2 }, { 0, 1, 1, 2 } }); var logic = new PlayLogic(board); var moves = logic.AvailableMoves(); var orientation = board.Orientation; foreach (var move in moves) { board.RotateTo(move.orientation); var matchingPieces = board.GetMatchingNeighbours(board.Get(move.coord)); Assert.IsEmpty(matchingPieces); board.RotateTo(orientation); } }
public void NewPieceHasExpectedSize() { var board = builder.FromTypeGrid(new int[, ] { { 0, 1, 2, 0 }, { 2, 1, 0, 2 }, { 1, 2, 1, 1 }, { 0, 1, 1, 1 } }); var game = new Game(board, GameRules.ClassicRules, PieceType.GetRange(0, 3)); var logic = new PlayLogic(board); foreach (var move in logic.AvailableMoves()) { var simulator = MoveSimulator.FromPotentialMove(board, move, game.NextPieceIfPlaying(move)); simulator.Simulate(); var actions = simulator.GetMove().consequences; var newPieceAction = actions.First(IsNewPieceAction) as NewPieceAction; Assert.AreEqual(simulator.oldPiece.size, newPieceAction.newPiece.size); } }
public void FallActionsFallPieceSizeRnd() { for (int i = 0; i < 50; i++) { var board = generator.GenerateRandom(4, 3); var game = new Game(board, GameRules.ClassicRules, PieceType.GetRange(0, 3)); var logic = new PlayLogic(board); foreach (var potentialMove in logic.AvailableMoves()) { var simulator = MoveSimulator.FromPotentialMove(board, potentialMove, game.NextPieceIfPlaying(potentialMove)); simulator.Simulate(); var move = simulator.GetMove(); var fallActions = move.consequences.Where(IsFallAction); foreach (var action in fallActions) { var orientatedCoord = board.TransportCoord(potentialMove.coord, potentialMove.orientation); var removedPiece = board.Get(orientatedCoord); Assert.AreEqual(removedPiece.size, (action as FallAction).rows, "Fall Action:\n" + action + ",\nboard:\n" + board + "\nmove:\n" + potentialMove); } } } }