Exemple #1
0
        public override void Express(ZeldaDungeonBuilder builder)
        {
            // spawn key
            builder.AddScript(keyLocation, ZeldaScripts.CreateKey(keyType, builder.Lookup));

            // spawn door
            builder.AddUndirectedTransition(doorStart, doorEnd, ZeldaScripts.CreateDoor(keyType, builder.Lookup));
        }
Exemple #2
0
        public void CrawlGenome()
        {
            // 3--2, 0--7, Switch: 4, Key: 3, Door: 9--8, Key: 9, Door: 4--6, 9--0, Key: 8, Door: 8--5, Piston: 7--1, Key: 7, Door: 5--6, Piston: 2--6
            // 0--7, 0--9, 2--3, Key: 3, Key: 7, Key: 8, Key: 9, Door: 4--6, Door: 5--6, Door: 5--8, Door: 8--9, Switch: 4, Piston: 1--7, Piston: 2--6

            var builder = new ZeldaDungeonBuilder();
            var lookup  = builder.Lookup;

            // 0--7, 0--9, 2--3
            builder.AddUndirectedTransition(0, 7, IdentityScript.Default);
            builder.AddUndirectedTransition(0, 9, IdentityScript.Default);
            builder.AddUndirectedTransition(2, 3, IdentityScript.Default);

            // Key: 3, Key: 7, Key: 8, Key: 9
            builder.AddScript(3, ZeldaScripts.CreateKey(0, lookup));
            builder.AddScript(7, ZeldaScripts.CreateKey(0, lookup));
            builder.AddScript(8, ZeldaScripts.CreateKey(0, lookup));
            builder.AddScript(9, ZeldaScripts.CreateKey(0, lookup));

            // Door: 4--6, Door: 5--6, Door: 5--8, Door: 8--9
            builder.AddUndirectedTransition(4, 6, ZeldaScripts.CreateDoor(0, lookup));
            builder.AddUndirectedTransition(5, 6, ZeldaScripts.CreateDoor(0, lookup));
            builder.AddUndirectedTransition(5, 8, ZeldaScripts.CreateDoor(0, lookup));
            builder.AddUndirectedTransition(8, 9, ZeldaScripts.CreateDoor(0, lookup));

            // Switch: 4, Piston: 1--7, Piston: 2--6
            builder.AddScript(4, ZeldaScripts.CreateColorSwitch(0, lookup));

            // Piston: 1--7, Piston: 2--6
            builder.AddUndirectedTransition(1, 7, ZeldaScripts.CreateBluePiston(0, lookup));
            builder.AddUndirectedTransition(2, 6, ZeldaScripts.CreateRedPiston(0, lookup));

            var crawler = builder.Build();
            var dot     = new DotBuilder();

            crawler.Express(dot);

            var initialState = emptyVariables.ToState(builder.Lookup);

            crawler.Crawl(new[] { initialState }, 10000);

            // test for exit reached
            Assert.True(crawler.DebugGetStep(0, initialState).HasDistanceFromExit);
        }
Exemple #3
0
        public void CrawlKeyDoorBatch()
        {
            //  0 -d- 2 -d- 3 -d- 1
            // kkk
            var builder = new ZeldaDungeonBuilder();
            var lookup  = builder.Lookup;

            builder.AddUndirectedTransition(0, 2, ZeldaScripts.CreateDoor(0, lookup));
            builder.AddUndirectedTransition(2, 3, ZeldaScripts.CreateDoor(0, lookup));
            builder.AddUndirectedTransition(3, 1, ZeldaScripts.CreateDoor(0, lookup));
            builder.AddScript(0, ZeldaScripts.CreateKey(0, lookup));
            builder.AddScript(0, ZeldaScripts.CreateKey(0, lookup));
            builder.AddScript(0, ZeldaScripts.CreateKey(0, lookup));
            var crawler = builder.Build();

            var initialState = emptyVariables.ToState(builder.Lookup);

            crawler.Crawl(new[] { initialState }, maxSteps);

            // test for exit reached
            Assert.True(crawler.DebugGetStep(0, initialState).HasDistanceFromExit);
        }