MCPcopy Create free account
hub / github.com/LARG/HFO / execute

Method execute

src/sample_communication.cpp:184–241  ·  view source on GitHub ↗

-------------------------------------------------------------------*/ ! */

Source from the content-addressed store, hash-verified

182
183 */
184bool
185SampleCommunication::execute( PlayerAgent * agent )
186{
187 if ( ! agent->config().useCommunication() )
188 {
189 return false;
190 }
191
192 updateCurrentSender( agent );
193
194 const WorldModel & wm = agent->world();
195 const bool penalty_shootout = wm.gameMode().isPenaltyKickMode();
196
197 bool say_recovery = false;
198 if ( wm.gameMode().type() != GameMode::PlayOn
199 && ! penalty_shootout
200 && currentSenderUnum() == wm.self().unum()
201 && wm.self().recovery() < ServerParam::i().recoverInit() - 0.002 )
202 {
203 say_recovery = true;
204 sayRecovery( agent );
205 }
206
207 if ( wm.gameMode().type() == GameMode::BeforeKickOff
208 || wm.gameMode().type() == GameMode::AfterGoal_
209 || penalty_shootout )
210 {
211 return say_recovery;
212 }
213
214#ifdef DEBUG_PRINT_PLAYER_RECORD
215 const AudioMemory::PlayerRecord::const_iterator end = agent->world().audioMemory().playerRecord().end();
216 for ( AudioMemory::PlayerRecord::const_iterator p = agent->world().audioMemory().playerRecord().begin();
217 p != end;
218 ++p )
219 {
220 dlog.addText( Logger::COMMUNICATION,
221 __FILE__": PlayerRecord: time=[%d,%d] %s %d from %d",
222 p->first.cycle(), p->first.stopped(),
223 p->second.unum_ <= 11 ? "teammate" : "opponent",
224 p->second.unum_ <= 11 ? p->second.unum_ : p->second.unum_ - 11,
225 p->second.sender_ );
226 }
227#endif
228
229#if 1
230 sayBallAndPlayers( agent );
231 sayStamina( agent );
232#else
233 sayBall( agent );
234 sayGoalie( agent );
235 saySelf( agent );
236 sayPlayers( agent );
237#endif
238 attentiontoSomeone( agent );
239
240 return true;
241}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected