Ejemplo n.º 1
0
 public void Play(RevGame game)
 {
     var plays = MakeListOfPossiblePlays(this, game);
     var bestPlay = plays.First(x => x.Value == plays.Max(y => y.Value)).Key;
     game.Play(this, bestPlay.x, bestPlay.y);
 }
Ejemplo n.º 2
0
        public void TestPlay()
        {
            var board = new RevGame();
            var black = board.CurrentPlayer;

            /*
             * x0 1 2 3 4 5 6 7
             * 0
             * 1
             * 2
             * 3      o x
             * 4      x o
             * 5
             * 6
             * 7
             * */

            board.Play(black, 5, 4);
            var white = board.CurrentPlayer;
            Assert.AreEqual(4, board.ScoreOf(black));
            Assert.AreEqual(1, board.ScoreOf(white));
            Assert.AreNotSame(black, white);

            /*
             * x0 1 2 3 4 5 6 7
             * 0
             * 1
             * 2
             * 3      o x
             * 4      x x x
             * 5
             * 6
             * 7
             * */

            board.Play(white, 5, 5);
            Assert.AreEqual(3, board.ScoreOf(black));
            Assert.AreEqual(3, board.ScoreOf(white));
            /*
             * x0 1 2 3 4 5 6 7
             * 0
             * 1
             * 2
             * 3      o x
             * 4      x o x
             * 5          o
             * 6
             * 7
             * */

            board.Play(black, 4, 5);
            Assert.AreEqual(5, board.ScoreOf(black));
            Assert.AreEqual(2, board.ScoreOf(white));

            /*
             * x0 1 2 3 4 5 6 7
             * 0
             * 1
             * 2
             * 3      o x
             * 4      x x x
             * 5        x o
             * 6
             * 7
             * */

            board.Play(white, 5, 3);
            Assert.AreEqual(3, board.ScoreOf(black));
            Assert.AreEqual(5, board.ScoreOf(white));

            /*
             * x0 1 2 3 4 5 6 7
             * 0
             * 1
             * 2
             * 3      o o o
             * 4      x x o
             * 5        x o
             * 6
             * 7
             * */

            board.Play(black, 6, 5);
            Assert.AreEqual(5, board.ScoreOf(black));
            Assert.AreEqual(4, board.ScoreOf(white));

            /*
             * x0 1 2 3 4 5 6 7
             * 0
             * 1
             * 2
             * 3      o o o
             * 4      x x o
             * 5        x x x
             * 6
             * 7
             * */

            board.Play(white, 4, 6);
            Assert.AreEqual(7, board.ScoreOf(white));
            Assert.AreEqual(3, board.ScoreOf(black));

            /*
             * x0 1 2 3 4 5 6 7
             * 0
             * 1
             * 2
             * 3      o o o
             * 4      x o o
             * 5        o x x
             * 6        o
             * 7
             * */
        }