| 1350 | // |
| 1351 | |
| 1352 | class TestStopStop : public TestUnitCommandNoTarget { |
| 1353 | public: |
| 1354 | bool move_command_sent_ = false; |
| 1355 | Point2D starting_point_; |
| 1356 | Point2D target_point_; |
| 1357 | |
| 1358 | TestStopStop() { |
| 1359 | test_unit_type_ = UNIT_TYPEID::PROTOSS_ZEALOT; |
| 1360 | test_ability_ = ABILITY_ID::STOP; |
| 1361 | } |
| 1362 | |
| 1363 | void AdditionalTestSetup() override { |
| 1364 | target_point_ = GetPointOffsetX(origin_pt_, 10); |
| 1365 | } |
| 1366 | |
| 1367 | void SetTestTime() override { |
| 1368 | wait_game_loops_ = 100; |
| 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; |
| 1404 | if (GetTestUnit(test_unit)) { |
| 1405 | if (Point2D(test_unit.pos) == starting_point_) { |
| 1406 | ReportError("Unit did not start moving as expected."); |
| 1407 | } |
| 1408 | if (Point2D(test_unit.pos) == target_point_) { |
| 1409 | ReportError("Unit did not stop moving as expected."); |
no outgoing calls