예제 #1
0
        private static bool HasFilledNeighbour(Cell testCell, HexBoard board)
        {
            Cell[] neighbours = board.Neighbours(testCell);

            foreach (Cell neighbour in neighbours)
            {
                if (!neighbour.IsEmpty())
                {
                    return true;
                }
            }

            Cell[][] neighbours2 = board.Neighbours2(testCell);

            foreach (Cell[] triple in neighbours2)
            {
                if (!triple[0].IsEmpty())
                {
                    return true;
                }
            }

            return false;
        }
예제 #2
0
        public void BoardNeighbours2Test()
        {
            HexBoard hexBoard = new HexBoard(BoardSize);

            for (int x = 0; x < hexBoard.Size; x++)
            {
                for (int y = 0; y < hexBoard.Size; y++)
                {
                    Cell cell = hexBoard.GetCellAt(x, y);

                    var neigbours2 = hexBoard.Neighbours2(cell);

                    Assert.IsNotNull(neigbours2);

                    /* all cells have at least 1 neighbours, and at most 6 */
                    Assert.Greater(neigbours2.GetLength(0), 0);
                    Assert.Less(neigbours2.GetLength(0), 7);

                    foreach (Cell[] triplet in neigbours2)
                    {
                        TestNeighbour2Triplet(cell, triplet);
                    }
                }
            }
        }