#include "assets/level.hpp" #include "core/clock.hpp" #include "core/vfs.hpp" #include "game/game_modes.hpp" #include "sim/ai_driver.hpp" #include "sim/combat.hpp" #include "sim/race_sim.hpp" #include #include #include #include #include #include using namespace top_octane; #define CHECK(cond) \ do { \ if (!(cond)) { \ std::cerr << "FAIL [" << __FILE__ << ":" << __LINE__ << "]: " #cond << "\n"; \ return 1; \ } \ } while (0) int main() { Vfs vfs; CHECK(vfs.init(HIOCTANE_DEFAULT_DATA_DIR)); assets::LevelData lvl1; CHECK(lvl1.load(vfs, 1)); float dt = static_cast(FixedStepClock::kFixedDt); // 1. Multi-AI Race Simulation (8 racers, 1 lap) + Combat + Pickups sim::RaceSetup setup; setup.mode = sim::GameMode::SingleRace; setup.track_number = 1; setup.total_laps = 1; setup.difficulty = 2; // Hard AI with weapons & boosting setup.num_ai = 7; sim::RaceSim sim; CHECK(sim.start_race(lvl1, setup)); sim.crafts_mut()[0].autopilot = true; int total_shots = 0; for (int t = 0; t < 4000 && !sim.race_finished(); ++t) { CraftInput in; in.fire_minigun = (t % 20 == 0); sim.step(in, CraftInput{}, dt); } for (const auto& c : sim.crafts()) { total_shots += c.shots_fired; } CHECK(sim.crafts()[0].finished); CHECK(total_shots > 0); std::cout << "[PASS] 8-racer AI & combat race finished in " << sim.crafts()[0].race_time << "s (placement=" << sim.crafts()[0].placement << ", total_shots=" << total_shots << ")\n"; // 2. Clone Race Ghost Recording & Playback sim::CloneRecording rec = sim.current_recording(); CHECK(rec.frames.size() > 100); { sim::RaceSetup csetup; csetup.mode = sim::GameMode::CloneRace; csetup.track_number = 1; csetup.total_laps = 1; sim::RaceSim csim; CHECK(csim.start_race(lvl1, csetup, &rec)); CHECK(csim.has_clone_ghost()); for (int t = 0; t < 240; ++t) { csim.step(CraftInput{}, CraftInput{}, dt); } sim::CraftPose gpose = csim.interpolated_clone_pose(0.5f); CHECK(gpose.pos.len_sq() > 0.1f); } std::cout << "[PASS] Clone Race ghost recording & playback validated\n"; // 3. DeathMatch & Recovery Craft Repair Sequence { sim::RaceSetup dm; dm.mode = sim::GameMode::DeathMatch; dm.track_number = 1; dm.num_ai = 3; dm.deathmatch_kill_limit = 2; sim::RaceSim dsim; CHECK(dsim.start_race(lvl1, dm)); // Skip countdown for (int t = 0; t < 200; ++t) dsim.step(CraftInput{}, CraftInput{}, dt); // Place victim directly in front of P1 and fire missile/minigun to test kill & recovery craft auto& p1 = dsim.crafts_mut()[0]; auto& tgt = dsim.crafts_mut()[1]; Vec3 fwd = p1.forward_dir(); tgt.curr_pose.pos = p1.curr_pose.pos + fwd * 3.0f; tgt.prev_pose = tgt.curr_pose; tgt.shield = 5.0f; for (int t = 0; t < 60; ++t) { CraftInput fire; fire.fire_minigun = true; dsim.step(fire, CraftInput{}, dt); } CHECK(p1.kills >= 1); CHECK(tgt.deaths >= 1); auto rvis = sim::get_recovery_visuals(dsim.crafts()); CHECK(!rvis.empty()); } std::cout << "[PASS] DeathMatch kill scoring & Recovery Craft dispatch validated\n"; // 4. Championship Save / Load & Highscore Persistence in temp directory std::filesystem::path tmp_dir = std::filesystem::temp_directory_path() / "top_octane_test_saves"; std::filesystem::remove_all(tmp_dir); { game::ChampionshipState ch; ch.start_new("ACE", 3, 7, 1, 8); ch.record_race_results(sim.crafts()); CHECK(ch.current_track == 2); CHECK(ch.total_tracks == 8); CHECK(ch.save_slot(tmp_dir, 0)); game::ChampionshipState loaded; CHECK(loaded.load_slot(tmp_dir, 0)); CHECK(loaded.current_track == 2); CHECK(loaded.total_tracks == 8); CHECK(loaded.player_name == "ACE"); CHECK(loaded.drivers[0].points == ch.drivers[0].points); game::HighscoreTable hs; hs.clear(); int flags = hs.submit_race(1, sim.crafts()); CHECK((flags & 3) == 3); int flags9 = hs.submit_race(9, sim.crafts()); CHECK((flags9 & 3) == 3); CHECK(hs.save(tmp_dir / "hiscores.dat")); game::HighscoreTable hs2; CHECK(hs2.load(tmp_dir / "hiscores.dat")); CHECK(hs2.tracks[0].best_lap == hs.tracks[0].best_lap); CHECK(std::abs(hs2.tracks[8].best_lap - hs.tracks[8].best_lap) < 1e-6f); // Legacy V1 highscores backwards-compatibility (6 entries) { std::ofstream ofs(tmp_dir / "hiscores_v1.dat", std::ios::trunc); ofs << "TOPOCTANE_HISCORE_V1\n"; for (int i = 0; i < 6; ++i) { ofs << (12.5f + i) << " " << (42.0f + i) << "\nLEGACY" << i << "\nLEGACYR" << i << "\n"; } } game::HighscoreTable hs_v1; CHECK(hs_v1.load(tmp_dir / "hiscores_v1.dat")); CHECK(std::abs(hs_v1.tracks[0].best_lap - 12.5f) < 1e-5f); CHECK(hs_v1.tracks[0].best_lap_driver == "LEGACY0"); CHECK(hs_v1.tracks[8].best_lap == 0.0f); CHECK(game::save_clone_recording(tmp_dir, rec)); sim::CloneRecording rec2; CHECK(game::load_clone_recording(tmp_dir, 1, rec2)); CHECK(rec2.frames.size() == rec.frames.size()); sim::CloneRecording rec7 = rec; rec7.track_number = 7; CHECK(game::save_clone_recording(tmp_dir, rec7)); sim::CloneRecording rec7_out; CHECK(game::load_clone_recording(tmp_dir, 7, rec7_out)); CHECK(rec7_out.track_number == 7 && rec7_out.frames.size() == rec7.frames.size()); } std::filesystem::remove_all(tmp_dir); std::cout << "[PASS] Championship save/load, 9-track Highscores (V1/V2) & Clone disk round-trip validated\n"; // 5. Gameplay Rule Toggles (fuel, weapons, damage, pickups, track morphing) { sim::RaceSetup r1; r1.mode = sim::GameMode::SingleRace; r1.track_number = 1; r1.num_ai = 1; r1.fuel_enabled = false; r1.weapons_enabled = false; r1.pickups_enabled = false; r1.track_morphing_enabled = false; sim::RaceSim ts1; CHECK(ts1.start_race(lvl1, r1)); CHECK(ts1.pickups().empty()); float start_fuel = ts1.crafts()[0].fuel; // Skip countdown for (int t = 0; t < 200; ++t) ts1.step(CraftInput{}, CraftInput{}, dt); CraftInput drive; drive.throttle = 1.0f; drive.boost = true; drive.fire_minigun = true; drive.fire_missile = true; for (int t = 0; t < 120; ++t) { ts1.step(drive, CraftInput{}, dt); CHECK(ts1.projectiles().empty()); } CHECK(ts1.crafts()[0].fuel == start_fuel); if (!lvl1.triggers.empty()) { const auto& tr = lvl1.triggers[0]; ts1.crafts_mut()[0].curr_pose.pos = Vec3( tr.tile_x() + 0.5f, lvl1.sample_height_world(tr.tile_x() + 0.5f, tr.tile_z() + 0.5f), tr.tile_z() + 0.5f); ts1.step(CraftInput{}, CraftInput{}, dt); int x0, z0, x1, z1; CHECK(!ts1.consume_terrain_dirty(x0, z0, x1, z1)); } // damage_enabled = false keeps target shields intact on direct hits sim::RaceSetup r2; r2.mode = sim::GameMode::DeathMatch; r2.track_number = 1; r2.num_ai = 1; r2.damage_enabled = false; sim::RaceSim ts2; CHECK(ts2.start_race(lvl1, r2)); for (int t = 0; t < 200; ++t) ts2.step(CraftInput{}, CraftInput{}, dt); auto& p1 = ts2.crafts_mut()[0]; auto& tgt = ts2.crafts_mut()[1]; Vec3 fwd = p1.forward_dir(); tgt.curr_pose.pos = p1.curr_pose.pos + fwd * 3.0f; tgt.prev_pose = tgt.curr_pose; float init_sh = tgt.shield; for (int t = 0; t < 60; ++t) { CraftInput fire; fire.fire_minigun = true; ts2.step(fire, CraftInput{}, dt); } CHECK(tgt.shield == init_sh); CHECK(p1.kills == 0); } std::cout << "[PASS] Gameplay rule toggles (fuel, weapons, damage, pickups, morphing) validated\n"; // 6. Authentic Sector Morphing across all 6 levels (Timed, Craft, Rocket triggers + columns/lights/pickups) { const size_t expected_morph_counts[6] = {1, 3, 5, 6, 7, 6}; for (int l = 1; l <= 6; ++l) { assets::LevelData lvl; CHECK(lvl.load(vfs, l)); CHECK(lvl.morphs.size() == expected_morph_counts[l - 1]); } // 6a. Level 1: Timed morph id=66 lowers (17,32) 1504 -> 1184, then oscillates back to 1504 { sim::RaceSetup ms; ms.track_number = 1; ms.num_ai = 0; sim::RaceSim msim; CHECK(msim.start_race(lvl1, ms)); CHECK(msim.level().cell(17, 32).height == 1504); for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt); for (int t = 0; t < 290; ++t) msim.step(CraftInput{}, CraftInput{}, dt); CHECK(msim.level().cell(17, 32).height == 1184); for (int t = 0; t < 290; ++t) msim.step(CraftInput{}, CraftInput{}, dt); CHECK(msim.level().cell(17, 32).height == 1504); } // 6b. Level 2: Craft trigger id=80 lowers & re-textures (109,20); Craft trigger id=198 unlocks grp=3 pickups { assets::LevelData lvl2; CHECK(lvl2.load(vfs, 2)); sim::RaceSetup ms; ms.track_number = 2; ms.num_ai = 0; sim::RaceSim msim; CHECK(msim.start_race(lvl2, ms)); CHECK(msim.level().cell(109, 20).height == 2480); CHECK(msim.level().cell(109, 20).tex_or_col == 72); bool has_locked_g3 = false; for (const auto& pk : msim.pickups()) { if (pk.group == 3) { has_locked_g3 = true; CHECK(!pk.group_unlocked); } } CHECK(has_locked_g3); for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt); msim.crafts_mut()[0].curr_pose.pos = Vec3(110.5f, msim.level().sample_height_world(110.5f, 19.5f) + 0.30f, 19.5f); msim.crafts_mut()[0].prev_pose = msim.crafts_mut()[0].curr_pose; for (int t = 0; t < 60; ++t) msim.step(CraftInput{}, CraftInput{}, dt); CHECK(msim.level().cell(109, 20).height == 1840); CHECK(msim.level().cell(109, 20).tex_or_col == 63); msim.crafts_mut()[0].curr_pose.pos = Vec3(127.5f, msim.level().sample_height_world(127.5f, 21.5f) + 0.30f, 21.5f); msim.crafts_mut()[0].prev_pose = msim.crafts_mut()[0].curr_pose; for (int t = 0; t < 10; ++t) msim.step(CraftInput{}, CraftInput{}, dt); for (const auto& pk : msim.pickups()) { if (pk.group == 3) CHECK(pk.group_unlocked && pk.active); } } // 6c. Level 3: Rocket trigger id=176 removes solid columns at (67,63) and marks columns_dirty { assets::LevelData lvl3; CHECK(lvl3.load(vfs, 3)); sim::RaceSetup ms; ms.track_number = 3; ms.num_ai = 0; sim::RaceSim msim; CHECK(msim.start_race(lvl3, ms)); CHECK(msim.level().cell(67, 63).tex_or_col == -87); float col_y = msim.level().sample_height_world(67.5f, 63.5f) + 0.30f; CHECK(msim.level().is_cell_solid_at_point(67, 63, 67.5f, 63.5f, col_y)); for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt); auto& p1 = msim.crafts_mut()[0]; p1.curr_pose.pos = Vec3(67.5f, msim.level().sample_height_world(67.5f, 67.5f) + 0.30f, 67.5f); p1.curr_pose.yaw = kPi; p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); bool saw_cols_dirty = false; std::vector rects; for (int t = 0; t < 40; ++t) { CraftInput fire; fire.fire_missile = (t == 0); msim.step(fire, CraftInput{}, dt); bool cdirty = false; if (msim.consume_world_dirty(rects, cdirty) && cdirty) saw_cols_dirty = true; } CHECK(saw_cols_dirty); CHECK(msim.level().cell(67, 63).tex_or_col >= 0); CHECK(!msim.level().is_cell_solid_at_point(67, 63, 67.5f, 63.5f, col_y)); } // 6d. Level 4: Rocket id=153 collapses reactor wall (69,83) & unlocks grp=10 pickups; Craft id=256 + Rocket id=40 open bunker ONCE { assets::LevelData lvl4; CHECK(lvl4.load(vfs, 4)); sim::RaceSetup ms; ms.track_number = 4; ms.num_ai = 0; sim::RaceSim msim; CHECK(msim.start_race(lvl4, ms)); CHECK(msim.level().cell(69, 83).height == 2992); CHECK(msim.level().cell(43, 114).tex_or_col == -168); for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt); auto& p1 = msim.crafts_mut()[0]; p1.curr_pose.pos = Vec3(69.5f, msim.level().sample_height_world(69.5f, 90.0f) + 0.30f, 90.0f); p1.curr_pose.yaw = kPi; p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); for (int t = 0; t < 60; ++t) { CraftInput fire; fire.fire_missile = (t == 0); msim.step(fire, CraftInput{}, dt); } CHECK(msim.level().cell(69, 83).height == 2048); bool g10_unlocked = false; for (const auto& pk : msim.pickups()) { if (pk.group == 10) { g10_unlocked = true; CHECK(pk.group_unlocked); float expected_y = msim.level().sample_height_world(pk.pos.x, pk.pos.z) + 0.45f; CHECK(std::abs(pk.pos.y - expected_y) < 0.05f); } } CHECK(g10_unlocked); p1.curr_pose.pos = Vec3(44.5f, msim.level().sample_height_world(44.5f, 49.5f) + 0.30f, 49.5f); p1.prev_pose = p1.curr_pose; for (int t = 0; t < 40; ++t) msim.step(CraftInput{}, CraftInput{}, dt); CHECK(msim.level().cell(43, 114).tex_or_col == -167); p1.curr_pose.pos = Vec3(44.5f, msim.level().sample_height_world(44.5f, 117.0f) + 0.30f, 117.0f); p1.curr_pose.yaw = kPi; p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); p1.missile_cd = 0.0f; for (int t = 0; t < 40; ++t) { CraftInput fire; fire.fire_missile = (t == 0); msim.step(fire, CraftInput{}, dt); } CHECK(msim.level().cell(43, 114).tex_or_col == -167); } // 6e. Level 5: Rocket id=286 blasts pillar (70,81); Craft id=275 starts blinking tunnel lights at (10,25) { assets::LevelData lvl5; CHECK(lvl5.load(vfs, 5)); sim::RaceSetup ms; ms.track_number = 5; ms.num_ai = 0; sim::RaceSim msim; CHECK(msim.start_race(lvl5, ms)); CHECK(msim.level().cell(70, 81).tex_or_col == -60); CHECK(msim.level().cell(10, 25).illumination == 12800); for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt); auto& p1 = msim.crafts_mut()[0]; p1.curr_pose.pos = Vec3(70.5f, msim.level().sample_height_world(70.5f, 84.0f) + 0.30f, 84.0f); p1.curr_pose.yaw = kPi; p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); bool saw_cols_dirty = false; std::vector rects; for (int t = 0; t < 40; ++t) { CraftInput fire; fire.fire_missile = (t == 0); msim.step(fire, CraftInput{}, dt); bool cdirty = false; if (msim.consume_world_dirty(rects, cdirty) && cdirty) saw_cols_dirty = true; } CHECK(saw_cols_dirty); CHECK(msim.level().cell(70, 81).tex_or_col == 117); p1.curr_pose.pos = Vec3(20.5f, msim.level().sample_height_world(20.5f, 77.5f) + 0.30f, 77.5f); p1.prev_pose = p1.curr_pose; bool saw_dim = false; for (int t = 0; t < 60; ++t) { msim.step(CraftInput{}, CraftInput{}, dt); if (msim.level().cell(10, 25).illumination == 8192) saw_dim = true; } CHECK(saw_dim); bool saw_bright = false; for (int t = 0; t < 60; ++t) { msim.step(CraftInput{}, CraftInput{}, dt); if (msim.level().cell(10, 25).illumination == 12800) saw_bright = true; } CHECK(saw_bright); } // 6f. Level 6: Timed id=3 oscillates ramp (10,75); Craft id=148 collapses (48,52); Rocket id=184 blasts (33,16) { assets::LevelData lvl6; CHECK(lvl6.load(vfs, 6)); sim::RaceSetup ms; ms.track_number = 6; ms.num_ai = 0; sim::RaceSim msim; CHECK(msim.start_race(lvl6, ms)); CHECK(msim.level().cell(10, 75).height == 2368); CHECK(msim.level().cell(48, 52).tex_or_col == -480); CHECK(msim.level().cell(33, 16).tex_or_col == -112); for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt); for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt); CHECK(msim.level().cell(10, 75).height == 2048); for (int t = 0; t < 180; ++t) msim.step(CraftInput{}, CraftInput{}, dt); CHECK(msim.level().cell(10, 75).height == 2368); auto& p1 = msim.crafts_mut()[0]; p1.curr_pose.pos = Vec3(70.5f, msim.level().sample_height_world(70.5f, 51.5f) + 0.30f, 51.5f); p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); bool saw_cols_dirty = false; std::vector rects; for (int t = 0; t < 40; ++t) { msim.step(CraftInput{}, CraftInput{}, dt); bool cdirty = false; if (msim.consume_world_dirty(rects, cdirty) && cdirty) saw_cols_dirty = true; } CHECK(saw_cols_dirty); CHECK(msim.level().cell(48, 52).tex_or_col >= 0); p1.curr_pose.pos = Vec3(33.5f, msim.level().sample_height_world(33.5f, 19.5f) + 0.30f, 19.5f); p1.curr_pose.yaw = kPi; p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); p1.missile_cd = 0.0f; for (int t = 0; t < 40; ++t) { CraftInput fire; fire.fire_missile = (t == 0); msim.step(fire, CraftInput{}, dt); } CHECK(msim.level().cell(33, 16).tex_or_col >= 0); } // 6g. track_morphing_enabled = false disables Timed (L1), Craft (L2), and Rocket (L3) morphs { sim::RaceSetup off1; off1.track_number = 1; off1.num_ai = 0; off1.track_morphing_enabled = false; sim::RaceSim s1; CHECK(s1.start_race(lvl1, off1)); for (int t = 0; t < 500; ++t) s1.step(CraftInput{}, CraftInput{}, dt); CHECK(s1.level().cell(17, 32).height == 1504); assets::LevelData lvl2; CHECK(lvl2.load(vfs, 2)); sim::RaceSetup off2; off2.track_number = 2; off2.num_ai = 0; off2.track_morphing_enabled = false; sim::RaceSim s2; CHECK(s2.start_race(lvl2, off2)); for (int t = 0; t < 200; ++t) s2.step(CraftInput{}, CraftInput{}, dt); s2.crafts_mut()[0].curr_pose.pos = Vec3(110.5f, s2.level().sample_height_world(110.5f, 19.5f) + 0.30f, 19.5f); s2.crafts_mut()[0].prev_pose = s2.crafts_mut()[0].curr_pose; for (int t = 0; t < 60; ++t) s2.step(CraftInput{}, CraftInput{}, dt); CHECK(s2.level().cell(109, 20).height == 2480); assets::LevelData lvl3; CHECK(lvl3.load(vfs, 3)); sim::RaceSetup off3; off3.track_number = 3; off3.num_ai = 0; off3.track_morphing_enabled = false; sim::RaceSim s3; CHECK(s3.start_race(lvl3, off3)); for (int t = 0; t < 200; ++t) s3.step(CraftInput{}, CraftInput{}, dt); s3.crafts_mut()[0].curr_pose.pos = Vec3(67.5f, s3.level().sample_height_world(67.5f, 67.5f) + 0.30f, 67.5f); s3.crafts_mut()[0].curr_pose.yaw = kPi; s3.crafts_mut()[0].prev_pose = s3.crafts_mut()[0].curr_pose; for (int t = 0; t < 40; ++t) { CraftInput fire; fire.fire_missile = (t == 0); s3.step(fire, CraftInput{}, dt); } CHECK(s3.level().cell(67, 63).tex_or_col == -87); } } std::cout << "[PASS] Authentic sector morphing, Timed/Craft/Rocket triggers & groups verified across all 6 tracks\n"; // 7. PostRace Leaderboard Opponent Times & SplitScreen Completion { // 7a. 1-lap 8-racer race on Track 3 assets::LevelData lvl3; CHECK(lvl3.load(vfs, 3)); sim::RaceSetup s1; s1.mode = sim::GameMode::SingleRace; s1.track_number = 3; s1.total_laps = 1; s1.difficulty = 1; s1.num_ai = 7; sim::RaceSim sim1; CHECK(sim1.start_race(lvl3, s1)); sim1.crafts_mut()[0].autopilot = true; for (int t = 0; t < 10000 && !sim1.race_finished(); ++t) { sim1.step(CraftInput{}, CraftInput{}, dt); } CHECK(sim1.race_finished()); CHECK(sim1.crafts()[0].finished); auto sorted1 = sim1.crafts(); std::sort(sorted1.begin(), sorted1.end(), [](const auto& a, const auto& b) { return a.placement < b.placement; }); bool any_unfinished1 = false; for (size_t i = 0; i < sorted1.size(); ++i) { const auto& c = sorted1[i]; CHECK(c.placement == static_cast(i + 1)); CHECK(c.race_time > 0.0f && c.race_time < 600.0f); CHECK(c.best_lap_time > 0.0f && c.best_lap_time <= c.race_time + 1e-4f); if (!c.finished) { any_unfinished1 = true; if (i > 0) { CHECK(c.race_time > sorted1[i - 1].race_time + 0.04f); } } } CHECK(any_unfinished1); // Extra steps after race_finished() must not mutate finalized times or placements for (int t = 0; t < 10; ++t) { sim1.step(CraftInput{}, CraftInput{}, dt); } auto after1 = sim1.crafts(); std::sort(after1.begin(), after1.end(), [](const auto& a, const auto& b) { return a.placement < b.placement; }); for (size_t i = 0; i < sorted1.size(); ++i) { CHECK(after1[i].placement == sorted1[i].placement); CHECK(std::abs(after1[i].race_time - sorted1[i].race_time) < 1e-6f); } // 7b. 3-lap 8-racer race on Track 5 assets::LevelData lvl5; CHECK(lvl5.load(vfs, 5)); sim::RaceSetup s3; s3.mode = sim::GameMode::SingleRace; s3.track_number = 5; s3.total_laps = 3; s3.difficulty = 1; s3.num_ai = 7; sim::RaceSim sim3; CHECK(sim3.start_race(lvl5, s3)); sim3.crafts_mut()[0].autopilot = true; for (int t = 0; t < 15000 && !sim3.race_finished(); ++t) { sim3.step(CraftInput{}, CraftInput{}, dt); } CHECK(sim3.race_finished()); CHECK(sim3.crafts()[0].finished); auto sorted3 = sim3.crafts(); std::sort(sorted3.begin(), sorted3.end(), [](const auto& a, const auto& b) { return a.placement < b.placement; }); bool any_unfinished3 = false; for (size_t i = 0; i < sorted3.size(); ++i) { const auto& c = sorted3[i]; CHECK(c.placement == static_cast(i + 1)); CHECK(c.race_time > 0.0f && c.race_time < 600.0f); CHECK(c.best_lap_time > 0.0f && c.best_lap_time <= c.race_time + 1e-4f); if (!c.finished) { any_unfinished3 = true; if (i > 0) { CHECK(c.race_time > sorted3[i - 1].race_time + 0.04f); } } else if (i > 0) { CHECK(c.race_time >= sorted3[i - 1].race_time - 1e-5f); } } CHECK(any_unfinished3); game::HighscoreTable hs; hs.clear(); int flags = hs.submit_race(5, sim3.crafts()); CHECK((flags & 3) == 3); CHECK(hs.tracks[4].best_race_driver == sim3.crafts()[0].pilot_name); CHECK(std::abs(hs.tracks[4].best_race - sim3.crafts()[0].race_time) < 1e-6f); // 7c. 2-player SplitScreen completion waits for both humans sim::RaceSetup sp; sp.mode = sim::GameMode::SplitScreen; sp.track_number = 3; sp.total_laps = 1; sp.difficulty = 1; sp.num_ai = 2; sp.p2_vehicle = sp.p1_vehicle; sim::RaceSim sim_sp; CHECK(sim_sp.start_race(lvl3, sp)); sim_sp.crafts_mut()[0].autopilot = true; sim_sp.crafts_mut()[1].autopilot = false; // Give P1 a small head start (~2 seconds after 3s countdown), then let P2 drive so unfinished AI may also be checked for (int t = 0; t < 10000 && !sim_sp.crafts()[0].finished; ++t) { if (t == 300) { sim_sp.crafts_mut()[1].autopilot = true; } sim_sp.step(CraftInput{}, CraftInput{}, dt); } CHECK(sim_sp.crafts()[0].finished); CHECK(!sim_sp.crafts()[1].finished); CHECK(!sim_sp.race_finished()); sim_sp.crafts_mut()[1].autopilot = true; for (int t = 0; t < 10000 && !sim_sp.race_finished(); ++t) { sim_sp.step(CraftInput{}, CraftInput{}, dt); } CHECK(sim_sp.race_finished()); CHECK(sim_sp.crafts()[0].finished); CHECK(sim_sp.crafts()[1].finished); CHECK(sim_sp.crafts()[1].race_time > sim_sp.crafts()[0].race_time); auto sorted_sp = sim_sp.crafts(); std::sort(sorted_sp.begin(), sorted_sp.end(), [](const auto& a, const auto& b) { return a.placement < b.placement; }); for (size_t i = 0; i < sorted_sp.size(); ++i) { const auto& c = sorted_sp[i]; CHECK(c.race_time > 0.0f && c.best_lap_time > 0.0f); if (!c.finished) { CHECK(c.race_time > sim_sp.crafts()[1].race_time); if (i > 0) { CHECK(c.race_time > sorted_sp[i - 1].race_time + 0.04f); } } } } std::cout << "[PASS] PostRace leaderboard opponent times & SplitScreen completion validated\n"; // 8. Authentic Pitstop Fuel / Shield / Ammo Charger Bays { const size_t expected_pad_counts[9] = {3, 3, 3, 7, 6, 7, 4, 4, 3}; for (int l = 1; l <= 9; ++l) { assets::LevelData lvl; CHECK(lvl.load(vfs, l)); CHECK(lvl.pads.size() == expected_pad_counts[l - 1]); int n_shield = 0, n_fuel = 0, n_ammo = 0; for (const auto& pad : lvl.pads) { if (pad.type == assets::ChargerType::Shield) ++n_shield; else if (pad.type == assets::ChargerType::Fuel) ++n_fuel; else if (pad.type == assets::ChargerType::Ammo) ++n_ammo; } CHECK(n_shield >= 1 && n_fuel >= 1 && n_ammo >= 1); } // Typed pitstop recharge on Level 1 { sim::RaceSetup ps; ps.mode = sim::GameMode::SingleRace; ps.track_number = 1; ps.num_ai = 0; ps.fuel_enabled = true; ps.damage_enabled = true; ps.weapons_enabled = true; sim::RaceSim psim; CHECK(psim.start_race(lvl1, ps)); for (int t = 0; t < 200; ++t) psim.step(CraftInput{}, CraftInput{}, dt); auto& p1 = psim.crafts_mut()[0]; auto place_p1 = [&](float wx, float wz, float dy = 0.30f) { p1.curr_pose.pos = Vec3(wx, psim.level().sample_height_world(wx, wz) + dy, wz); p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); }; // Fuel bay (49.0, 79.0): recharges only fuel, updates on_pit_mask/pit_fill_ratio & emits PitComplete on 100% p1.fuel = 20.0f; p1.shield = 20.0f; p1.ammo = 20.0f; place_p1(49.0f, 79.0f); psim.clear_events(); float first_fill = 1.0f; float mid_fill = 0.0f; bool saw_pit_complete = false; for (int t = 0; t < 60; ++t) { psim.step(CraftInput{}, CraftInput{}, dt); if (t == 0) { CHECK(p1.on_pit_mask == 2u); CHECK(p1.active_recharge_mask == 2u); first_fill = p1.pit_fill_ratio; } if (t == 59) { mid_fill = p1.pit_fill_ratio; } for (const auto& ev : psim.events()) { if (ev.sound == sim::SimSoundCue::PitComplete) saw_pit_complete = true; } psim.clear_events(); } CHECK(p1.fuel > 70.0f); CHECK(p1.shield == 20.0f); CHECK(p1.ammo == 20.0f); CHECK(mid_fill > first_fill && mid_fill < 1.0f); // Continue on Fuel bay until full -> PitComplete emitted & active_recharge_mask clears while on_pit_mask stays 2 for (int t = 0; t < 70; ++t) { psim.step(CraftInput{}, CraftInput{}, dt); for (const auto& ev : psim.events()) { if (ev.sound == sim::SimSoundCue::PitComplete) saw_pit_complete = true; } psim.clear_events(); } CHECK(p1.fuel >= p1.max_fuel - 0.5f); CHECK(p1.on_pit_mask == 2u); CHECK(p1.active_recharge_mask == 0u); CHECK(saw_pit_complete); // Ammo bay (49.0, 85.0): recharges only ammo p1.fuel = 20.0f; place_p1(49.0f, 85.0f); for (int t = 0; t < 60; ++t) psim.step(CraftInput{}, CraftInput{}, dt); CHECK(p1.ammo > 70.0f); CHECK(p1.shield == 20.0f); CHECK(p1.fuel <= 20.0f); // Shield bay (27.0, 98.5): recharges only shield p1.ammo = 20.0f; place_p1(27.0f, 98.5f); for (int t = 0; t < 60; ++t) psim.step(CraftInput{}, CraftInput{}, dt); CHECK(p1.shield > 65.0f); CHECK(p1.ammo == 20.0f); // Legacy Recovery Truck spawn (44.5, 58.5) must NOT recharge resources p1.fuel = 20.0f; p1.shield = 20.0f; p1.ammo = 20.0f; place_p1(44.5f, 58.5f); for (int t = 0; t < 30; ++t) psim.step(CraftInput{}, CraftInput{}, dt); CHECK(p1.shield == 20.0f); CHECK(p1.ammo == 20.0f); CHECK(p1.fuel <= 20.0f); CHECK(p1.active_recharge_mask == 0); // High above Fuel bay canopy (ground_y + 2.5f) must NOT recharge p1.fuel = 20.0f; place_p1(49.0f, 79.0f, 2.5f); psim.step(CraftInput{}, CraftInput{}, dt); CHECK(p1.active_recharge_mask == 0); CHECK(p1.fuel <= 20.0f); // Entering/resting on Fuel bay at 0 fuel refuels directly without Recovery Craft p1.fuel = 0.0f; place_p1(49.0f, 79.0f); for (int t = 0; t < 10; ++t) psim.step(CraftInput{}, CraftInput{}, dt); CHECK(p1.fuel > 5.0f); CHECK(p1.recovery_state == sim::RecoveryState::Active); } // Overlapping Shield + Ammo pitstop on Level 5 (84.5, 127.0) { assets::LevelData lvl5; CHECK(lvl5.load(vfs, 5)); sim::RaceSetup ps5; ps5.mode = sim::GameMode::SingleRace; ps5.track_number = 5; ps5.num_ai = 0; sim::RaceSim psim5; CHECK(psim5.start_race(lvl5, ps5)); for (int t = 0; t < 200; ++t) psim5.step(CraftInput{}, CraftInput{}, dt); auto& p1 = psim5.crafts_mut()[0]; p1.fuel = 20.0f; p1.shield = 20.0f; p1.ammo = 20.0f; p1.curr_pose.pos = Vec3(84.5f, psim5.level().sample_height_world(84.5f, 127.0f) + 0.30f, 127.0f); p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); for (int t = 0; t < 60; ++t) psim5.step(CraftInput{}, CraftInput{}, dt); CHECK(p1.shield > 65.0f); CHECK(p1.ammo > 70.0f); CHECK(p1.fuel <= 20.0f); } } std::cout << "[PASS] Authentic pitstop Fuel/Shield/Ammo chargers verified across all 9 tracks\n"; // 9. Original Explosions, Volumetric Smoke Trails, Wreck Plumes & Steam Vents { // 9a. Unguided missile smoke contrail + exhaust glow { sim::RaceSetup ms; ms.mode = sim::GameMode::SingleRace; ms.track_number = 1; ms.num_ai = 0; ms.fuel_enabled = false; sim::RaceSim msim; CHECK(msim.start_race(lvl1, ms)); for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt); auto& p1 = msim.crafts_mut()[0]; p1.lock_progress = 0.0f; p1.lock_target_id = -1; CraftInput fire; fire.fire_missile = true; msim.step(fire, CraftInput{}, dt); for (int t = 0; t < 10; ++t) msim.step(CraftInput{}, CraftInput{}, dt); bool saw_smoke = false, saw_glow = false; for (const auto& pb : msim.particles()) { if (pb.kind == sim::ParticleKind::Smoke) saw_smoke = true; if (pb.kind == sim::ParticleKind::AdditiveGlow) saw_glow = true; } CHECK(saw_smoke && saw_glow); } // 9b. Multi-layer explosion FX evolution (expanding smoke, falling debris) + kMaxParticles cap { sim::RaceSetup es; es.mode = sim::GameMode::DeathMatch; es.track_number = 1; es.num_ai = 1; es.fuel_enabled = false; sim::RaceSim esim; CHECK(esim.start_race(lvl1, es)); for (int t = 0; t < 200; ++t) esim.step(CraftInput{}, CraftInput{}, dt); auto& p1 = esim.crafts_mut()[0]; auto& tgt = esim.crafts_mut()[1]; tgt.curr_pose.pos = p1.curr_pose.pos + p1.forward_dir() * 4.0f; tgt.prev_pose = tgt.curr_pose; tgt.shield = 1.0f; p1.lock_progress = 1.0f; p1.lock_target_id = tgt.id; CraftInput fire; fire.fire_missile = true; for (int t = 0; t < 20 && tgt.recovery_state == sim::RecoveryState::Active; ++t) { esim.step(fire, CraftInput{}, dt); fire.fire_missile = false; } CHECK(tgt.recovery_state == sim::RecoveryState::CallingRepair); float max_smoke0 = 0.0f; float min_debris_vy0 = 1e9f; bool has_fireball = false, has_smoke = false, has_debris = false; for (const auto& pb : esim.particles()) { if (pb.kind == sim::ParticleKind::Fireball) has_fireball = true; if (pb.kind == sim::ParticleKind::Smoke) { has_smoke = true; max_smoke0 = std::max(max_smoke0, pb.size); } if (pb.kind == sim::ParticleKind::Debris) { has_debris = true; min_debris_vy0 = std::min(min_debris_vy0, pb.vel.y); } } CHECK(has_fireball && has_smoke && has_debris); for (int t = 0; t < 6; ++t) esim.step(CraftInput{}, CraftInput{}, dt); float max_smoke1 = 0.0f; float min_debris_vy1 = 1e9f; for (const auto& pb : esim.particles()) { if (pb.kind == sim::ParticleKind::Smoke) max_smoke1 = std::max(max_smoke1, pb.size); if (pb.kind == sim::ParticleKind::Debris) min_debris_vy1 = std::min(min_debris_vy1, pb.vel.y); } CHECK(max_smoke1 > max_smoke0); CHECK(min_debris_vy1 < min_debris_vy0); // Wreck plume continues emitting Fireball & Smoke long after initial explosion fades for (int t = 0; t < 55; ++t) esim.step(CraftInput{}, CraftInput{}, dt); CHECK(tgt.recovery_state != sim::RecoveryState::Active); bool wreck_fire = false, wreck_smoke = false; for (int t = 0; t < 25; ++t) { esim.step(CraftInput{}, CraftInput{}, dt); for (const auto& pb : esim.particles()) { if (pb.kind == sim::ParticleKind::Fireball) wreck_fire = true; if (pb.kind == sim::ParticleKind::Smoke) wreck_smoke = true; } } CHECK(wreck_fire && wreck_smoke); // Rapid wall-missile spam stays within kMaxParticles for (int t = 0; t < 35; ++t) { p1.missile_cd = 0.0f; p1.ammo = p1.max_ammo; CraftInput spam; spam.fire_missile = true; esim.step(spam, CraftInput{}, dt); } CHECK(esim.particles().size() <= sim::RaceSim::kMaxParticles); } // 9c. Damaged craft smoke trail & Level 4 continuous steam vent { assets::LevelData lvl4; CHECK(lvl4.load(vfs, 4)); sim::RaceSetup ss; ss.mode = sim::GameMode::SingleRace; ss.track_number = 4; ss.num_ai = 0; ss.fuel_enabled = false; sim::RaceSim ssim; CHECK(ssim.start_race(lvl4, ss)); for (int t = 0; t < 200; ++t) ssim.step(CraftInput{}, CraftInput{}, dt); auto& p1 = ssim.crafts_mut()[0]; p1.shield = p1.max_shield * 0.15f; for (int t = 0; t < 15; ++t) ssim.step(CraftInput{}, CraftInput{}, dt); bool damaged_smoke = false; for (const auto& pb : ssim.particles()) { if (pb.kind == sim::ParticleKind::Smoke) damaged_smoke = true; } CHECK(damaged_smoke); // Restore full shield, trigger Level 4 group 6 steam vents via (11.5, 77.5) p1.shield = p1.max_shield; for (int t = 0; t < 80; ++t) ssim.step(CraftInput{}, CraftInput{}, dt); // let old smoke expire p1.curr_pose.pos = Vec3(11.5f, ssim.level().sample_height_world(11.5f, 77.5f) + 0.30f, 77.5f); p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); ssim.step(CraftInput{}, CraftInput{}, dt); CHECK(!ssim.particles().empty()); // After 1.5s (> 1.15s initial puff lifetime), continuous steam vent still emits Smoke for (int t = 0; t < 90; ++t) ssim.step(CraftInput{}, CraftInput{}, dt); bool continuous_steam = false; for (const auto& pb : ssim.particles()) { if (pb.kind == sim::ParticleKind::Smoke) continuous_steam = true; } CHECK(continuous_steam); } } std::cout << "[PASS] Original explosions, smoke trails, wreck plumes & steam vents validated\n"; // 10. Authentic Type-5 Pickup Subtypes (upgrades, double caps, invincible, invisible) { assets::LevelData flat_lvl; flat_lvl.map.resize(assets::kMapWidth * assets::kMapHeight); for (auto& m : flat_lvl.map) { m.height = 2048; m.tex_or_col = 0; } sim::RaceSetup ps; ps.mode = sim::GameMode::DeathMatch; ps.track_number = 1; ps.num_ai = 1; ps.damage_enabled = true; ps.weapons_enabled = true; std::vector crafts(2); crafts[0].id = 0; crafts[0].vehicle_idx = 0; crafts[0].curr_pose.pos = Vec3(50.0f, 0.28f, 50.0f); crafts[0].prev_pose = crafts[0].curr_pose; crafts[0].fuel = 20.0f; crafts[0].shield = 20.0f; crafts[0].ammo = 20.0f; crafts[1].id = 1; crafts[1].vehicle_idx = 0; crafts[1].curr_pose.pos = Vec3(50.0f, 0.28f, 44.0f); crafts[1].curr_pose.yaw = 0.0f; // facing +Z toward craft 0 crafts[1].prev_pose = crafts[1].curr_pose; std::vector pks; for (uint8_t sub = 0; sub <= 13; ++sub) { sim::PickupItem pk; pk.entity_id = static_cast(sub + 1); pk.subtype = sub; pk.group = 1; pk.group_unlocked = true; pk.active = true; pk.pos = Vec3(50.0f, 0.30f, 50.0f); pks.push_back(pk); } std::vector props; std::vector parts; std::vector evs; std::vector projs; bool ro = false; int wid = -1; std::vector ins(2); sim::step_combat_and_world(ps, flat_lvl, crafts, ins, projs, pks, props, parts, evs, ro, wid, dt); CHECK(crafts[0].invincible_timer > 10.0f); CHECK(crafts[0].invisible_timer > 10.0f); CHECK(crafts[0].max_shield >= 199.0f && crafts[0].shield >= 199.0f); CHECK(crafts[0].max_ammo >= 199.0f && crafts[0].ammo >= 199.0f); CHECK(crafts[0].max_fuel >= 199.0f && crafts[0].fuel >= 199.0f); CHECK(crafts[0].minigun_level == 2); CHECK(crafts[0].missile_level == 2); CHECK(crafts[0].booster_level == 2); // Invisible blocks lock-on; Invincible blocks projectile damage crafts[1].lock_target_id = 0; crafts[1].lock_progress = 0.8f; float inv_sh = crafts[0].shield; ins[1].fire_minigun = true; for (int t = 0; t < 15; ++t) { sim::step_combat_and_world(ps, flat_lvl, crafts, ins, projs, pks, props, parts, evs, ro, wid, dt); CHECK(crafts[1].lock_target_id == -1); CHECK(crafts[1].lock_progress == 0.0f); } CHECK(crafts[0].shield == inv_sh); } std::cout << "[PASS] Authentic pickup subtypes (upgrades, double caps, invincible, invisible) validated\n"; // 11. Full 8-racer AI anti-stuck & progression check across all 9 tracks for (int l = 1; l <= 9; ++l) { assets::LevelData lvl; CHECK(lvl.load(vfs, l)); sim::RaceSetup ms; ms.mode = sim::GameMode::SingleRace; ms.track_number = l; ms.total_laps = 2; ms.difficulty = 1; // Medium AI with full combat, pitstops, morphing & pickups ms.num_ai = 7; sim::RaceSim msim; CHECK(msim.start_race(lvl, ms)); msim.crafts_mut()[0].autopilot = true; int stalled_ticks[8]{}; int max_stalled_ticks[8]{}; for (int t = 0; t < 9000 && !msim.race_finished(); ++t) { msim.step(CraftInput{}, CraftInput{}, dt); if (msim.countdown_active()) continue; for (size_t i = 0; i < msim.crafts().size(); ++i) { const auto& c = msim.crafts()[i]; if (c.recovery_state == sim::RecoveryState::Active) { int cx = static_cast(std::floor(c.curr_pose.pos.x)); int cz = static_cast(std::floor(c.curr_pose.pos.z)); CHECK(!msim.level().is_cell_solid_at_point( cx, cz, c.curr_pose.pos.x, c.curr_pose.pos.z, c.curr_pose.pos.y)); } if (c.finished || c.recovery_state != sim::RecoveryState::Active || c.active_recharge_mask != 0) { stalled_ticks[i] = 0; continue; } if (c.speed_horizontal() < 1.5f && c.race_time > 2.0f) { stalled_ticks[i]++; max_stalled_ticks[i] = std::max(max_stalled_ticks[i], stalled_ticks[i]); } else { stalled_ticks[i] = 0; } } } int progressed = 0; for (size_t i = 0; i < msim.crafts().size(); ++i) { const auto& c = msim.crafts()[i]; CHECK(max_stalled_ticks[i] < 420); // never stuck >= 7.0 seconds CHECK(c.checkpoints_passed >= 4); if (c.finished || c.lap >= 2) ++progressed; } CHECK(progressed >= 6); } std::cout << "[PASS] All 9 tracks 8-racer AI anti-stuck & progression validated\n"; // 12. Manual Track Recovery from pit, HUD stuck hint, anti-exploit, and SplitScreen P2 { sim::RaceSetup rs; rs.mode = sim::GameMode::SingleRace; rs.track_number = 1; rs.num_ai = 0; rs.fuel_enabled = true; sim::RaceSim rsim; CHECK(rsim.start_race(lvl1, rs)); // Still in countdown -> cannot trigger manual recovery CHECK(!rsim.request_track_recovery(0)); for (int t = 0; t < 200; ++t) rsim.step(CraftInput{}, CraftInput{}, dt); auto& p1 = rsim.crafts_mut()[0]; p1.curr_pose.pos = Vec3(32.5f, lvl1.sample_height_world(32.5f, 57.5f) + 0.28f, 57.5f); p1.curr_pose.yaw = kHalfPi; p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0.0f, 0.0f, 0.0f); p1.next_checkpoint = 1; p1.shield = p1.max_shield * 0.50f; p1.ammo = p1.max_ammo * 0.40f; p1.fuel = 42.0f; // Driving trapped inside pit triggers HUD stuck hint after ~2.0s CraftInput drive_fwd; drive_fwd.throttle = 1.0f; for (int t = 0; t < 135; ++t) rsim.step(drive_fwd, CraftInput{}, dt); CHECK(p1.curr_pose.pos.y < 0.0f); CHECK(p1.stuck_in_pit_hint); const float pre_shield = p1.shield; const float pre_ammo = p1.ammo; const float pre_fuel = p1.fuel; // Press manual recover key rsim.clear_events(); CraftInput rec_in; rec_in.recover_pressed = true; rsim.step(rec_in, CraftInput{}, dt); CHECK(p1.recovery_state == sim::RecoveryState::CallingRepair); CHECK(!p1.recovery_refill); CHECK(!p1.stuck_in_pit_hint); CHECK(!sim::get_recovery_visuals(rsim.crafts()).empty()); bool saw_recovery_banner = false; for (const auto& ev : rsim.events()) { if (ev.banner_text == "CALLING RECOVERY") saw_recovery_banner = true; } CHECK(saw_recovery_banner); // Wait ~1.75s for manual recovery sequence (1.6s) to airlift craft smoothly back to track bool saw_repairing = false; int repair_move_ticks = 0; float max_repair_step = 0.0f; float touchdown_step = -1.0f; const int cp_before_rec = p1.checkpoints_passed; sim::RecoveryState prev_rec_state = p1.recovery_state; Vec3 prev_rec_pos = p1.curr_pose.pos; for (int t = 0; t < 105; ++t) { rsim.step(CraftInput{}, CraftInput{}, dt); const float step_d = (p1.curr_pose.pos - prev_rec_pos).len(); auto step_rvis = sim::get_recovery_visuals(rsim.crafts()); if (p1.recovery_state != sim::RecoveryState::Active) { CHECK(step_rvis.size() == 1); } if (p1.recovery_state == sim::RecoveryState::Repairing) { saw_repairing = true; CHECK((step_rvis[0].pos - (p1.curr_pose.pos + Vec3(0.0f, 1.05f, 0.0f))).len() < 0.15f); if (prev_rec_state == sim::RecoveryState::Repairing) { if (step_d > 0.02f) ++repair_move_ticks; max_repair_step = std::max(max_repair_step, step_d); } } if (prev_rec_state == sim::RecoveryState::Repairing && p1.recovery_state == sim::RecoveryState::Active) { touchdown_step = step_d; } prev_rec_state = p1.recovery_state; prev_rec_pos = p1.curr_pose.pos; } CHECK(saw_repairing); CHECK(repair_move_ticks >= 20); CHECK(max_repair_step < 1.5f); CHECK(touchdown_step >= 0.0f && touchdown_step < 0.5f); CHECK(p1.checkpoints_passed == cp_before_rec); CHECK(p1.recovery_state == sim::RecoveryState::Active); CHECK(p1.deaths == 0); CHECK(p1.curr_pose.pos.y > 0.0f); CHECK(p1.curr_pose.pos.x < 25.0f); CHECK(p1.next_checkpoint == 1); CHECK(!p1.stuck_in_pit_hint); auto dep_vis0 = sim::get_recovery_visuals(rsim.crafts()); CHECK(dep_vis0.size() == 1); CHECK(dep_vis0[0].pos.y > p1.curr_pose.pos.y + 1.05f); for (int t = 0; t < 5; ++t) rsim.step(CraftInput{}, CraftInput{}, dt); auto dep_vis1 = sim::get_recovery_visuals(rsim.crafts()); CHECK(dep_vis1.size() == 1 && dep_vis1[0].pos.y > dep_vis0[0].pos.y); int px = static_cast(std::floor(p1.curr_pose.pos.x)); int pz = static_cast(std::floor(p1.curr_pose.pos.z)); CHECK(!lvl1.is_cell_solid_at_point(px, pz, p1.curr_pose.pos.x, p1.curr_pose.pos.z, p1.curr_pose.pos.y)); CHECK(!lvl1.is_cliff_blocking_at_y(px, pz, p1.curr_pose.pos.y)); // Resources were not freely topped off (anti-exploit) CHECK(std::abs(p1.shield - pre_shield) < 0.01f); CHECK(std::abs(p1.ammo - pre_ammo) < 0.01f); CHECK(p1.fuel <= pre_fuel + 0.01f); CHECK(p1.fuel < p1.max_fuel * 0.6f); // Cooldown prevents instant spam right after recovery completes CHECK(p1.recovery_cooldown > 0.5f); rsim.step(rec_in, CraftInput{}, dt); CHECK(p1.recovery_state == sim::RecoveryState::Active); // Departing drone finishes climbing away cleanly while craft races on for (int t = 0; t < 50; ++t) rsim.step(CraftInput{}, CraftInput{}, dt); CHECK(sim::get_recovery_visuals(rsim.crafts()).empty()); // Finished craft cannot recover p1.finished = true; CHECK(!rsim.request_track_recovery(0)); // SplitScreen P2 manual recovery & emergency minimal fuel floor (<5 -> 8) sim::RaceSetup ss; ss.mode = sim::GameMode::SplitScreen; ss.track_number = 1; ss.num_ai = 0; ss.fuel_enabled = true; sim::RaceSim ssim; CHECK(ssim.start_race(lvl1, ss)); for (int t = 0; t < 200; ++t) ssim.step(CraftInput{}, CraftInput{}, dt); auto& s_p2 = ssim.crafts_mut()[1]; s_p2.curr_pose.pos = Vec3(32.5f, lvl1.sample_height_world(32.5f, 57.5f) + 0.28f, 57.5f); s_p2.prev_pose = s_p2.curr_pose; s_p2.next_checkpoint = 1; s_p2.fuel = 1.0f; ssim.step(CraftInput{}, rec_in, dt); CHECK(s_p2.recovery_state == sim::RecoveryState::CallingRepair); for (int t = 0; t < 110; ++t) ssim.step(CraftInput{}, CraftInput{}, dt); CHECK(s_p2.recovery_state == sim::RecoveryState::Active); CHECK(s_p2.curr_pose.pos.y > 0.0f); CHECK(s_p2.curr_pose.pos.x < 25.0f); CHECK(s_p2.fuel >= 5.0f && s_p2.fuel < 15.0f); CHECK(ssim.request_track_recovery(0)); } std::cout << "[PASS] Manual Track Recovery from pit, stuck prompt, anti-exploit & SplitScreen P2 validated\n"; // 13. Step dt safety, Track 6 off-track AI recovery, DamageCraft & Level 9 morph & save fuzzing { // 13a. RaceSim::step ignores dt <= 0 and NaN cleanly sim::RaceSetup rs; rs.mode = sim::GameMode::SingleRace; rs.track_number = 1; rs.num_ai = 1; sim::RaceSim sim0; CHECK(sim0.start_race(lvl1, rs)); for (int t = 0; t < 200; ++t) sim0.step(CraftInput{}, CraftInput{}, dt); const Vec3 p_before = sim0.crafts()[0].curr_pose.pos; sim0.step(CraftInput{0.5f, 1.0f}, CraftInput{}, 0.0f); sim0.step(CraftInput{0.5f, 1.0f}, CraftInput{}, -0.1f); sim0.step(CraftInput{0.5f, 1.0f}, CraftInput{}, std::numeric_limits::quiet_NaN()); CHECK((sim0.crafts()[0].curr_pose.pos - p_before).len_sq() < 1e-8f); // 13b. AI circling behind Track 6 perimeter berm recovers via ai_wp_stall_timer in < 10s assets::LevelData lvl6; CHECK(lvl6.load(vfs, 6)); sim::RaceSetup rs6; rs6.mode = sim::GameMode::SingleRace; rs6.track_number = 6; rs6.num_ai = 1; sim::RaceSim sim6; CHECK(sim6.start_race(lvl6, rs6)); sim6.crafts_mut()[0].autopilot = true; for (int t = 0; t < 200; ++t) sim6.step(CraftInput{}, CraftInput{}, dt); auto& ai6 = sim6.crafts_mut()[1]; ai6.curr_pose.pos = Vec3(78.0f, lvl6.sample_height_world(78.0f, 15.0f) + 0.25f, 15.0f); ai6.prev_pose = ai6.curr_pose; ai6.vel = Vec3(5.0f, 0.0f, 0.0f); ai6.current_wp = 0; ai6.ai_target_wp = 1; ai6.next_checkpoint = 1; ai6.ai_stuck_timer = 0.0f; ai6.ai_progress_timer = 0.0f; ai6.ai_wp_stall_timer = 0.0f; ai6.ai_wp_best_dist = 1e9f; bool recovered = false; for (int t = 0; t < 600; ++t) { sim6.step(CraftInput{}, CraftInput{}, dt); if (ai6.checkpoints_passed >= 1 || ai6.curr_pose.pos.x > 84.0f || ai6.curr_pose.pos.z < 10.0f) { recovered = true; break; } } CHECK(recovered); // 13c. Invincible craft takes zero weapon/barrel damage & never heals from negative damage { std::vector cvec(2); cvec[0].id = 0; cvec[0].recovery_state = sim::RecoveryState::Active; cvec[0].curr_pose.pos = Vec3(10.0f, lvl1.sample_height_world(10.0f, 10.0f) + 0.25f, 10.0f); cvec[0].prev_pose = cvec[0].curr_pose; cvec[0].shield = 25.0f; cvec[0].max_shield = 100.0f; cvec[0].invincible_timer = 3.0f; cvec[1].id = 1; cvec[1].recovery_state = sim::RecoveryState::Active; cvec[1].curr_pose.pos = cvec[0].curr_pose.pos + Vec3(0.0f, 0.0f, -2.0f); cvec[1].prev_pose = cvec[1].curr_pose; std::vector pjs; sim::Projectile prj; prj.active = true; prj.owner_id = 1; prj.damage = 40.0f; prj.pos = cvec[0].curr_pose.pos + Vec3(0.0f, 0.0f, -0.5f); prj.vel = Vec3(0.0f, 0.0f, 60.0f); pjs.push_back(prj); std::vector pks; std::vector prs; std::vector pts; std::vector evs; std::vector ins(2); bool ro = false; int wid = -1; sim::step_combat_and_world(rs, lvl1, cvec, ins, pjs, pks, prs, pts, evs, ro, wid, dt); CHECK(std::abs(cvec[0].shield - 25.0f) < 1e-4f); } // 13d. Level 9 st=23 grp=1 permanent morph does not auto-activate and blank arena cells assets::LevelData lvl9; CHECK(lvl9.load(vfs, 9)); sim::RaceSetup rs9; rs9.mode = sim::GameMode::DeathMatch; rs9.track_number = 9; rs9.num_ai = 3; sim::RaceSim sim9; CHECK(sim9.start_race(lvl9, rs9)); for (int t = 0; t < 600; ++t) sim9.step(CraftInput{}, CraftInput{}, dt); int nontriv_arena_cells = 0; for (const auto& pad : sim9.level().pads) { int cx = static_cast(std::floor(pad.cx)); int cz = static_cast(std::floor(pad.cz)); const auto& cell = sim9.level().cell(cx, cz); if (cell.tex_or_col != 0) ++nontriv_arena_cells; } CHECK(nontriv_arena_cells == static_cast(sim9.level().pads.size())); // 13e. Corrupt/malformed save files safely rejected without mutating valid state std::filesystem::path bad_dir = std::filesystem::temp_directory_path() / "top_octane_bad_saves"; std::filesystem::create_directories(bad_dir); { std::ofstream ofs(bad_dir / "hiscores.dat"); ofs << "HIOCTANE_HISCORES_V2\n" << "TRACK 1 nan 1 DEADFISH 999\n"; } game::HighscoreTable ht; ht.load(bad_dir / "hiscores.dat"); for (const auto& rec : ht.tracks) { CHECK(std::isfinite(rec.best_lap)); CHECK(std::isfinite(rec.best_race)); } { std::ofstream ofs(bad_dir / "clone_t1.dat"); ofs << "INVALID_MAGIC 1 -9 99 nan 9999999\n"; } sim::CloneRecording cre; CHECK(!game::load_clone_recording(bad_dir, 1, cre)); std::filesystem::remove_all(bad_dir); std::cout << "[PASS] Gameplay dt/AI-basin/invincible/Level9-morph & save hardening validated\n"; } // 14. DeathMatch suppresses "FINAL LAP" and "WRONG WAY" warnings while SingleRace keeps both { sim::RaceSetup dm; dm.mode = sim::GameMode::DeathMatch; dm.track_number = 1; dm.num_ai = 0; dm.total_laps = 2; dm.deathmatch_kill_limit = 5; dm.weapons_enabled = false; dm.fuel_enabled = false; sim::RaceSim dm_sim; CHECK(dm_sim.start_race(lvl1, dm)); for (int t = 0; t < 200; ++t) dm_sim.step(CraftInput{}, CraftInput{}, dt); dm_sim.clear_events(); dm_sim.crafts_mut()[0].autopilot = true; bool dm_saw_final_lap = false; for (int t = 0; t < 2400 && dm_sim.crafts()[0].lap < 3; ++t) { dm_sim.step(CraftInput{}, CraftInput{}, dt); for (const auto& ev : dm_sim.events()) { if (ev.banner_text == "FINAL LAP") dm_saw_final_lap = true; } dm_sim.clear_events(); } CHECK(dm_sim.crafts()[0].lap >= 3); CHECK(!dm_sim.crafts()[0].finished); CHECK(!dm_saw_final_lap); sim::RaceSetup sr; sr.mode = sim::GameMode::SingleRace; sr.track_number = 1; sr.num_ai = 0; sr.total_laps = 2; sr.weapons_enabled = false; sr.fuel_enabled = false; sim::RaceSim sr_sim; CHECK(sr_sim.start_race(lvl1, sr)); for (int t = 0; t < 200; ++t) sr_sim.step(CraftInput{}, CraftInput{}, dt); sr_sim.clear_events(); sr_sim.crafts_mut()[0].autopilot = true; bool sr_saw_final_lap = false; for (int t = 0; t < 1600 && !sr_saw_final_lap; ++t) { sr_sim.step(CraftInput{}, CraftInput{}, dt); for (const auto& ev : sr_sim.events()) { if (ev.banner_text == "FINAL LAP") sr_saw_final_lap = true; } sr_sim.clear_events(); } CHECK(sr_sim.crafts()[0].lap >= 2); CHECK(sr_saw_final_lap); auto drive_wrong_way = [&](sim::RaceSim& sim_obj) { auto& c = sim_obj.crafts_mut()[0]; c.autopilot = false; const size_t n_wp = lvl1.main_waypoints.size(); const size_t wp = static_cast(std::clamp(c.current_wp, 0, static_cast(n_wp - 1))); const auto& w0 = lvl1.main_waypoints[wp]; const auto& w1 = lvl1.main_waypoints[(wp + 1) % n_wp]; Vec2 dir = Vec2(w1.x - w0.x, w1.z - w0.z).normalized(); c.curr_pose.yaw = std::atan2(-dir.x, -dir.y); c.vel = Vec3(-dir.x, 0.0f, -dir.y) * 10.0f; c.prev_pose = c.curr_pose; CraftInput rev_in; rev_in.throttle = 1.0f; for (int t = 0; t < 5; ++t) { sim_obj.step(rev_in, CraftInput{}, dt); } }; drive_wrong_way(dm_sim); CHECK(dm_sim.crafts()[0].speed_horizontal() > 3.0f); CHECK(!dm_sim.crafts()[0].wrong_way); drive_wrong_way(sr_sim); CHECK(sr_sim.crafts()[0].speed_horizontal() > 3.0f); CHECK(sr_sim.crafts()[0].wrong_way); std::cout << "[PASS] DeathMatch Final Lap & Wrong Way suppression validated\n"; } // 15. Perpendicular Checkpoint Normals, Bidirectional Gates, Morphed Shortcuts & Pickup Deduplication { auto test_gate_crossing = [&](int track_num, int cp_idx, Vec2 start_xz, Vec2 dir_xz, int expected_after, int steps = 8) -> bool { assets::LevelData lvl; if (!lvl.load(vfs, track_num)) return false; sim::RaceSetup setup; setup.mode = sim::GameMode::SingleRace; setup.track_number = track_num; setup.num_ai = 0; setup.total_laps = 2; setup.weapons_enabled = false; setup.fuel_enabled = false; setup.damage_enabled = false; sim::RaceSim sim_obj; if (!sim_obj.start_race(lvl, setup)) return false; for (int t = 0; t < 200; ++t) sim_obj.step(CraftInput{}, CraftInput{}, dt); auto& p1 = sim_obj.crafts_mut()[0]; p1.autopilot = false; p1.next_checkpoint = cp_idx; p1.checkpoints_passed = cp_idx; Vec2 d = dir_xz.normalized(); p1.curr_pose.pos = Vec3(start_xz.x, sim_obj.level().sample_height_world(start_xz.x, start_xz.y) + 0.30f, start_xz.y); p1.curr_pose.yaw = std::atan2(d.x, d.y); p1.prev_pose = p1.curr_pose; for (int t = 0; t < steps; ++t) { p1.vel.x = d.x * 18.0f; p1.vel.z = d.y * 18.0f; sim_obj.step(CraftInput{}, CraftInput{}, dt); } return sim_obj.crafts()[0].next_checkpoint == expected_after; }; // 15a. Previously failing forward crossings & reverse-crossing rejection on fixed gates CHECK(test_gate_crossing(6, 9, Vec2(9.2f, 89.6f), Vec2(0.8f, 0.5f), 10)); // L6 cp[9] ESE waypoint crossing CHECK(test_gate_crossing(6, 9, Vec2(10.8f, 90.0f), Vec2(-1.0f, 0.0f), 9)); // L6 cp[9] reverse West rejected CHECK(test_gate_crossing(3, 1, Vec2(18.5f, 57.6f), Vec2(-0.7f, -0.7f), 2)); // L3 cp[1] NW diagonal exit CHECK(test_gate_crossing(4, 6, Vec2(44.4f, 123.8f), Vec2(0.5f, 0.85f), 7)); // L4 cp[6] angled SE crossing CHECK(test_gate_crossing(4, 9, Vec2(24.6f, 79.5f), Vec2(-0.5f, 0.85f), 0)); // L4 cp[9] angled SW crossing CHECK(test_gate_crossing(8, 1, Vec2(97.5f, 87.2f), Vec2(0.0f, 1.0f), 2)); // L8 cp[1] Southbound hairpin entry CHECK(test_gate_crossing(8, 4, Vec2(17.4f, 88.6f), Vec2(0.7f, -0.7f), 5)); // L8 cp[4] NE hairpin exit CHECK(test_gate_crossing(8, 4, Vec2(19.3f, 85.0f), Vec2(-1.0f, 0.0f), 5, 3)); // L8 cp[4] apex tile strip graze CHECK(test_gate_crossing(8, 4, Vec2(22.0f, 85.0f), Vec2(0.0f, 1.0f), 4, 4)); // L8 cp[4] East of apex strip does not fire // 15b. Level 7 chained mine shortcut (trig#278 -> trig#279 -> trig#282) hits cp[2] and cp[3] { assets::LevelData lvl7; CHECK(lvl7.load(vfs, 7)); sim::RaceSetup ms; ms.track_number = 7; ms.num_ai = 0; ms.total_laps = 2; ms.fuel_enabled = false; ms.damage_enabled = false; sim::RaceSim msim; CHECK(msim.start_race(lvl7, ms)); for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt); const uint16_t ramp_before = msim.level().cell(33, 42).height; const uint16_t ramp_src = msim.level().cell(39, 49).height; const uint16_t ridge_before = msim.level().cell(45, 40).height; const uint16_t ridge_src = msim.level().cell(45, 49).height; CHECK(ramp_before > ramp_src); CHECK(ridge_before > 2048u && ridge_src < 2048u); auto& p1 = msim.crafts_mut()[0]; p1.autopilot = false; // Visiting trig#279 before trig#278 arms group 5 must NOT morph M[3] p1.curr_pose.pos = Vec3(32.0f, msim.level().sample_height_world(32.0f, 42.5f) + 0.30f, 42.5f); p1.prev_pose = p1.curr_pose; for (int t = 0; t < 40; ++t) msim.step(CraftInput{}, CraftInput{}, dt); CHECK(msim.level().cell(33, 42).height == ramp_before); // Crossing trig#278 (94..99, 56..57) arms trig#279 p1.curr_pose.pos = Vec3(95.5f, msim.level().sample_height_world(95.5f, 56.5f) + 0.30f, 56.5f); p1.prev_pose = p1.curr_pose; for (int t = 0; t < 10; ++t) msim.step(CraftInput{}, CraftInput{}, dt); // Now trig#279 fires on Lap 2 and flattens M[3] step at (33, 42) p1.curr_pose.pos = Vec3(32.0f, msim.level().sample_height_world(32.0f, 42.5f) + 0.30f, 42.5f); p1.prev_pose = p1.curr_pose; for (int t = 0; t < 45; ++t) msim.step(CraftInput{}, CraftInput{}, dt); CHECK(msim.level().cell(33, 42).height == ramp_src); // Missile hit on trig#282 blasts ridge M[4] (44..47, 39..42) p1.curr_pose.pos = Vec3(45.5f, msim.level().sample_height_world(45.5f, 43.0f) + 0.30f, 43.0f); p1.curr_pose.yaw = kPi; p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); p1.missile_cd = 0.0f; for (int t = 0; t < 45; ++t) { CraftInput fire; fire.fire_missile = (t == 0); msim.step(fire, CraftInput{}, dt); } CHECK(msim.level().cell(45, 40).height == ridge_src); // Driving into mine entry crosses cp[2] (z=46) and exiting north rejoins before cp[3] (x=52) p1.next_checkpoint = 2; p1.checkpoints_passed = 2; p1.curr_pose.pos = Vec3(22.0f, msim.level().sample_height_world(22.0f, 46.8f) + 0.30f, 46.8f); p1.curr_pose.yaw = kPi; p1.prev_pose = p1.curr_pose; for (int t = 0; t < 10; ++t) { p1.vel = Vec3(0.0f, 0.0f, -18.0f); msim.step(CraftInput{}, CraftInput{}, dt); } CHECK(msim.crafts()[0].next_checkpoint == 3); p1.curr_pose.pos = Vec3(51.2f, msim.level().sample_height_world(51.2f, 24.5f) + 0.30f, 24.5f); p1.curr_pose.yaw = kPi * 0.5f; p1.prev_pose = p1.curr_pose; for (int t = 0; t < 10; ++t) { p1.vel = Vec3(18.0f, 0.0f, 0.0f); msim.step(CraftInput{}, CraftInput{}, dt); } CHECK(msim.crafts()[0].next_checkpoint == 4); } // 15c. Morph pickup relocation deduplicates overlapping pickups (L4 M[1] & L5 M[2]) auto check_no_stacked_pickups = [&](const sim::RaceSim& s) -> bool { for (size_t i = 0; i < s.pickups().size(); ++i) { const auto& a = s.pickups()[i]; if (!a.group_unlocked) continue; for (size_t j = i + 1; j < s.pickups().size(); ++j) { const auto& b = s.pickups()[j]; if (!b.group_unlocked) continue; float dx = a.pos.x - b.pos.x; float dz = a.pos.z - b.pos.z; if (dx * dx + dz * dz < 0.25f) return false; } } return true; }; { assets::LevelData lvl4; CHECK(lvl4.load(vfs, 4)); sim::RaceSetup ms4; ms4.track_number = 4; ms4.num_ai = 0; sim::RaceSim sim4; CHECK(sim4.start_race(lvl4, ms4)); for (int t = 0; t < 200; ++t) sim4.step(CraftInput{}, CraftInput{}, dt); auto& p1 = sim4.crafts_mut()[0]; p1.curr_pose.pos = Vec3(69.5f, sim4.level().sample_height_world(69.5f, 90.0f) + 0.30f, 90.0f); p1.curr_pose.yaw = kPi; p1.prev_pose = p1.curr_pose; p1.vel = Vec3(0, 0, 0); for (int t = 0; t < 60; ++t) { CraftInput fire; fire.fire_missile = (t == 0); sim4.step(fire, CraftInput{}, dt); } CHECK(check_no_stacked_pickups(sim4)); int vault_unlocked = 0; for (const auto& pk : sim4.pickups()) { if (pk.group_unlocked && pk.pos.x >= 64.0f && pk.pos.x <= 77.0f && pk.pos.z >= 71.0f && pk.pos.z <= 89.0f) { ++vault_unlocked; } } CHECK(vault_unlocked == 8); } { assets::LevelData lvl5; CHECK(lvl5.load(vfs, 5)); sim::RaceSetup ms5; ms5.track_number = 5; ms5.num_ai = 0; sim::RaceSim sim5; CHECK(sim5.start_race(lvl5, ms5)); for (int t = 0; t < 200; ++t) sim5.step(CraftInput{}, CraftInput{}, dt); auto& p1 = sim5.crafts_mut()[0]; p1.curr_pose.pos = Vec3(17.0f, sim5.level().sample_height_world(17.0f, 134.0f) + 0.30f, 134.0f); p1.prev_pose = p1.curr_pose; for (int t = 0; t < 45; ++t) sim5.step(CraftInput{}, CraftInput{}, dt); CHECK(check_no_stacked_pickups(sim5)); int alcove_unlocked = 0; for (const auto& pk : sim5.pickups()) { if (pk.group_unlocked && pk.pos.x >= 15.0f && pk.pos.x <= 20.0f && pk.pos.z >= 133.0f && pk.pos.z <= 137.0f) { ++alcove_unlocked; } } CHECK(alcove_unlocked == 4); } std::cout << "[PASS] Perpendicular checkpoints, bidirectional hairpins, L7 mine morph & pickup deduplication validated\n"; } // 16. Championship completion opens PostRace directly on overall championship leaderboard with exact tie-breakers { CHECK(game::initial_post_race_page(sim::GameMode::Championship, false) == 0); CHECK(game::initial_post_race_page(sim::GameMode::Championship, true) == 2); CHECK(game::initial_post_race_page(sim::GameMode::SingleRace, true) == 0); CHECK(game::initial_post_race_page(sim::GameMode::DeathMatch, true) == 0); game::ChampionshipState ch; ch.start_new("ACE", 0, 0, 1, 2); CHECK(!ch.is_complete()); CHECK(game::initial_post_race_page(sim::GameMode::Championship, ch.is_complete()) == 0); auto make_results = [&](const std::array& places, const std::array& kills) { std::vector out(8); for (int i = 0; i < 8; ++i) { out[static_cast(i)].id = i; out[static_cast(i)].is_human = (i == 0); out[static_cast(i)].player_index = (i == 0) ? 0 : -1; out[static_cast(i)].placement = places[static_cast(i)]; out[static_cast(i)].kills = kills[static_cast(i)]; } return out; }; // Race 1 (places for slots 0..7): slot 1=1st(10,1W), slot 2=2nd(6), slot 0=3rd(4), slot 3=4th(3), slot 4=5th(2), slot 5=6th(1), 6=7th, 7=8th ch.record_race_results(make_results({3, 1, 2, 4, 5, 6, 7, 8}, {1, 2, 6, 2, 0, 0, 3, 1})); CHECK(ch.current_track == 2); CHECK(!ch.is_complete()); CHECK(game::initial_post_race_page(sim::GameMode::Championship, ch.is_complete()) == 0); // Race 2 creates controlled ties: // - Slot 1: 12 pts, 1 win, 2 kills // - Slot 4: 12 pts, 1 win, 0 kills (loses to Slot 1 on kills, beats Slot 2 on wins) // - Slot 2: 12 pts, 0 wins, 6 kills // - Slot 3: 7 pts, 0 wins, 6 kills // - Slot 0: 7 pts, 0 wins, 2 kills (loses to Slot 3 on kills) ch.record_race_results(make_results({4, 5, 2, 3, 1, 6, 7, 8}, {1, 0, 0, 4, 0, 0, 0, 0})); CHECK(ch.is_complete()); CHECK(game::initial_post_race_page(sim::GameMode::Championship, ch.is_complete()) == 2); const std::array expected_order{1, 4, 2, 3, 0, 5, 6, 7}; const auto order = ch.sorted_driver_indices(); for (size_t i = 0; i < order.size(); ++i) { CHECK(order[i] == expected_order[i]); } std::cout << "[PASS] Championship completion leaderboard default page & tie-break ranking validated\n"; } // 17. Difficulty pacing & combat aggressiveness ordering (Easy / Medium / Hard) { struct PaceResult { bool finished = false; float race_time = 0.0f; }; auto run_solo_2lap = [&](int difficulty) -> PaceResult { sim::RaceSetup setup; setup.mode = sim::GameMode::SingleRace; setup.track_number = 1; setup.total_laps = 2; setup.num_ai = 0; setup.difficulty = difficulty; setup.p1_vehicle = 0; // KD-1 setup.weapons_enabled = false; setup.damage_enabled = false; sim::RaceSim sim; if (!sim.start_race(lvl1, setup)) return {}; const int max_ticks = static_cast(120.0f / dt); for (int t = 0; t < max_ticks && !sim.race_finished(); ++t) { CraftInput p1 = sim::compute_ai_input(sim.crafts_mut()[0], sim.level(), sim.crafts(), setup.difficulty, dt); sim.step(p1, CraftInput{}, dt); } return {sim.race_finished(), sim.crafts()[0].race_time}; }; const PaceResult easy = run_solo_2lap(0); const PaceResult med = run_solo_2lap(1); const PaceResult hard = run_solo_2lap(2); CHECK(easy.finished); CHECK(med.finished); CHECK(hard.finished); std::cout << " Solo 2-lap KD-1 (Track 1): Easy=" << easy.race_time << "s, Medium=" << med.race_time << "s, Hard=" << hard.race_time << "s\n"; CHECK(easy.race_time > med.race_time + 1.5f); CHECK(med.race_time > hard.race_time + 2.5f); struct CombatResult { bool finished = false; int ai_shots = 0; }; auto run_combat_2lap_shots = [&](int difficulty) -> CombatResult { sim::RaceSetup setup; setup.mode = sim::GameMode::SingleRace; setup.track_number = 1; setup.total_laps = 2; setup.num_ai = 7; setup.difficulty = difficulty; setup.p1_vehicle = 0; // KD-1 setup.weapons_enabled = true; setup.damage_enabled = true; sim::RaceSim sim; if (!sim.start_race(lvl1, setup)) return {}; const int max_ticks = static_cast(120.0f / dt); for (int t = 0; t < max_ticks && !sim.race_finished(); ++t) { CraftInput p1 = sim::compute_ai_input(sim.crafts_mut()[0], sim.level(), sim.crafts(), setup.difficulty, dt); sim.step(p1, CraftInput{}, dt); } int total_ai_shots = 0; for (size_t i = 1; i < sim.crafts().size(); ++i) { total_ai_shots += sim.crafts()[i].shots_fired; } return {sim.race_finished(), total_ai_shots}; }; const CombatResult easy_c = run_combat_2lap_shots(0); const CombatResult med_c = run_combat_2lap_shots(1); const CombatResult hard_c = run_combat_2lap_shots(2); CHECK(easy_c.finished); CHECK(med_c.finished); CHECK(hard_c.finished); std::cout << " 8-racer 2-lap AI shots (Track 1): Easy=" << easy_c.ai_shots << ", Medium=" << med_c.ai_shots << ", Hard=" << hard_c.ai_shots << "\n"; CHECK(static_cast(med_c.ai_shots) < static_cast(hard_c.ai_shots) * 0.75f); CHECK(easy_c.ai_shots <= hard_c.ai_shots); std::cout << "[PASS] Difficulty pacing & combat aggression cleanly separated (Easy / Medium / Hard)\n"; } return 0; }