Exemple #1
0
        public void ScoreCanTakeInANewBoardAndReturnAZeroScore()
        {
            var board   = new Board();
            var subject = new MinimaxStrategy();

            Assert.Equal(0, subject.Score(board, P1_MARKER, 0));
        }
Exemple #2
0
        public void ScoreIsZeroForADrawnGame()
        {
            var board    = new Board();
            var subject  = new MinimaxStrategy();
            var p1_moves = new [] { 1, 2, 6, 7, 9 };
            var p2_moves = new [] { 3, 4, 5, 8 };

            board.PartiallyFillBoard(p1_moves, P1_MARKER);
            board.PartiallyFillBoard(p2_moves, P2_MARKER);

            Assert.True(subject.rules.IsOver(board, subject.maximizingPlayer));
            Assert.True(subject.rules.CheckIfDraw(board, subject.maximizingPlayer));

            Assert.Equal(0, subject.Score(board, P1_MARKER, 0));
        }
Exemple #3
0
        public void ScoreIsMinusTenIfPlayerOneHasWonTheGame()
        {
            var board   = new Board();
            var subject = new MinimaxStrategy();

            var p1_moves = new [] { 1, 5, 9 };
            var p2_moves = new [] { 2, 4 };

            board.PartiallyFillBoard(p1_moves, P1_MARKER);
            board.PartiallyFillBoard(p2_moves, P2_MARKER);

            subject.maximizingPlayer = P2_MARKER;
            subject.minimizingPlayer = P1_MARKER;

            Assert.True(subject.rules.IsOver(board, P1_MARKER));
            Assert.True(subject.rules.CheckIfWon(board.spaces, P1_MARKER));
            Assert.Equal(-10, subject.Score(board, P1_MARKER, 0));
        }