Examples of GdlList


Examples of stanfordlogic.gdl.GdlList

        assertEquals(2, sigma.numMappings());
    }
   
    public void testFunctionMgu()
    {
        GdlList l1, l2;
        Fact f1, f2;
        Substitution sigma;
       
        l1 = parser_.parse("foo (f a b)");
        l2 = parser_.parse("foo ?x");
View Full Code Here

Examples of stanfordlogic.gdl.GdlList

  {
    String str = "(true (control xplayer)) (true (cell 2 2 b)) (role xplayer)" +
        "(<= (next (control ?x)) (control ?y) (distinct ?x ?y))";
    ByteArrayInputStream in = new ByteArrayInputStream( str.getBytes() );
   
    GdlList gdl = parser_.parse( in );
       
        assertEquals(4, gdl.getSize());
       
        for ( GdlExpression elem : gdl )
            assertEquals(GdlList.class, elem.getClass());
       
        GdlList elem1 = (GdlList) gdl.getElement(0);
        GdlList elem2 = (GdlList) gdl.getElement(1);
        GdlList elem3 = (GdlList) gdl.getElement(2);
        GdlList elem4 = (GdlList) gdl.getElement(3);
       
        assertEquals(2, elem1.getSize());
        assertEquals(2, elem2.getSize());
        assertEquals(2, elem3.getSize());
        assertEquals(4, elem4.getSize());
       
        GdlList l;
       
        assertEquals( atom( "true" ), elem1.getElement( 0 ) );
        l = new GdlList( symbolTable_, new GdlExpression [] { atom( "control" ),
                atom( "xplayer" ) } );
        assertEquals( l, elem1.getElement( 1 ) );

        assertEquals( atom( "true" ), elem2.getElement( 0 ) );
        l = new GdlList( symbolTable_, new GdlExpression [] { atom( "cell" ),
                atom( "2" ), atom( "2" ), atom( "b" ) } );
        assertEquals( l, elem2.getElement( 1 ) );

        assertEquals( atom( "role" ), elem3.getElement( 0 ) );
        assertEquals( atom( "xplayer" ), elem3.getElement( 1 ) );

        assertEquals( atom( "<=" ), elem4.getElement( 0 ) );
        l = new GdlList( symbolTable_, new GdlExpression [] {
                atom( "next" ),
                new GdlList( symbolTable_, new GdlExpression [] { atom( "control" ),
                        var( "x" ) } ) } );
        assertEquals( l, elem4.getElement( 1 ) );
        l = new GdlList( symbolTable_, new GdlExpression [] { atom( "control" ),
                var( "y" ) } );
        assertEquals( l, elem4.getElement( 2 ) );
        l = new GdlList( symbolTable_, new GdlExpression [] { atom( "distinct" ),
                var( "x" ), var( "y" ) } );
        assertEquals( l, elem4.getElement( 3 ) );   
  }
View Full Code Here

Examples of stanfordlogic.gdl.GdlList

    trueProcessor=new RelationNameProcessor(parser.TOK_TRUE);
  }
 
    protected Fact makeQuery(String ... args)
    {
        GdlList list = GdlList.buildFromWords(parser.getSymbolTable(), args);
        return VariableFact.fromList(list);
    }
View Full Code Here

Examples of stanfordlogic.gdl.GdlList

   
    public static GameInformation createGameInfo(String filename) throws IOException
    {
        Game<Term, GameState> game = new Game<Term, GameState>(new File(filename), new ReasonerFactory(), GDLVersion.v1);
        String game_desc = "("+game.getKIFGameDescription()+")";
        GdlList list = (GdlList)GameManager.getParser().parse(game_desc).getElement(0);
        return new MetaGdl(GameManager.getParser()).examineGdl(list);
    }
View Full Code Here

Examples of stanfordlogic.gdl.GdlList

    public void readExternal(ObjectInput in) throws IOException,
            ClassNotFoundException
    {
        String str = in.readUTF();
        //System.out.println(str);
        GdlList list = GameManager.getParser().parse(str);
        list = (GdlList) list.getElement(0);
        fact = GroundFact.fromList(list);
    }
View Full Code Here

Examples of stanfordlogic.gdl.GdlList

    {
        this.reasoner = reasoner;
       
        try
        {
            GdlList list = GameManager.getParser().parse(observation);
          
            for(GdlExpression atom : list)
            {
                GroundFact fact = GroundFact.fromExpression(atom);
                facts.add(fact);
View Full Code Here

Examples of stanfordlogic.gdl.GdlList

        StringBuilder string = new StringBuilder("(true ");
        parseArgs(element,string);
        string.append(")");
       
        // Create and return the GroundFact
        GdlList list = GameManager.getParser().parse(string.toString());
        list = (GdlList) list.getElement(0);
        return GroundFact.fromList(list);
    }
View Full Code Here

Examples of stanfordlogic.gdl.GdlList

        throw new RuntimeException("Player not found in xml file : " + player_name);
    }
   
    private GroundFact createAction(String action_term, String role)
    {
        GdlList list = GameManager.getParser().parse("(does " + role + " " +action_term + ")");
        list = (GdlList) list.getElement(0);
        return GroundFact.fromList(list);
    }
View Full Code Here

Examples of stanfordlogic.gdl.GdlList

    {
        if ( relation instanceof GdlAtom )
            return examineAtomRelation( (GdlAtom) relation );
       
        // else, must be a variable
        GdlList list = (GdlList) relation;
        return examineListRelation( (GdlList) relation, ((GdlAtom) list.getElement(0)).getToken() );
    }
View Full Code Here

Examples of stanfordlogic.gdl.GdlList

   
    public static GameInformation examineGame(String filename, Parser p)
    {
        try
        {
            GdlList axioms = p.parse( new FileInputStream( filename ) );
            MetaGdl meta = new MetaGdl( p );
            GameInformation info = meta.examineGdl( axioms );
            return info;
        }
        catch ( IOException e )
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.