| 110 | // |
| 111 | |
| 112 | class TestCoordinateSystemMap : public TestSequence { |
| 113 | public: |
| 114 | Point2D spawn_pt_; |
| 115 | |
| 116 | void OnTestStart() override { |
| 117 | const GameInfo& game_info = agent_->Observation()->GetGameInfo(); |
| 118 | float camera_size = game_info.options.feature_layer.camera_width; |
| 119 | float max_spawn_offset = (camera_size / 2.0f) - 1.0f; |
| 120 | |
| 121 | Point2D min = game_info.playable_min; |
| 122 | Point2D max = game_info.playable_max; |
| 123 | min.x += max_spawn_offset; |
| 124 | min.y += max_spawn_offset; |
| 125 | max.x -= max_spawn_offset; |
| 126 | max.y -= max_spawn_offset; |
| 127 | if (min.x > max.x || min.y > max.y) { |
| 128 | ReportError("Map is too small to run test"); |
| 129 | return; |
| 130 | } |
| 131 | |
| 132 | Point2D camera_pt_= FindRandomLocation(min, max); |
| 133 | spawn_pt_.x = camera_pt_.x + GetRandomScalar() * max_spawn_offset; |
| 134 | spawn_pt_.y = camera_pt_.y + GetRandomScalar() * max_spawn_offset; |
| 135 | |
| 136 | DebugInterface* debug = agent_->Debug(); |
| 137 | debug->DebugMoveCamera(camera_pt_); |
| 138 | debug->DebugCreateUnit(UNIT_TYPEID::TERRAN_MARINE, spawn_pt_, agent_->Observation()->GetPlayerID(), 1); |
| 139 | debug->SendDebug(); |
| 140 | |
| 141 | wait_game_loops_ = 5; |
| 142 | } |
| 143 | |
| 144 | void OnStep() override { |
| 145 | |
| 146 | } |
| 147 | |
| 148 | void OnTestFinish() override { |
| 149 | // Cleanup Test |
| 150 | KillAllUnits(); |
| 151 | |
| 152 | // Validate Result |
| 153 | FeatureLayer8BPP data; |
| 154 | const char* error = GetPlayerRelativeLayer(agent_, FeatureLayerType::MAP, data); |
| 155 | if (error) { |
| 156 | ReportError(error); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | const GameInfo& game_info = agent_->Observation()->GetGameInfo(); |
| 161 | Point2D camera_world = agent_->Observation()->GetCameraPos(); |
| 162 | Point2DI camera = ConvertWorldToCamera(game_info, camera_world, spawn_pt_); |
| 163 | |
| 164 | if (!data.InBounds(camera)) { |
| 165 | ReportError("Unit not in camera bounds"); |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | if (data.Read(camera) == 0) |
no outgoing calls