Package fr.irit.halterego.ggp_agent.cmd

Source Code of fr.irit.halterego.ggp_agent.cmd.Explore

package fr.irit.halterego.ggp_agent.cmd;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import stanfordlogic.knowledge.GameInformation;
import stanfordlogic.prover.TermObject;
import stanfordlogic.util.CommandLineParser;
import fr.irit.halterego.ggp_agent.AgentProperties;
import fr.irit.halterego.rrl_ggp.base.RRLAlgorithm;
import fr.irit.halterego.rrl_ggp.base.RRLAlgorithm.Agent;
import fr.irit.halterego.rrl_ggp.base.RState;
import fr.irit.halterego.rrl_ggp.impl.GDLAlgorithmAgent;
import fr.irit.halterego.rrl_ggp.impl.GDLState;
import fr.irit.halterego.rrl_ggp.impl.GameReasoner;

public class Explore
{  
    public static void main(String[] args)
    {  
        try
        {
            CommandLineParser clp = new CommandLineParser();
            clp.addParam("--gamedef");
            clp.addParam("--config");
            clp.addParam("--iterations");
            clp.parse(args);
           
            String config_path = clp.getArgAsString("--config");
            String path_to_gdl = clp.getArgAsString("--gamedef");
            int iterations = Integer.parseInt(clp.getArgAsString("--iterations"));
        
            if(config_path == null)
            {
                config_path = "config.properties";
            }
           
            Properties p = new Properties(System.getProperties());
            p.load(new FileInputStream(new File(config_path)));
            System.setProperties(p);
           
            RRLAlgorithm algorithm = (RRLAlgorithm)AgentProperties.getAlgorithmClass().newInstance();
            algorithm.load();
           
            GameInformation game_infos = GameReasoner.createGameInfo(path_to_gdl);
           
            List<Agent> agents = new ArrayList<Agent>();
            for(TermObject t : game_infos.getRoles())
            {
                agents.add(new GDLAlgorithmAgent(t.toString()));
            }
           
            GameReasoner reasoner = new GameReasoner(game_infos);
           
            for(int i = 0; i < iterations; ++i)
            {
                System.out.println("iteration " + i);
                RState state = new GDLState(reasoner);
                algorithm.exploreNewEpisode(state, agents);
            }
               
            algorithm.save();
        }
        catch(Exception e)
        {
            throw new RuntimeException(e);
        }
    }
}
TOP

Related Classes of fr.irit.halterego.ggp_agent.cmd.Explore

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.