Example #1
0
        public void TypicallyAfterTest()
        {
            var queryText = @"typically not FrodoLives after Bilbo TakeSword, Bilbo AttackFrodo from BilboLives and FrodoLives and not FrodoHasSword";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially FrodoLives and BilboLives and not FrodoHasSword and not BilboHasSword
                        when Frodo TakeSword causes FrodoHasSword if not BilboHasSword
                        when Bilbo TakeSword causes BilboHasSword if not FrodoHasSword
                        impossible Frodo AttackFrodo
                        impossible Frodo TakeSword if not FrodoLives
                        impossible Bilbo AttackBilbo
                        impossible Bilbo TakeSword if not BilboLives
                        AttackFrodo typically causes not FrodoLives if BilboHasSword
                        AttackBilbo causes not BilboLives if FrodoHasSword";

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, null);

            if (query is AfterQueryStatement afterQuery)
            {
                var queryResult = afterQuery.Execute(graph, history);
                Assert.AreEqual(true, queryResult);
            }
        }
        public void NecessaryExecutableTest2()
        {
            var queryText = @"necessary executable Frodo AttackBilbo, Bilbo AttackFrodo";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially FrodoLives and BilboLives and not FrodoHasSword and not BilboHasSword
                        when Frodo TakeSword causes FrodoHasSword if not BilboHasSword
                        when Bilbo TakeSword causes BilboHasSword if not FrodoHasSword
                        impossible Frodo AttackFrodo
                        impossible Frodo TakeSword if not FrodoLives
                        impossible Bilbo AttackBilbo
                        impossible Bilbo TakeSword if not BilboLives
						impossible AttackFrodo if not BilboLives
						impossible AttackBilbo if not FrodoLives
                        AttackFrodo typically causes not FrodoLives if BilboHasSword
                        AttackBilbo causes not BilboLives if FrodoHasSword
						observable not BilboLives after Frodo AttackBilbo"                        ;

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, query);

            if (query is ExecutableQueryStatement executableQuery)
            {
                var queryResult = executableQuery.Execute(graph, history);
                Assert.AreEqual(false, queryResult);
            }
        }
Example #3
0
        public void NecessaryAccessibleTest6()
        {
            var queryText = @"necessary accessible not FrodoLives from FrodoHasSword";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially FrodoLives and BilboLives and FrodoHasSword
                        when Frodo TakeSword causes FrodoHasSword
                        when Bilbo TakeSword causes true
                        when Bilbo TakeSword causes BilboHasSword if not FrodoHasSword
                        not FrodoHasSword  after Bilbo TakeSword
                        impossible Frodo AttackFrodo
                        impossible Frodo TakeSword if not FrodoLives
                        impossible Bilbo AttackBilbo
                        impossible Bilbo TakeSword if not BilboLives
                        AttackFrodo causes not FrodoLives if BilboHasSword
                        AttackBilbo causes not BilboLives if FrodoHasSword";

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, null);

            if (query is AccessibleQueryStatement accessibleQuery)
            {
                var queryResult = accessibleQuery.Execute(graph, history);
                Assert.AreEqual(true, queryResult);
            }
        }
Example #4
0
        public void AgentIsInQueryTest()
        {
            var queryText = this.query;
            var query     = Parsing.GetQuery(queryText);

            var text = this.text;

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, query);

            if (query is AgentInQueryStatement accessibleQuery)
            {
                var executor    = new AgentInQueryExecutor();
                var queryResult = executor.Execute(query, graph, history);
                queryResult.Should().Be(answer, queryText + Environment.NewLine + text);
            }
        }
Example #5
0
        public void RealseseTest1()
        {
            var queryText = @"possibly accessible not loaded from loaded";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially loaded
                shoot releases loaded";

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, null);

            if (query is AccessibleQueryStatement accessibleQuery)
            {
                var queryResult = accessibleQuery.Execute(graph, history);
                Assert.AreEqual(true, queryResult);
            }
        }
        public void NecessaryExecutableTest11()
        {
            var queryText = @"necessary executable rel, test";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially not loaded
						 loaded after rel
						 impossible test if not loaded"                        ;

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, query);

            if (query is ExecutableQueryStatement executableQuery)
            {
                var queryResult = executableQuery.Execute(graph, history);
                Assert.AreEqual(true, queryResult);
            }
        }
        public void ReleasesTest()
        {
            var queryText = @"possibly executable rel, test";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially not loaded
                rel releases loaded
                impossible test if not loaded";

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, query);

            if (query is ExecutableQueryStatement executableQuery)
            {
                var queryResult = executableQuery.Execute(graph, history);
                Assert.AreEqual(true, queryResult);
            }
        }
Example #8
0
        public void NecessaryAccessibleTestIssue27()
        {
            var queryText = @"necessary accessible open from hasCard";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially not open
                        insertCard typically causes open
                        impossible insertCard if not hasCard";

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, null);

            if (query is AccessibleQueryStatement accessibleQuery)
            {
                var queryResult = accessibleQuery.Execute(graph, history);
                Assert.AreEqual(false, queryResult);
            }
        }
        public void NecessaryExecutableTest13()
        {
            var queryText = @"necessary executable load, shoot, shoot";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially alive and not loaded
						 impossible shoot if not loaded
						 loaded after load
						 observable not loaded after load, shoot"                        ;

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, query);

            if (query is ExecutableQueryStatement executableQuery)
            {
                var queryResult = executableQuery.Execute(graph, history);
                Assert.AreEqual(false, queryResult);
            }
        }
        public void PossiblyExecutableTest11()
        {
            var queryText = @"possibly executable load, shoot, shoot";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially alive and not loaded
						 load causes loaded
						 impossible shoot if not loaded
						 not loaded after shoot"                        ;

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, query);

            if (query is ExecutableQueryStatement executableQuery)
            {
                var queryResult = executableQuery.Execute(graph, history);
                Assert.AreEqual(true, queryResult);
            }
        }
        public void NecessaryExecutableTest6()
        {
            var queryText = @"necessary executable John load, John shoot, shoot";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially alive and not loaded
						 load causes loaded
						 impossible shoot if not loaded
						 impossible Bob shoot
					     shoot typically causes not loaded and not alive"                    ;

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, query);

            if (query is ExecutableQueryStatement executableQuery)
            {
                var queryResult = executableQuery.Execute(graph, history);
                Assert.AreEqual(false, queryResult);
            }
        }
        public void NecessaryExecutableTest12()
        {
            var queryText = @"necessary executable load, John shoot, shoot";
            var query     = Parsing.GetQuery(queryText);

            var text = @"initially alive and not loaded
						 when Bob load causes loaded
						 impossible shoot if not loaded
						 impossible Eric shoot
						 not loaded after Bob shoot
						 when John shoot releases loaded"                        ;

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, query);

            if (query is ExecutableQueryStatement executableQuery)
            {
                var queryResult = executableQuery.Execute(graph, history);
                Assert.AreEqual(false, queryResult);
            }
        }
Example #13
0
        public void NecessaryAfterLight()
        {
            var queryText = @"necessary light after toggle2, toggle1 from not light";
            var query     = Parsing.GetQuery(queryText);

            var text = @"noninertial light
                        initially not light
                        always light iff (switch1 iff switch2)
                        toggle1 causes switch1 if not switch1
                        toggle1 causes not switch1 if switch1
                        toggle2 causes switch2 if not switch2
                        toggle2 causes not switch2 if switch2
                        impossible toggle1 if light";

            var history = Parsing.GetHistory(text);
            var story   = new Story(history);
            var graph   = Graph.Graph.CreateGraph(story, null);

            if (query is AfterQueryStatement afterQuery)
            {
                var queryResult = afterQuery.Execute(graph, history);
                Assert.AreEqual(true, queryResult);
            }
        }