コード例 #1
0
	/**
	* Processes the server tips
	* @param tip The server tip in string shape
	*/
	void BFClientBasicState::reactOnServerTip (const string& tip) throw (StrategyException,bad_exception) {
		if (tip=="STARTROTATION")
			sendRTBMessageRotate(6,_go->ROBOT_CANNON_MAX_ROTATE);
		else if (tip=="STOPROTATION")
			sendRTBMessageRotate(6,0.0);
			
		else
			_bfcsp->getLogger()->logMessage(100,"Unknown server tip in brotfrucht: "+tip);	
	}
コード例 #2
0
void ColumbusClientBaseState::driveTowards (const Position& pos) throw (bad_exception)
{
	static double para=M_PI*_go->ROBOT_MAX_ACCELERATION;
	static double M2PI=M_PI+M_PI;
	static RobotInfo *i=&(_csp->getRobotInfo());
	double dx=pos.x-i->pos.x;
	double dy=pos.y-i->pos.y;
	double force=dx*dx+dy*dy;
	force=(M_1_PI-M_1_PI/(1+force))*.8+.2;
	double dir=dx==0.&&dy==0.?0.:atan2(dy,dx)-i->dirRobot;
	dir-=M2PI*int(dir/M2PI);
	while(dir<-M_PI)
		dir+=M2PI;
	while(dir>=M_PI)
		dir-=M2PI;
	sendRTBMessageDebugLine(0,0,dir,.6+force);
	double ad=fabs(dir);
	if(ad>M_PI_2)
		sendRTBMessageBrake(force*(ad-M_PI));
	else	sendRTBMessageAccelerate(force*(para-_go->ROBOT_MAX_ACCELERATION*ad));
	sendRTBMessageRotate(1,force*dir*_go->ROBOT_MAX_ROTATE);
}