test(@projects/@magic-civilization): 🐛 update stale Rust tests for DeclareWar action + player_index capping
- full_game_transcript: add the missing `Action::DeclareWar { target }` arm to the
signature_of match (the tactical AI gained DeclareWar so AI-vs-AI leaves perpetual
peace — non-exhaustive match broke compilation).
- ai_controller: player_index_to_slot now caps out-of-range indices to the last slot
(graceful degradation for >MAX_PLAYERS games) instead of erroring; assert the cap.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0ae4728242
commit
f293c31d07
2 changed files with 8 additions and 3 deletions
|
|
@ -27,9 +27,13 @@ fn constructor_smoke_player_index_bounds() {
|
|||
player_index_to_slot((MAX_PLAYERS - 1) as i64).unwrap(),
|
||||
MAX_PLAYERS - 1
|
||||
);
|
||||
assert!(
|
||||
player_index_to_slot(MAX_PLAYERS as i64).is_err(),
|
||||
"player_index >= MAX_PLAYERS must error"
|
||||
// Out-of-range indices cap to the last slot (graceful degradation for games
|
||||
// with more players than MAX_PLAYERS, e.g. the 5-clan demo) rather than
|
||||
// erroring and taking no actions — see player_index_to_slot in ai.rs.
|
||||
assert_eq!(
|
||||
player_index_to_slot(MAX_PLAYERS as i64).unwrap(),
|
||||
MAX_PLAYERS - 1,
|
||||
"player_index >= MAX_PLAYERS must cap to the last slot"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1372,6 +1372,7 @@ fn ai_action_signature(action: &mc_ai::tactical::Action) -> String {
|
|||
A::DeploySiege { .. } => "deploy_siege".into(),
|
||||
A::PackSiege { .. } => "pack_siege".into(),
|
||||
A::Bombard { .. } => "bombard".into(),
|
||||
A::DeclareWar { target } => format!("declare_war:{target}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue