AI masters build only rooms and towers they have researched
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e1a8e2c49c
commit
cccb6b64c3
2 files changed
+41
-1
No files matched your search
@@ -600,6 +600,37 @@ mod tests {
|
||||
g
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_ai_partner_builds_only_what_is_researched() {
|
||||
// the first missions of both co-op campaigns: no library, no forge yet
|
||||
let doc = crate::editor::coop_campaign::coop_campaign();
|
||||
let games = [
|
||||
crate::campaign::start_editor_coop_mission(&doc.missions[0], 0, 77),
|
||||
crate::campaign::start_coop_mission(crate::campaign::coop_mission_indexes()[0], None),
|
||||
];
|
||||
let lib = crate::ui::TOOLS.iter().position(|&t| t == crate::ui::Tool::Room(4)).unwrap();
|
||||
let forge = crate::ui::TOOLS.iter().position(|&t| t == crate::ui::Tool::Room(8)).unwrap();
|
||||
for mut g in games {
|
||||
g.coop = true;
|
||||
assert!(g.start_match(&[0, 2], 0));
|
||||
g.sync_ai_sides(&[2], 1);
|
||||
g.end_match();
|
||||
let mine_knows = (g.tool_allowed(lib), g.tool_allowed(forge));
|
||||
for _ in 0..(10 * 60 * 20) {
|
||||
g.update(0.05);
|
||||
}
|
||||
let owner = Owner::of_side(2);
|
||||
let has = |k: Kind| g.map.t.iter().any(|t| t.kind == k && t.owner == owner);
|
||||
if !mine_knows.0 {
|
||||
assert!(!has(Kind::Library), "the partner has no library either");
|
||||
}
|
||||
if !mine_knows.1 {
|
||||
assert!(!has(Kind::Forge), "the partner has no forge either");
|
||||
}
|
||||
assert!(has(Kind::Lair) || has(Kind::Treasury), "but builds what it knows");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn imps_take_ground_from_enemies_but_never_from_allies() {
|
||||
let mut g = offline_league_game();
|
||||
|
||||
Reference in new issue
Block a user