示例#1
0
        protected Dictionary<Coord, int> MakeListOfPossiblePlays(Player p, RevGame game)
        {
            int col = 8;
            int row = 8;
            Dictionary<Coord,int> d = new Dictionary<Coord, int>();

            for (int i = 0; i < col; i++)
            {
                for (int j = 0; j < row; j++)
                {
                    if (game.CanPlayThere(p, i, j))
                    {
                        var tokens = game.MakeListOfConvertedTokens(p, i, j);
                        d[new Coord(i,j)] = tokens.Count();
                    }
                }
            }
            return d;
        }
示例#2
0
        public void TestCanPlayThere()
        {
            var board = new RevGame();

            bool actual = board.CanPlayThere(board.CurrentPlayer, 5, 4);
            bool expected = true;

            Assert.AreEqual(expected, actual);

            actual = board.CanPlayThere(board.CurrentPlayer, 5, 3);
            expected = false;

            Assert.AreEqual(expected, actual);

            actual = board.CanPlayThere(board.CurrentPlayer, 0, 0);
            expected = false;

            Assert.AreEqual(expected, actual);

            actual = board.CanPlayThere(board.CurrentPlayer, 4, 4);
            expected = false;

            Assert.AreEqual(expected, actual);
        }
示例#3
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);
 }
示例#4
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
             * */
        }
示例#5
0
        public void TestPutTokenWithNonValidPlayer()
        {
            var board = new RevGame();
            var player = new Player(0);

            board.PutToken(player, 5, 5);
        }
示例#6
0
        public void TestPutTokenOnTokenOfSamePlayer()
        {
            var board = new RevGame();
            var player = board.CurrentPlayer;

            board.PutToken(player, 3, 4);
        }
        private void CreateGame()
        {
            Black = new Player(Token.Black);
            White = new Player(Token.White);

            var queue = new PlayerQueue(Black, White);
            Queue = queue;

            Game = new RevGame(Queue);
            SnapshotContainer = Game.SnapshotContainer;
            SnapshotContainer.SetInitialState(new OnePartTurn() { Board = Game.CloneBoard(), PlayerThatPlayed = White, PlayerToPlay = Black });

            RaisePropertyChanged(() => Game);
            RaisePropertyChanged(() => SnapshotContainer);
        }