MCPcopy Create free account
hub / github.com/Blizzard/s2client-api / OnStep

Method OnStep

tests/test_unit_command.cc:1371–1400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1369 }
1370
1371 void OnStep() override {
1372 const ObservationInterface* obs = agent_->Observation();
1373 ActionInterface* act = agent_->Actions();
1374
1375 if (obs->GetGameLoop() < order_on_game_loop_) {
1376 return;
1377 }
1378
1379 test_units_ = obs->GetUnits(Unit::Self, [&](const Unit& unit) {
1380 return unit.unit_type == test_unit_type_;
1381 });
1382
1383 Unit test_unit;
1384 if (test_units_.size() > 0) {
1385 test_unit_ = test_units_.front().tag;
1386 test_unit = test_units_.front();
1387 }
1388
1389 if (!move_command_sent_) {
1390 starting_point_ = Point2D(test_unit.pos);
1391 act->UnitCommand(test_unit_, ABILITY_ID::MOVE, target_point_);
1392 move_command_sent_ = true;
1393 }
1394
1395 if (obs->GetGameLoop() < order_on_game_loop_ + 10) {
1396 return;
1397 }
1398
1399 IssueUnitCommand(act);
1400 }
1401
1402 void OnTestFinish() override {
1403 Unit test_unit;

Callers

nothing calls this directly

Calls 6

Point2DClass · 0.85
ObservationMethod · 0.80
ActionsMethod · 0.80
GetGameLoopMethod · 0.80
GetUnitsMethod · 0.80
UnitCommandMethod · 0.80

Tested by

no test coverage detected