Package stanfordlogic.prover

Examples of stanfordlogic.prover.AbstractReasoner


        GameInformation gameInfo = new MetaGdl(parser).examineGdl(description);
       
        KnowledgeBase staticKb = new BasicKB();
        staticKb.loadWithFacts(gameInfo.getAllGrounds());
       
        AbstractReasoner reasoner = new BasicReasoner(staticKb, gameInfo.getIndexedRules(), parser);
       
        TermObject myRole = (TermObject) TermObject.buildFromGdl(role);
       
        gamer.initializeGame(myRole, playClock, gameInfo, reasoner);
       
View Full Code Here


        GameInformation gameInfo = new MetaGdl(parser).examineGdl(description);
       
        KnowledgeBase staticKb = new BasicKB();
        staticKb.loadWithFacts(gameInfo.getAllGrounds());
       
        AbstractReasoner reasoner = new BasicReasoner(staticKb, gameInfo.getIndexedRules(), parser);
       
        TermObject myRole = (TermObject) TermObject.buildFromGdl(role);
       
        gamer.initializeGame(myRole, playClock, gameInfo, reasoner);
       
View Full Code Here

       
        ArrayList<Implication> rules = new ArrayList<Implication>();
        rules.add(rule);
        rules.add(rule2);
       
        AbstractReasoner r = new BasicReasoner(kb_, rules, parser_ );
        
        // Make sure we can prove all of our ground facts!
        List<GroundFact> answers = getAllAnswers( r, VariableFact.fromList(parser_.parse("gt ?y")) );
       
        assertEquals( 3, answers.size() );
View Full Code Here

    }
   
    public void testTicTacToeTerminal() throws IOException
    {
        List<Implication> rules = getTicTacToeRules();
        AbstractReasoner r = new BasicReasoner(kb_, rules, parser_);
       
        GdlList facts = parser_.parse("(true (cell 1 1 b))(true (cell 1 2 b))(true (cell 1 3 b))(true (cell 2 1 b))(true (cell 2 2 b))(true (cell 2 3 b))(true (cell 3 1 b))(true (cell 3 2 b))(true (cell 3 3 b))(true (control xplayer))");
        addFacts(facts);
       
        Fact f = getAnAnswer( r, Fact.fromExpression( parser_.parse("terminal") ) );
View Full Code Here

        GameInformation info = MetaGdl.examineGame("game-defs/tictactoe.kif", parser_);
        List<Implication> rules = info.getRules();
       
        assertEquals(26, rules.size());
       
        AbstractReasoner r = new BasicReasoner(kb_, rules, parser_);
       
        GdlList facts = parser_.parse( "(true (cell 1 1 x)) (true (cell 1 2 x)) (true (cell 1 3 o)) (true (cell 2 1 x)) (true (cell 2 2 o)) (true (cell 2 3 b)) (true (cell 3 1 o)) (true (cell 3 2 b)) (true (cell 3 3 b)) (true (control xplayer))" );
        addFacts(facts);
       
        List<GroundFact> results = getAllAnswers( r, Fact.fromExpression( parser_.parse("legal xplayer ?x") ) );
View Full Code Here

   
    public void testMoreTicTacToe() throws IOException
    {
        GameInformation info = MetaGdl.examineGame("game-defs/tictactoe.kif", parser_);
        List<Implication> rules = info.getRules();
        AbstractReasoner r = new BasicReasoner(kb_, rules, parser_);
       
        GdlList facts = parser_.parse("(true (cell 1 1 x))(true (cell 1 2 o))(true (cell 1 3 x))(true (cell 2 1 o))(true (cell 2 2 x))(true (cell 2 3 b))(true (cell 3 1 b))(true (cell 3 2 b))(true (cell 3 3 b))(true (control oplayer))");
        addFacts(facts);
       
        // Get all next facts
        GroundFact does = GroundFact.fromExpression( parser_.parse("does xplayer noop") );
        GroundFact does2 = GroundFact.fromExpression( parser_.parse("does oplayer (mark 2 3)") );
        Fact question = VariableFact.fromExpression( parser_.parse("next ?x") );
       
        KnowledgeBase kb = new BasicKB();
       
        kb.setTrue(does);
        kb.setTrue(does2);
       
        ProofContext context = new ProofContext(kb, parser_);
       
        List<GroundFact> results = r.getAllAnswers( question, context );
       
        assertEquals(10, results.size());
    }
View Full Code Here

        GameInformation info = MetaGdl.examineGame("game-defs/tictactoe.kif", parser_);
       
        KnowledgeBase staticKb = new BasicKB();
        staticKb.loadWithFacts(info.getAllGrounds());
       
        AbstractReasoner r = new BasicReasoner(staticKb, info.getIndexedRules(), parser_);
       
       
        Fact initQuestion = Fact.fromExpression(parser_.parse("init ?x"));
       
        // Compute the initial state
        List<GroundFact> inits = r.getAllAnswers(initQuestion);
       
        KnowledgeBase currentState = new BasicKB();
       
        RelationNameProcessor trueProcessor = new RelationNameProcessor(parser_.TOK_TRUE);
        for (GroundFact init: inits) {
View Full Code Here

       
        List<Implication> rules = info.getRules();
       
        KnowledgeBase volatileKb = new BasicKB();
       
        AbstractReasoner reasoner = new BasicReasoner(staticKb, rules, parser_);
       
        Fact question = VariableFact.fromList( parser_.parse("init ?x") );
       
        ProofContext context = new ProofContext(volatileKb, parser_);
       
        List<GroundFact> init = reasoner.getAllAnswers( question, context );
       
        // Make sure that we have a cache for all the initial truths
        assertEquals( 18, init.size() );
       
        RelationNameProcessor processor = new RelationNameProcessor(parser_.TOK_TRUE);
       
        for ( GroundFact f : init )
            volatileKb.setTrue ( processor.processFact(f) );
           
                // Find out how many legal moves there are
        List<GroundFact> legal = reasoner.getAllAnswers( makeFact( "legal white ?x" ),
                context );

        // Make sure there's the right amount of legal moves
        assertEquals( 7, legal.size() );

        // Is the game terminal?
        assertNull( reasoner.getAnAnswer( makeFact( "terminal" ), context ) );

        // Make some move
        GroundFact does1 = (GroundFact) makeFact( "does white (move wk c 1 c 2)" );
        GroundFact does2 = (GroundFact) makeFact( "does black noop" );

        volatileKb.setTrue( does1 );
        volatileKb.setTrue( does2 );

        // Find the next state.
        List<GroundFact> nextTruths = reasoner.getAllAnswers( makeFact( "next ?x" ),
                context );

        assertEquals( 18, nextTruths.size() );
    }
View Full Code Here

       
        List<Implication> rules = info.getRules();
       
        KnowledgeBase volatileKb = new BasicKB();
       
        AbstractReasoner reasoner = new BasicReasoner(staticKb, rules, parser_);
       
        Fact question = VariableFact.fromList( parser_.parse("init ?x") );
       
        ProofContext context = new ProofContext(volatileKb, parser_);
       
        List<GroundFact> init = reasoner.getAllAnswers( question, context );
       
        assertEquals(66, init.size());
       
        RelationNameProcessor processor = new RelationNameProcessor(parser_.TOK_TRUE);
       
        for ( GroundFact f : init )
            volatileKb.setTrue ( processor.processFact(f) );
           
        // Find out how many legal moves there are
        List<GroundFact> legal = reasoner.getAllAnswers( makeFact( "legal white ?x" ),
                context );

        // Make sure there's the right amount of legal moves
        assertEquals( 20, legal.size() );
    }
View Full Code Here

        GameInformation gameInfo = new MetaGdl(parser).examineGdl(description);
       
        KnowledgeBase staticKb = new BasicKB();
        staticKb.loadWithFacts(gameInfo.getAllGrounds());
       
        AbstractReasoner reasoner = new BasicReasoner(staticKb, gameInfo.getIndexedRules(), parser);
       
        TermObject myRole = (TermObject) TermObject.buildFromGdl(role);
       
        gamer.initializeGame(myRole, playClock, gameInfo, reasoner);
       
View Full Code Here

TOP

Related Classes of stanfordlogic.prover.AbstractReasoner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.