Package stanfordlogic.gdl

Examples of stanfordlogic.gdl.GdlExpression


    this.parser=parser;
  }
 
  public Term getTermFromKIF(String kif) throws InvalidKIFException {
    try{
      GdlExpression gdlExpr=parser.parse(kif).getElement(0);
      return new Term(parser.getSymbolTable(), stanfordlogic.prover.Term.buildFromGdl(gdlExpr));
    }catch(Exception ex){
      throw new InvalidKIFException("Exception while parsing \""+kif+"\":"+ex);
    }
  }
View Full Code Here


        assertEquals(5, makeTerm("(f (g ?x) (h ?y))").getTotalColumns());
    }
   
    private Term makeTerm(String str)
    {
        GdlExpression exp = parser_.parse(str).getElement(0);
       
        if ( exp instanceof GdlVariable )
            return TermVariable.makeTermVariable();
        else
            return Term.buildFromGdl(exp);
View Full Code Here

   
    private GroundFact parseAction(Action action)
    {
        String actionString = new String(action.charArray);
       
        GdlExpression content = GameManager.getParser().parse(actionString);
        content = ((GdlList)content).getElement(0);
        return GroundFact.fromExpression(content);
    }
View Full Code Here

            // Convert each term
            Term [] terms = new Term [list.getArity()];
           
            for ( int i = 0; i < list.getArity(); i++ )
            {
                GdlExpression elem = list.getElement(i+1);
               
                if ( elem instanceof GdlVariable == false)
                    terms[i] = Term.buildFromGdl(elem, varMap);
                else
                {
View Full Code Here

     */
    @Override
    protected void execute() throws IOException
    {
        // Tell the game manager that the game ended, passing in the previous moves
        GdlExpression prevMoves = content_.getElement(2);
       
        if (prevMoves instanceof GdlList == false) {
            logger_.severe(gameId_ + ": Previous move list in STOP message was not a GDL list!");
            finish();
            return;
View Full Code Here

        {
            throw new IllegalArgumentException( "PLAY request should have exactly three arguments, not "
                    + content_.getSize() );
        }
       
        GdlExpression prevExp = content_.getElement(2);
        GdlList prevMoves;
       
        StringBuilder prevMovesStr = new StringBuilder();
       
        if ( prevExp instanceof GdlList )
        {
            prevMoves = (GdlList) content_.getElement(2);
           
            prevMovesStr.append(" Previous moves: ");
           
            for ( GdlExpression exp: prevMoves )
            {
                prevMovesStr.append( exp.toString() );
                prevMovesStr.append("  ");
            }
        }
        else
        {
            // make sure it's an atom containing NIL
            if ( prevExp instanceof GdlAtom == false || prevExp.equals( GameManager.getParser().TOK_NIL ) == false )
                throw new IllegalArgumentException("PLAY request doesn't have LIST and doesn't have NIL atom as prev-moves!");
            prevMoves = null; // empty prev moves
        }
       
        Gamer game = GameManager.getGame(gameId_);
View Full Code Here

        // Now parse the content, only reading as much as contentLength
        InputStream contentInput;

        contentInput = new LengthInputStream(input, header.contentLength_);

        GdlExpression content = GameManager.getParser().parse(contentInput);

        RequestHandler handler;

        // Find out what kind of message it was, and create the appropriate
        // RequestHandler subclass
        if ( content instanceof GdlList )
            handler = createFromList(socket, header, (GdlList) content);
        else
        {
            throw new IllegalArgumentException("Can't handle gdl expression of type "
                                               + content.getClass().getName()
                                               + " during request handling");
        }

        handler.setManager(manager);
        return handler;
View Full Code Here

       
        Triple<Term, String, String> move = moveThink();
       
        // Convert the Term to a GdlExpression
       
        GdlExpression moveGdl;
       
        if (move == null || move.first == null) {
            logger_.severe(gameId_ + ": move returned by moveThink was null");
            moveGdl = new GdlAtom(symbolTable_, parser_.TOK_NIL);
            move = new Triple<Term, String, String>(null, "", "");
View Full Code Here

       
        Map<GdlVariable, TermVariable> varMap = new HashMap<GdlVariable, TermVariable>();
       
        for ( int i = 0; i < list.getArity(); i++ )
        {
            GdlExpression exp = list.getElement(i+1);
           
            if ( (exp instanceof GdlVariable) == false )
            {
                terms[i] = Term.buildFromGdl( exp, varMap );
               
View Full Code Here

       
        Map<GdlVariable, TermVariable> varMap = new HashMap<GdlVariable, TermVariable>();
       
        for ( int i = 0; i < list.getArity(); i++ )
        {
            GdlExpression exp = list.getElement(i+1);
           
            if ( (exp instanceof GdlVariable) == false )
                terms[i] = Term.buildFromGdl( exp, varMap );
            else
            {
View Full Code Here

TOP

Related Classes of stanfordlogic.gdl.GdlExpression

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.