Package stanfordlogic.gdl

Examples of stanfordlogic.gdl.GdlAtom


    {
        // Informations are the game description
        GdlList content = GameManager.getParser().parse(informations);
        content = (GdlList) content.getElement(0);
       
        GdlAtom roleAtom = (GdlAtom) content.getElement(2);
        TermObject role_term = (TermObject) TermObject.buildFromGdl(roleAtom);
        my_role = role_term.toString();
       
        GdlList game_description = (GdlList) content.getElement(3);
        GameInformation gameInfo = new MetaGdl(GameManager.getParser()).examineGdl(game_description);
View Full Code Here


            for ( GdlExpression exp : gameDesc )
            {
                if ( exp instanceof GdlList )
                {
                    GdlList l = (GdlList) exp;
                    if ( l.getElement(0).equals( new GdlAtom(parser_.getSymbolTable(), parser_.TOK_ROLE) ) )
                    {
                        GdlAtom roleAtom = (GdlAtom) l.getElement(1);
                        role = roleAtom.toString();
                        break;
                    }
                }
            }
        }
View Full Code Here

        symbolTable_ = parser_.getSymbolTable();
    }

    private GdlAtom atom(String name)
    {
        return new GdlAtom(symbolTable_, symbolTable_.get(name));
    }
View Full Code Here

   
    private void examineTopLevelList(GdlList list)
    {
        // Is this a rule, or a relation?
        // Note that it is safe to assume that the head is in fact an atom.
        GdlAtom head = (GdlAtom) list.getElement(0);
       
        if ( head.getToken() == parser_.TOK_IMPLIEDBY )
        {
            Implication impl = examineRule(list);
            expressions_.add(impl);
            addRule(impl.getConsequent().getRelationName(), impl);
        }
        else
        {
            // It must be a ground fact at this point: it can't have variables,
            // since there is no rule to specify binding.
            GroundFact f = (GroundFact) examineListRelation(list, head.getToken() );
            addGround(head.getToken(), f);
            expressions_.add(f);
           
            // Is this a role?
            if ( head.getToken() == parser_.TOK_ROLE )
                roles_.add( (TermObject) f.getTerm(0));
        }
    }
View Full Code Here

   
    private void examineListTerm(GdlList list)
    {
        // The first element here must be a function symbol.
        // Note that it is safe to assume that the head is in fact an atom.
        GdlAtom head = (GdlAtom) list.getElement(0);
       
        int token = head.getToken();
       
        // Make sure that 'token' is a function symbol.
        if ( isObjectSymbol( token ) || isRelationSymbol( token ) )
            throw new IllegalArgumentException( "Symbol '" + token + "' ("
                    + parser_.getSymbolTable().get(token)
View Full Code Here

    }
   
    @Override
    public String env_init()
    {
        GdlAtom roleAtom = (GdlAtom) start_content.getElement(2);
        role = (TermObject) TermObject.buildFromGdl(roleAtom);
        GdlList game_description = (GdlList) start_content.getElement(3);
        GameInformation gameInfo = new MetaGdl(GameManager.getParser()).examineGdl(game_description);
        roles = gameInfo.getRoles();
        reasoner = new GameReasoner(gameInfo);
View Full Code Here

        // the first element of the list should be an atom, telling us the command
        if ( ( list.getElement(0) instanceof GdlAtom ) == false )
        {
            throw new IllegalArgumentException("First element of message received in list is not an atom! Got: " + list.getElement(0) );
        }
        GdlAtom command = (GdlAtom) list.getElement(0);
       
        String matchId = list.getElement(1).toString();
        System.out.println(matchId);
       
        RequestHandler result = null;
       
        if ( command.equals("start") )
        {
            result = new StartRequestHandler(socket, header, list, matchId);
        }
        else if ( command.equals("play") )
        {
            result = new PlayRequestHandler(socket, header, list, matchId);
        }
        else if ( command.equals("stop") )
        {
            result = new StopRequestHandler(socket, header, list, matchId);
        }
        else if ( command.equals("kill") )
        {
            // FIXME: make this more secure!!!
            result = new KillRequestHandler(socket, header, list, matchId);
        }
        else
View Full Code Here

                }
            }
           
            logger_.severe(gameId_ + ": " + sb.toString());
           
            GdlAtom nil = new GdlAtom(GameManager.getSymbolTable(), GameManager.getParser().TOK_NIL);
            next = new Triple<GdlExpression, String, String>(nil, "exception", "oh crap");
           
            throw new RuntimeException(e);
        }
       
View Full Code Here

        {
            throw new IllegalArgumentException( "START request should have exactly six arguments, not "
                    + content_.getSize() );
        }
       
        GdlAtom role = (GdlAtom) content_.getElement(2);
        GdlList description = (GdlList) content_.getElement(3);
       
        int start = Integer.parseInt( content_.getElement(4).toString() );
        int play = Integer.parseInt( content_.getElement(5).toString() );
        //crea juego
View Full Code Here

       
        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, "", "");
        }
        else {
            // the top-level element returned is list of all elements in the parse;
            // in this case, we have just one, the move.
View Full Code Here

TOP

Related Classes of stanfordlogic.gdl.GdlAtom

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.