Example #1
0
bool ProgramOptions::parseCmdOptions(int argc, char* argv[])
{
	QStringList args;
	for (int i = 1; i < argc; i++)
		args << QString(argv[i]);
	return parseCmdOptions(args);
}
Example #2
0
// FIXME: interceptor will hang on debugger breakpoint,
// thus stopping all mouse and kb interaction. :Z
BlitzleApp::BlitzleApp(int argc, char** argv)
	: opts(parseCmdOptions(argc, argv))
{
	detector = instantiateDetector(opts.detectorType);
	detector->init(argc, argv, opts.withDebug, opts.withControls);
	desktop = new DesktopSource(opts.duplicationAdapter, opts.duplicationOutput, opts.duplicationTimeout);
#ifndef _DEBUG
	interceptor = new Interceptor();
#endif
}
Example #3
0
int main(int argc, char *argv[]) {
	if (argc < 2) {
		std::cerr << "USAGE: ./aixi agent.conf [--option1=value1 --option2=value2 ...] " << std::endl;
		std::cerr << "The first argument should indicate the location of the configuration file. Further arguments can either be specified in the config file or passed as command line option. Command line options are used over options specified in the file." << std::endl;
		return -1;
	}
    // Initialize random seed
    srand(time(NULL));

	// Load configuration options
	options_t options;

	// Default configuration values
	options["ct-depth"] = "16";
	options["agent-horizon"] = "3";
	options["exploration"] = "0";     // do not explore
	options["explore-decay"] = "1.0"; // exploration rate does not decay
    options["mc-timelimit"] = "500"; //number of mc simulations per search
    options["terminate-age"] = "10000";
    options["log"]  = "log";
    options["load-ct"] = "";
    options["write-ct"] = "";
    options["intermediate-ct"] = "1";

	// Read configuration options
	std::ifstream conf(argv[1]);
	if (!conf.is_open()) {
		std::cerr << "ERROR: Could not open file '" << argv[1] << "' now exiting" << std::endl;
		return -1;
	}
	processOptions(conf, options);
	conf.close();

    //parse command line options (overwrites values of config files)
    parseCmdOptions(argc, argv, options);

	// Set up logging
	std::string log_file = options["log"];
	verboseLog.open((log_file + ".log").c_str());
	compactLog.open((log_file + ".csv").c_str());

	// Print header to compactLog
	compactLog << "cycle, observation, reward, action, explored, explore_rate, total reward, average reward" << std::endl;

	// Set up the environment
	Environment *env;
	std::string environment_name = options["environment"];
	if (environment_name == "coin-flip") {
		env = new CoinFlip(options);
		options["agent-actions"] = "2";
		options["observation-bits"] = "1";
		options["reward-bits"] = "1";
	}
	else if (environment_name == "tiger") {
		env = new Tiger(options);
		options["agent-actions"] = "3";
		options["observation-bits"] = "2";
		options["reward-bits"] = "7";
	}
	else if (environment_name == "biased-rock-paper-scissor") {
		env = new BiasedRockPaperScissor(options);
		options["agent-actions"] = "3";
		options["observation-bits"] = "2";
		options["reward-bits"] = "2";
	}
	else if (environment_name == "kuhn-poker") {
		env = new KuhnPoker(options);
		options["agent-actions"] = "2";
		options["observation-bits"] = "4";
		options["reward-bits"] = "3";
	}
	else if (environment_name == "pacman") {
        env = new Pacman(options);
		options["agent-actions"] = "4";
		options["observation-bits"] = "16";
		options["reward-bits"] = "8";
	}
	else {
		std::cerr << "ERROR: unknown environment '" << environment_name << "'" << std::endl;
		return -1;
	}

    printOptions(options);

	// Set up the agent
	Agent ai(options);

	// If specified, load a pretrained context tree.
    if(options["load-ct"] != ""){
        std::ifstream ct(options["load-ct"].c_str());

        if(ct.is_open()){
            ai.loadCT(ct);
        }
        else{
            std::cerr << "WARNING: specified context tree file could not be loaded.\n";
        }
        ct.close();
    }  

	// Run the main agent/environment interaction loop
	mainLoop(ai, *env, options);

	verboseLog.close();
	compactLog.close();

	return 0;
}