Package stanfordlogic.prover

Examples of stanfordlogic.prover.GroundFact


        {
            GdlList list = GameManager.getParser().parse(observation);
          
            for(GdlExpression atom : list)
            {
                GroundFact fact = GroundFact.fromExpression(atom);
                facts.add(fact);
            }
           
        }
        catch(Exception e)
View Full Code Here


    }

    @Override
    public boolean isTerminal()
    {
        GroundFact fact = reasoner.getAnAnswer(getContext(),"terminal");
        boolean terminal = fact != null;
        return terminal;
    }
View Full Code Here

        return terminal;
    }
    public double getReward(String role)
    {
        GroundFact goal = reasoner.getAnAnswer(getContext(),"goal", role, "?x");
        if(goal == null)
        {
            return 0;
        }
        else
        {
            TermObject score = (TermObject) goal.getTerm(1);
            // 0   loose
            // 50  draw match
            // 100 win
            return Integer.parseInt(score.toString());
        }
View Full Code Here

{
    private GroundFact fact;
   
    public GDLAction(GroundFact fact)
    {
        this.fact = new GroundFact(GameManager.getParser().TOK_DOES,fact.getTerm(0),fact.getTerm(1));
    }
View Full Code Here

                for(Element e : root.getChild("history").getChildren("step"))
                {
                    String s = e.getChildren("step-number").get(0).getText();
                    int stepnum = Integer.parseInt(s);
                    String action_term = e.getChildren("move").get(player_id).getText();
                    GroundFact fact = createAction(action_term,role);
                    actions.put(stepnum, new SerializableAction(fact));
                }
            }
           
            // Register the state-action couples by browsing the step_x.xml
View Full Code Here

                sb.append(" ");
            }
            logger_.fine(sb.toString());
        }
       
        GroundFact move;

        move = moves.get(random_.nextInt(moves.size()));

        // term 0 is the player, term 1 is the actual move
        Term action = move.getTerm(1);

        return new Triple<Term, String, String>(action, "I'm a silly random player",
                                                "I hope you can beat me");
    }
View Full Code Here

        }
        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

    
    @Override
    public Reward_observation_terminal env_step(Action action)
    {
        // Translate the action to a GroundFact
        GroundFact fact = parseAction(action);
        applyAction(fact);
        Reward_observation_terminal ret = new Reward_observation_terminal();
        ret.setObservation(createObservation(state));
        ret.setReward(state.getReward(role.toString()));
        ret.setTerminal(state.isTerminal());
View Full Code Here

       
        // Translate them in does facts
        List<RAction> actions = new ArrayList<RAction>();
        for(int i = 0; i < moves.size(); ++i)
        {
            GroundFact fact = new GroundFact(GameManager.getParser().TOK_DOES,roles.get(i),moves.get(i));
            actions.add(new GDLAction(fact));
        }
       
        // Compute the next state
        state = (GDLState)state.next(actions);
View Full Code Here

                                              int currentDepth) throws TimeoutException
    {
        newLevel(currentDepth, state);
       
        // is this a terminal node?
        GroundFact isTerminal = reasoner_.getAnAnswer(QUERY_TERMINAL, context);
       
        if (isTerminal != null) {
            return calculateTerminal(context, currentDepth);
        }
       
View Full Code Here

TOP

Related Classes of stanfordlogic.prover.GroundFact

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.