void Agent::think() { // Stime time data // This is a sensation to be given to the agent. It begins a // thinking cycle. The first time is the simulation time the // sensation was generated (also known as the send time) and the // second is the time that the sensation is delivered to the agent // (also known as the arrive time). If the parameter send agent send // time is off, -1 is always sent as the send time, and if the // parameter send agent arrive time is off, -1 is always sent as the // arrive time. The data is an arbitrary data string generated by // the world model. The agent can reply with act messages, and must // finish with a done thinking message. LOGBEGIN; LOG( 1, "received sensation %i" , _sensationCount ); //if ( WM->getGameTime() > 150 ) exit(0); WM->update(); _panTilted = false; switch ( _sensationCount ) { case 0: createAgent(); break; case 1: initAgent(); break; default:; playMatch(); } ++_sensationCount; //if ( _sensationCount > 1000 ) exit(1);//profile the program //--------------for DEBUG----------------- //-- init FileLogger and open file if ( _sensationCount == 10 ) { init(); WM->setSameTypeTeammateNum(); //-* can only update after set the num #ifdef ENABLE_LOG msgLog.openFile("msgLog"); //-* logging all msg for communcation with the server localizationLog.openFile("myPos");//-* for debuging localization ballPosLog.openFile("ballPos"); //-* for debuging localize ball's position #endif } //-------------end DEBUG---------------------- /* ** From 'NEWS' in SPADES 1.10 ** * * Agents can now, in the middle of a thinking cycle, send a "request current think time" message. The commserver responds with the * current think time for this thinking cycle. This message is processed by the commserver (no network message to the engine) and * the commserver responds as quickly as it can. The format: * Agent->CS: "C" is a request current think time message * CS->Agent: "C<time>" is the response, where <time> is the current thinking time * CS->Agent: "req_curr_think_time_when_not_thinking" is a new error code if the agent sends this message when it's not thinking */ //-* "C" message //-- send a "C" to commserver //-- commserver reply current think time //-- the reply formation is "C<time>" // Time timeBeforeThink = WM->getRealTime(); COMM->PutOutput( requestThinkTimeMessage() ); LOG( 2, "---------after send C-------"); if ( COMM->GetInput() ) { LOG( 2, COMM->GetMsg() ); #ifdef ENABLE_LOG msgLog.log( COMM->GetMsg() ); msgLog.log( "\n"); #endif PA->parseAll(COMM->GetMsg()); LOG( 2, "C time: %f",WM->getCurrentThinkTime() ); } sendActionNotifys(); }