Ejemplo n.º 1
0
        public void ClearTest()
        {
            HexBoard hexBoard = new HexBoard(BoardSize);

            // set a cell
            hexBoard.PlayMove(1, 1, true);
            Assert.AreEqual(Occupied.PlayerX, hexBoard.GetCellOccupiedAt(1, 1));

            Location loc11 = new Location(1, 1);
            Assert.AreEqual(Occupied.PlayerX, hexBoard.GetCellOccupiedAt(1, 1));
            Assert.AreEqual(Occupied.PlayerX, hexBoard.GetCellOccupiedAt(loc11));

            // reset it
            hexBoard.Clear();
            Assert.AreEqual(Occupied.Empty, hexBoard.GetCellOccupiedAt(1, 1));
            Assert.AreEqual(Occupied.Empty, hexBoard.GetCellOccupiedAt(loc11));
        }
Ejemplo n.º 2
0
        private static HexBoard RandomBoard(int size, int moves, Random rands)
        {
            HexBoard result = new HexBoard(size);

            for (int loopCount = 0; loopCount < moves; loopCount++)
            {
                int x = rands.Next(size);
                int y = rands.Next(size);

                if (result.GetCellOccupiedAt(x, y) == Occupied.Empty)
                {
                    result.PlayMove(x, y, (loopCount % 2 == 0));
                }
            }

            return result;
        }
Ejemplo n.º 3
0
        public void MoveSetsCellOccupied()
        {
            HexBoard hexBoard = new HexBoard(BoardSize);
            Assert.AreEqual(Occupied.Empty, hexBoard.GetCellOccupiedAt(1, 1));

            hexBoard.PlayMove(1, 1, true);
            Assert.AreEqual(Occupied.PlayerX, hexBoard.GetCellAt(1, 1).IsOccupied);
            Assert.AreEqual(Occupied.PlayerX, hexBoard.GetCellOccupiedAt(1, 1));
        }