Beispiel #1
0
        public void GetPossibleExpansionsWeighted()
        {
            /* A F
             * B E
             * C-DG */
            TestFloorPlan floorPlan;
            {
                Rect[] rooms = new Rect[]
                {
                    new Rect(3, 1, 2, 2),
                    new Rect(3, 3, 2, 2),
                    new Rect(3, 5, 2, 3),
                    new Rect(7, 5, 2, 3),
                    new Rect(7, 3, 2, 2),
                    new Rect(7, 1, 2, 2),
                    new Rect(9, 6, 2, 2),
                };
                var links = new Tuple <char, char>[]
                {
                    Tuple.Create('A', 'B'),
                    Tuple.Create('B', 'C'),
                    Tuple.Create('C', 'a'),
                    Tuple.Create('a', 'D'),
                    Tuple.Create('D', 'E'),
                    Tuple.Create('E', 'F'),
                    Tuple.Create('D', 'G'),
                };
                floorPlan = TestFloorPlan.InitFloorToContext(
                    new Loc(22, 14),
                    rooms,
                    new Rect[] { new Rect(5, 6, 2, 2) },
                    links);
            }

            var candList = new List <RoomHallIndex>
            {
                new RoomHallIndex(0, false),
                new RoomHallIndex(1, false),
                new RoomHallIndex(2, false),
            };

            var nodes = ConnectTestStep.GetPossibleExpansions(floorPlan, candList);

            Assert.That(nodes.Count, Is.EqualTo(2));
            Assert.That(nodes.GetSpawnRate(0), Is.EqualTo(6));
            Assert.That(nodes.GetSpawn(0).From, Is.EqualTo(new RoomHallIndex(0, false)));
            Assert.That(nodes.GetSpawn(0).To, Is.EqualTo(new RoomHallIndex(5, false)));
            Assert.That(nodes.GetSpawn(0).Connector, Is.EqualTo(new Rect(5, 1, 2, 2)));
            Assert.That(nodes.GetSpawnRate(1), Is.EqualTo(4));
            Assert.That(nodes.GetSpawn(1).From, Is.EqualTo(new RoomHallIndex(1, false)));
            Assert.That(nodes.GetSpawn(1).To, Is.EqualTo(new RoomHallIndex(4, false)));
            Assert.That(nodes.GetSpawn(1).Connector, Is.EqualTo(new Rect(5, 3, 2, 2)));
        }
Beispiel #2
0
        public void GetPossibleExpansionsAll()
        {
            /*     A B
            *
            *
            *
            *  C   D     E
            |
            |  F   a-G   H
            |
            |
            |      I J     */
            // go through and refuse all GetRoomToConnect calls
            // measure the GetRoomToConnect Calls
            TestFloorPlan floorPlan;
            {
                Rect[] rooms = new Rect[]
                {
                    new Rect(5, 1, 1, 2),
                    new Rect(7, 1, 2, 2),
                    new Rect(1, 5, 2, 1),
                    new Rect(5, 5, 2, 2),
                    new Rect(11, 5, 2, 1),
                    new Rect(1, 7, 2, 1),
                    new Rect(7, 7, 2, 2),
                    new Rect(11, 7, 2, 1),
                    new Rect(5, 11, 1, 2),
                    new Rect(7, 11, 1, 2),
                };
                floorPlan = TestFloorPlan.InitFloorToContext(
                    new Loc(22, 14),
                    rooms,
                    new Rect[] { new Rect(5, 7, 2, 2) },
                    new Tuple <char, char>[] { Tuple.Create('D', 'a'), Tuple.Create('a', 'G') });
            }

            var candList = new List <RoomHallIndex>
            {
                new RoomHallIndex(3, false),
                new RoomHallIndex(0, true),
                new RoomHallIndex(6, false),
            };

            var nodes = ConnectTestStep.GetPossibleExpansions(floorPlan, candList);

            Assert.That(nodes.Count, Is.EqualTo(8));
        }
Beispiel #3
0
        public void GetPossibleExpansionsOne()
        {
            // two isolated rooms
            TestFloorPlan floorPlan = TestFloorPlan.InitFloorToContext(
                new Loc(22, 14),
                new Rect[] { new Rect(3, 3, 2, 2), new Rect(3, 9, 2, 2) },
                Array.Empty <Rect>(),
                Array.Empty <Tuple <char, char> >());

            var candList = new List <RoomHallIndex> {
                new RoomHallIndex(0, false)
            };
            var nodes = ConnectTestStep.GetPossibleExpansions(floorPlan, candList);

            Assert.That(nodes.Count, Is.EqualTo(1));
            Assert.That(nodes.GetSpawn(0).From, Is.EqualTo(new RoomHallIndex(0, false)));
            Assert.That(nodes.GetSpawn(0).To, Is.EqualTo(new RoomHallIndex(1, false)));
            Assert.That(nodes.GetSpawn(0).Connector, Is.EqualTo(new Rect(3, 5, 2, 4)));
        }