fix: remove panics on cxx hot path
This commit is contained in:
parent
72eb60f322
commit
953b5f451a
5 changed files with 51 additions and 48 deletions
|
|
@ -259,15 +259,13 @@ impl TrictracEnvironment {
|
|||
use training_common::get_valid_actions;
|
||||
|
||||
// Obtenir les actions valides dans le contexte actuel
|
||||
let valid_actions = get_valid_actions(game_state);
|
||||
|
||||
if valid_actions.is_empty() {
|
||||
return None;
|
||||
if let Ok(valid_actions) = get_valid_actions(game_state) {
|
||||
// Mapper l'index d'action sur une action valide
|
||||
let action_index = (action.index as usize) % valid_actions.len();
|
||||
Some(valid_actions[action_index].clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
// Mapper l'index d'action sur une action valide
|
||||
let action_index = (action.index as usize) % valid_actions.len();
|
||||
Some(valid_actions[action_index].clone())
|
||||
}
|
||||
|
||||
/// Exécute une action Trictrac dans le jeu
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue