예제 #1
0
        public void ReturnNextPossibleMovesReturnsNextPossibleValidMovesNormalMove()
        {
            // Arrange
            var startingX = 4;
            var startingY = 4;
            var expected  = GetDefaultMoveSet();
            // Act
            var actual = _movementHandler.ReturnNextPossibleMoves(startingX, startingY);

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
예제 #2
0
        public Square GetNextSquareToMoveTo(Square currentSquare)
        {
            var allMoves        = _movementHandler.ReturnNextPossibleMoves(currentSquare.x, currentSquare.y);
            var allAllowedMoves = RemoveLandedOnMoves(allMoves);

            _movementHandler.CountOnwardsMoves(allAllowedMoves);

            var LowestNumberMoves = allAllowedMoves.Where(x => x.numOnwardMoves != 0).Min(x => x.numOnwardMoves);
            var potentialMoves    = allAllowedMoves.Where(x => x.numOnwardMoves == LowestNumberMoves).ToList();

            //If multiple, tiebreak
            var optimalMove = potentialMoves[0];

            if (potentialMoves.Count != 1)
            {
                optimalMove = TieBreak(potentialMoves);
            }

            var optimalSquare = GetSquare(optimalMove.xMove, optimalMove.yMove);

            return(optimalSquare);
        }