예제 #1
0
int main(int argc, char *argv[])
{
	const char *pcHost;
	int nPort;

	if(argc < 2)
	{
		pcHost = kDefaultServerName;
	}
	else
	{
		pcHost = argv[1];
	}
    if(argc < 3)
	{
		nPort = kDefaultServerPort;
	}
	else
	{
        nPort = atoi(argv[2]);
    }

	cout << "Host: " << pcHost << endl;
	cout << "Port: " << nPort  << endl;

	BZRC MyTeam = BZRC(pcHost, nPort, false);
	if(!MyTeam.GetStatus())
	{
		cout << "Can't connect to BZRC server." << endl;

		while(!_kbhit());
		exit(1);
	}

	// Calling agent code
	world_init(&MyTeam);

	bool exit = false;
	while(!exit)
	{
		robot_pre_update();
		exit = !robot_update();
		robot_post_update();
	}

	MyTeam.Close();

	cout << "Press any key to continue";
	while(!_kbhit());
	return 0;
}
예제 #2
0
파일: dummy_agent.cpp 프로젝트: mdko/cs470
int main(int argc, char *argv[]) {
	const char *pcHost;
	int nPort;
	std::srand(std::time(0));

	nextTurnSeconds = 0;
	nextTurnMillis = 0;
	nextShotSeconds = 0;
	nextShotMillis = 0;
	
	nextTurn = STRAIGHT;

	if(argc < 2) {
		pcHost = kDefaultServerName;
	}
	else {
		pcHost = argv[1];
	}
    if(argc < 3) {
		nPort = kDefaultServerPort;
	}
	else {
        nPort = atoi(argv[2]);
    }

	BZRC MyTeam = BZRC(pcHost, nPort, false);
	if(!MyTeam.GetStatus()) {
		cout << "Can't connect to BZRC server." << endl;
		exit(1);
	}

	// Calling agent code
	world_init(&MyTeam);

	// Update loop
	while (true) {
		robot_pre_update(&MyTeam);
		robot_update(&MyTeam);
		robot_post_update(&MyTeam);
		usleep(50);
	}

	MyTeam.Close();
	free(&MyTeam);
	return 0;
}
예제 #3
0
int main(int argc, char *argv[]) {
	const char *pcHost;
	int nPort;

	if(argc < 2) {
		pcHost = kDefaultServerName;
	}
	else {
		pcHost = argv[1];
	}
    if(argc < 3) {
		nPort = kDefaultServerPort;
	}
	else {
        nPort = atoi(argv[2]);
    }

	BZRC MyTeam = BZRC(pcHost, nPort, false);
	if(!MyTeam.GetStatus()) {
		cout << "Can't connect to BZRC server." << endl;
		exit(1);
	}

	// Calling agent code
	world_init(&MyTeam);
	dumb_agent(MyTeam);
	/*
	for(int i=1; i>0; i++)
	{
		//robot_pre_update();
		//robot_update();
		//robot_post_update();
		//Sleep(50);

		MyTeam.speed(1,1.0);
		MyTeam.shoot(2);
	}
	*/
	MyTeam.Close();
	//free(&MyTeam);
	return 0;
}