Exemple #1
0
        public bool RunTest(List <string> replays)
        {
            bool            verdict = true;
            List <GamePlay> plays   = loadSavedGamePlays(replays);

            foreach (GamePlay gp in plays)
            {
                int M = (int)gp.numberOfMonsters;


                //player moves to exit node
                List <Specification> XS = new List <Specification>()
                {
                    new Always(G => false), new LeadsTo(G => true, G => G.player.location == G.dungeon.exitNode)
                };

                //at least 1 mosnter died
                Specification S = new LeadsTo(G => countMonsters(G) == M, G => countMonsters(G) < M); //werkt wel

                Specification todo = new Condition(XS, S);

                gp.replay(todo);
                verdict = verdict && todo.getVerdict();
            }
            return(verdict);
        }
Exemple #2
0
        public void LeadsToPredicate2()
        {
            List <GamePlay> plays = loadSavedGamePlays(allReplays);

            foreach (GamePlay gp in plays)
            {
                // test that this specifation is respected by each game-play:
                Specification S = new LeadsTo(G => G.player.location == G.dungeon.startNode, G => G.player.location != G.dungeon.startNode); // countMonsters(G) < M
                gp.replay(S);
                Assert.IsTrue(S.getVerdict());
            }
        }
Exemple #3
0
        public void LeadsToPredicate()
        {
            List <GamePlay> plays = loadSavedGamePlays(allReplays);

            foreach (GamePlay gp in plays)
            {
                // test that this specifation is respected by each game-play:
                int           M = (int)gp.numberOfMonsters;
                Specification S = new LeadsTo(G => countMonsters(G) == M, G => countMonsters(G) < M); // countMonsters(G) < M
                gp.replay(S);
                Assert.IsTrue(S.getVerdict());
            }
        }
        public void LeadsTo_RBridge_Test()
        {
            List <GamePlay> plays = loadSavedGamePlays(new List <string>()
            {
                "End"
            });

            foreach (GamePlay gp in plays)
            {
                // test that this specifation is respected by each game-play:
                Game game = gp.getGame();
                List <Tuple <Bridge, int> > hungry_bridges = new List <Tuple <Bridge, int> >();
                Specification S = new LeadsTo(G => bridge_is_hungry(G, hungry_bridges), G => packs_in_last_zone_are_alert(G));
                gp.replay(S);
                Assert.IsTrue(S.getVerdict());
            }
        }
        public void LeadsTo_REndZone_Test()
        {
            List <GamePlay> plays = loadSavedGamePlays(new List <string>()
            {
                "End"
            });

            foreach (GamePlay gp in plays)
            {
                // test that this specifation is respected by each game-play:
                Game          game       = gp.getGame();
                bool[]        zone_alert = new bool[game.dungeon.difficultyLevel + 2];
                Specification S          = new LeadsTo(G => player_last_zone(G), G => packs_in_last_zone_are_alert(G));
                gp.replay(S);
                Assert.IsTrue(S.getVerdict());
            }
        }
Exemple #6
0
        public void MurderAgent()
        {
            List <GamePlay> plays = loadSavedGamePlays(new List <string>()
            {
                "KillAgent"
            });                                                                            //kills 17 monsters (without using a crystal -> can not accidentally kill more than 17)

            foreach (GamePlay gp in plays)
            {
                List <Specification> antecedents = new List <Specification>()
                {
                    { new Always(G => false) }, { new LeadsTo(G => true, G => G.player.KillPoint == 0) }, { new LeadsTo(G => G.player.KillPoint == 0, G => G.player.KillPoint > 0) },
                    { new Always(G => !(G.player.KillPoint > 17)) }
                };
                Specification consequent = new LeadsTo(G => true, G => G.player.KillPoint == 17);
                // test that this specifation is respected by each game-play:
                Specification S = new Condition(antecedents, consequent);
                gp.replay(S);
                Assert.IsTrue(S.getVerdict());
            }
        }
Exemple #7
0
        public void ConditionPredicateBridge()
        {
            List <GamePlay> plays = loadSavedGamePlays(allReplays);

            foreach (GamePlay gp in plays)
            {
                // test that this specifation is respected by each game-play:
                List <Specification> XS = new List <Specification>()
                {
                    new LeadsTo(G => true, G => G.player.location == G.dungeon.exitNode)
                };
                //the Predicates.isBridge method removes nodes from the graph???? temp solution below
                Specification S = new LeadsTo(G => G.player.location == G.dungeon.startNode, G => G.player.location is Bridge); //werkt wel

                //Specification S = new LeadsTo(G => G.player.location == G.dungeon.startNode, G => Predicates.isBridge(G.dungeon.startNode,G.dungeon.exitNode,G.player.location));
                Specification todo = new Condition(XS, S);

                gp.replay(todo);
                Assert.IsTrue(todo.getVerdict());
            }
        }
Exemple #8
0
        public void GoalAgent()
        {
            List <GamePlay> plays = loadSavedGamePlays(new List <string>()
            {
                "GoalAgent"
            });                                                                            //Passive agent that only focuses on finding the exit, and finishes the game.

            foreach (GamePlay gp in plays)
            {
                List <Specification> antecedents = new List <Specification>()
                {
                    { new Always(G => false) }, { new LeadsTo(G => true, G => G.player.KillPoint == 0) }, { new LeadsTo(G => true, G => G.player.location.nodeLevel == 1) },
                    { new LeadsTo(G => G.player.location.nodeLevel == 1, G => G.player.location.nodeLevel > 1) },
                    { new Always(G => (G.player.KillPoint == 0)) }
                };
                Specification consequent = new LeadsTo(G => true, G => G.player.location == G.dungeon.exitNode);
                // test that this specifation is respected by each game-play:
                Specification S = new Condition(antecedents, consequent);
                gp.replay(S);
                Assert.IsTrue(S.getVerdict());
            }
        }
Exemple #9
0
        public void NoOldZoneTest()
        {
            List <GamePlay> plays = loadSavedGamePlays(new List <string>()
            {
                "ZoneUpAgent"
            });                                                                              //moves to Zone 3.

            foreach (GamePlay gp in plays)
            {
                List <Specification> antecedents = new List <Specification>()
                {
                    { new Always(G => false) }, { new LeadsTo(G => true, G => G.player.location.nodeLevel == 1) },
                    { new LeadsTo(G => G.player.location.nodeLevel == 1, G => G.player.location.nodeLevel > 1) }, { new LeadsTo(G => G.player.location.nodeLevel == 2, G => G.player.location.nodeLevel > 2) },
                    { new Always(G => !(G.player.location.nodeLevel >= 4)) }
                };
                Specification consequent = new LeadsTo(G => true, G => G.player.location.nodeLevel == 3);
                // test that this specifation is respected by each game-play:
                Specification S = new Condition(antecedents, consequent);
                gp.replay(S);
                Assert.IsTrue(S.getVerdict());
            }
        }
Exemple #10
0
        public void ConditionPredicateKP()
        {
            List <GamePlay> plays = loadSavedGamePlays(allReplays);

            foreach (GamePlay gp in plays)
            {
                int M = (int)gp.numberOfMonsters;

                // test that this specifation is respected by each game-play:
                List <Specification> XS = new List <Specification>()
                {
                    new LeadsTo(G => true, G => G.player.KillPoint > 0)
                };

                Specification S = new LeadsTo(G => countMonsters(G) == M, G => countMonsters(G) < M); //werkt wel

                Specification todo = new Condition(XS, S);

                gp.replay(todo);
                Assert.IsTrue(todo.getVerdict());
            }
        }
Exemple #11
0
        public ModuleVertex(XElement element)
        {
            // Check for null parameter.
            if (element == null)
            {
                throw new ArgumentException("Parameter \'element\' can't be null.", "element");
            }

            // Get WarpCode
            var code = element.Attribute(XmlConsts.ATTR_CODE);

            if (code == null || string.IsNullOrEmpty(code.Value))
            {
                throw new ArgumentException("No \'WarpCode\' attribute found in the XML element.");
            }
            else
            {
                WarpCode = code.Value;
            }

            // Get CommonName
            var name = element.Attribute(XmlConsts.ATTR_NAME);

            if (name == null || string.IsNullOrEmpty(name.Value))
            {
                throw new ArgumentException("No \'CommonName\' attribute found in the XML element.");
            }
            else
            {
                CommonName = name.Value;
            }

            // Get list of Tags
            var tags = element.Attribute(XmlConsts.ATTR_TAGS);

            if (tags != null && !string.IsNullOrWhiteSpace(tags.Value))
            {
                foreach (var tag in tags.Value.Split(XmlConsts.TAG_SEPARATOR_COMMA))
                {
                    Tags.Add(tag);
                }
            }

            // Parse Tags
            IsMalak   = Tags.Contains(XmlConsts.TAG_MALAK);
            IsPazaak  = Tags.Contains(XmlConsts.TAG_PAZAAK);
            IsStart   = Tags.Contains(XmlConsts.TAG_START);
            IsStarMap = Tags.Contains(XmlConsts.TAG_STAR_MAP);

            IsBastila   = Tags.Contains(XmlConsts.TAG_BASTILA);
            IsCanderous = Tags.Contains(XmlConsts.TAG_CANDEROUS);
            IsCarth     = Tags.Contains(XmlConsts.TAG_CARTH);
            IsHK47      = Tags.Contains(XmlConsts.TAG_HK47);
            IsJolee     = Tags.Contains(XmlConsts.TAG_JOLEE);
            IsJuhani    = Tags.Contains(XmlConsts.TAG_JUHANI);
            IsMission   = Tags.Contains(XmlConsts.TAG_MISSION);
            IsT3M4      = Tags.Contains(XmlConsts.TAG_T3M4);
            IsZaalbar   = Tags.Contains(XmlConsts.TAG_ZAALBAR);

            // Get LockedTag
            LockedTag = element.Attribute(XmlConsts.ATTR_LOCKED_TAG)?.Value; // Null if it doesn't exist.

            // Get list of Unlocks
            var unlocks = element.Attribute(XmlConsts.ATTR_UNLOCK);

            if (unlocks != null && !string.IsNullOrWhiteSpace(unlocks.Value))
            {
                foreach (var unlock in unlocks.Value.Split(XmlConsts.TAG_SEPARATOR_COMMA))
                {
                    Unlock.Add(unlock);
                }
            }

            // Get adjacent vertices
            var descendants = element.Descendants(XmlConsts.ELEM_LEADS_TO);

            foreach (var desc in descendants)
            {
                LeadsTo.Add(new ModuleEdge(desc));
            }
        }
Exemple #12
0
 public static bool LeadsToWord(string prefix)
 {
     return(LeadsTo.Contains(prefix));
 }