Example #1
0
void BenchMark(Agent *agent, int otherturn, int gameCtr) {
	string filename = ( otherturn == -1 ? "agent1_stats.dat" : "agent2_stats.dat"); 
	ofstream myFile;
	myFile.open( filename.c_str(), ios::out | ios::app );
	Game *game = new Game();
	Agent *opponent = new Agent(game, otherturn);
	Game *hold = agent->ChangeGame(game);
	agent->ToggleDebug();
	int tie = 0, p1win = 0, p2win = 0;
	for(int i = 0; i < 100; i++) {
		game->Reset();
		while(game->Status()) {
			int move;
			if(game->curr_player == agent->Turn()) {
				move = agent->Move();
			} else {
				move = opponent->Move();
			}
			game->Move(move);
		}
		if(game->Reward() == 1) p1win++;
		else if (game->Reward() == -1) p2win++;
		else tie++;		
	}
	myFile<<gameCtr<<" "<<p1win<<" "<<p2win<<" "<<tie<<endl;
	myFile.close();
	agent->ChangeGame(hold);
	agent->ToggleDebug();
}
Example #2
0
void TestPathEngine()
{
	NavMesh* mesh = new NavMesh();
	mesh->LoadMesh("nav_test.obj");
	mesh->BuildMesh();
	mesh->InitCrowd();
	float* p = new float[3];
	p[0] = 100.0f;
	p[1] = 0.0f;
	p[2] = 100.0f;
	int id = mesh->AddAgent(p);
	Agent* agent = new Agent(mesh,id);
	float* dest = new float[3];
	dest[0] = 10.0f;
	dest[1] = 0.0f;
	dest[2] = 10.0f;
	agent->Move(dest);
	for(int i=0;i<100;i++)
	{
		mesh->UpdateCrowd(0.03);
		agent->SyncPosition();
	}
}