Beispiel #1
0
        public void FindAdjacentCellsRange1()
        {
            var map = new TerrainMap(new ShortestPath());

            map.InitializeBoard(10, 10);

            var result = map.FindAdjacentCells(3, 3, 0, 1);

            Assert.Equal(6, result.Count);
            Assert.Equal(2, result[0].Col);
            Assert.Equal(4, result[0].Row);

            Assert.Equal(2, result[1].Col);
            Assert.Equal(3, result[1].Row);

            Assert.Equal(3, result[2].Col);
            Assert.Equal(4, result[2].Row);

            Assert.Equal(3, result[3].Col);
            Assert.Equal(2, result[3].Row);

            Assert.Equal(4, result[4].Col);
            Assert.Equal(4, result[4].Row);

            Assert.Equal(4, result[5].Col);
            Assert.Equal(3, result[5].Row);
        }
Beispiel #2
0
        public void FindAdjacentCellsLeftSideTest()
        {
            var map = new TerrainMap(new ShortestPath());

            map.InitializeBoard(7, 6);

            // build a wall of mountains
            for (int i = 0; i < 4; i++)
            {
                map[3, i + 1] = new TerrainCell(3, i + 1, 30);
            }

            var surroundingCells = map.FindAdjacentCells(0, 3, 2, 1)
                                   .OrderBy(u => u.Col)
                                   .ThenBy(u => u.Row)
                                   .ToList();

            Assert.Equal(4, surroundingCells.Count);
            Assert.Equal(0, surroundingCells[0].Col);
            Assert.Equal(2, surroundingCells[0].Row);
            Assert.Equal(0, surroundingCells[1].Col);
            Assert.Equal(4, surroundingCells[1].Row);
            Assert.Equal(1, surroundingCells[2].Col);
            Assert.Equal(2, surroundingCells[2].Row);
            Assert.Equal(1, surroundingCells[3].Col);
            Assert.Equal(3, surroundingCells[3].Row);
        }
Beispiel #3
0
        public void FindAdjacentCellsRange2()
        {
            var map = new TerrainMap(new ShortestPath());

            map.InitializeBoard(10, 10);

            var result = map.FindAdjacentCells(3, 3, 1, 2);

            Assert.Equal(18, result.Count);
        }