Example #1
0
	CConfigData::CConfigData(Global* G){
		_abstract = true;
		gaia = false;
		spacemod = false;
		dynamic_selection = true;
		use_modabstracts = false;
		absent_abstract = false;
		fire_state_commanders = 0;
		move_state_commanders = 0;
		scout_speed = 60;
		rule_extreme_interpolate= true;
		mod_tdf = new TdfParser(G);
		
		//CLOG("Loading AI.tdf with TdfParser");
		TdfParser cs(G);
		cs.LoadFile("AI/AI.tdf");
		
		//CLOG("Retrieving datapath value");

		datapath = cs.SGetValueDef(string(aiexport_getDataDir(true)), "AI/Skirmish/NTai/data");

		CLOG("Getting tdfpath value");
		
		CLOG("Loading modinfo.tdf");
		TdfParser sf(G);
		if(sf.LoadFile("modinfo.tdf")){
			G->L.print("modinfo.tdf loaded into parser");
		} else {
			G->L.eprint("error modinfo.tdf retrieval failed");
		}
		const char* modname = G->cb->GetModName();
		tdfpath =  sf.SGetValueDef(string(modname), "MOD\\NTAI\\tdfpath");
	}
Example #2
0
void BaczekKPAI::InitAI(IGlobalAICallback* callback, int team)
{
	init_rng();

	this->callback=callback;
	cb = callback->GetAICallback();
	cheatcb = callback->GetCheatInterface();

	cheatcb->EnableCheatEvents(true);

	datadir = aiexport_getDataDir(true, "");
	std::string dd(datadir);
	cb->SendTextMsg(AI_NAME, 0);
	cb->SendTextMsg(AI_VERSION, 0);
	cb->SendTextMsg("AI data directory:", 0);
	cb->SendTextMsg(datadir, 0);


	if (!ailog) {
		ailog.reset(new Log(callback));

		std::stringstream ss;
		ss << dd << "/log.txt";

		std::string logname = ss.str();
		ailog->open(logname.c_str());
		ailog->info() << "Logging initialized.\n";
		ailog->info() << "Baczek KP AI compiled on " __TIMESTAMP__ "\n";
		ailog->info() << AI_NAME << " " << AI_VERSION << std::endl;
		ss.clear();
	}


	InitializeUnitDefs();

	std::stringstream ss;
	ss << dd << "status" << team << ".txt";
	std::string logname = ss.str();
	statusName = strdup(logname.c_str());
	map.h = cb->GetMapHeight();
	map.w = cb->GetMapWidth();
	map.squareSize = SQUARE_SIZE;

	float3::maxxpos = map.w * SQUARE_SIZE;
	float3::maxzpos = map.h * SQUARE_SIZE;
	ailog->info() << "Map size: " << float3::maxxpos << "x" << float3::maxzpos << std::endl;

	FindGeovents();

	std::string influence_conf = dd+"influence.json";
	if (!fs::is_regular_file(fs::path(influence_conf))) {
		InfluenceMap::WriteDefaultJSONConfig(influence_conf);
	}
	influence = new InfluenceMap(this, influence_conf);

	PythonScripting::RegisterAI(team, this);
	python = new PythonScripting(team, datadir);

	debugLines = python->GetIntValue("debugDrawLines", false);
	debugMsgs = python->GetIntValue("debugMessages", false);

	toplevel = new TopLevelAI(this);

	assert(randfloat() != randfloat() || randfloat() != randfloat());
	
#ifdef USE_STATUS_WINDOW
	int argc = 1;
	static  char *argv[] = {"SkirmishAI.dll"};

	wxEntry(argc, argv);

	    // Create the main application window
    frame = new MyFrame(_T("Drawing sample"),
                                 wxPoint(50, 50), wxSize(550, 340));

    // Show it and tell the application that it's our main window
    frame->Show(true);
#endif
}