wip reduction TrictracAction
This commit is contained in:
parent
5370eb4307
commit
ec6ae26d38
9 changed files with 418 additions and 48 deletions
|
|
@ -3,7 +3,7 @@ use log::info;
|
|||
use std::path::Path;
|
||||
use store::MoveRules;
|
||||
|
||||
use crate::dqn::dqn_common::{get_valid_actions, sample_valid_action, TrictracAction};
|
||||
use crate::dqn::dqn_common_big::{get_valid_actions, sample_valid_action, TrictracAction};
|
||||
use crate::dqn::simple::dqn_model::SimpleNeuralNetwork;
|
||||
|
||||
/// Stratégie DQN pour le bot - ne fait que charger et utiliser un modèle pré-entraîné
|
||||
|
|
|
|||
|
|
@ -117,8 +117,8 @@ impl BotStrategy for DqnBurnStrategy {
|
|||
// Utiliser le DQN pour choisir le mouvement
|
||||
if let Some(TrictracAction::Move {
|
||||
dice_order,
|
||||
from1,
|
||||
from2,
|
||||
checker1,
|
||||
checker2,
|
||||
}) = self.get_dqn_action()
|
||||
{
|
||||
let dicevals = self.game.dice.values;
|
||||
|
|
@ -128,15 +128,33 @@ impl BotStrategy for DqnBurnStrategy {
|
|||
(dicevals.1, dicevals.0)
|
||||
};
|
||||
|
||||
let from1 = self
|
||||
.game
|
||||
.board
|
||||
.get_checker_field(&self.color, checker1 as u8)
|
||||
.unwrap_or(0);
|
||||
|
||||
if from1 == 0 {
|
||||
// empty move
|
||||
dice1 = 0;
|
||||
}
|
||||
let mut to1 = from1 + dice1 as usize;
|
||||
if 24 < to1 {
|
||||
let mut to1 = if self.color == Color::White {
|
||||
from1 + dice1 as usize
|
||||
} else {
|
||||
from1 - dice1 as usize
|
||||
};
|
||||
if 24 < to1 || to1 < 0 {
|
||||
// sortie
|
||||
to1 = 0;
|
||||
}
|
||||
|
||||
let checker_move1 = store::CheckerMove::new(from1, to1).unwrap_or_default();
|
||||
|
||||
let mut tmp_board = self.game.board.clone();
|
||||
tmp_board.move_checker(&self.color, checker_move1);
|
||||
let from2 = tmp_board
|
||||
.get_checker_field(&self.color, checker2 as u8)
|
||||
.unwrap_or(0);
|
||||
if from2 == 0 {
|
||||
// empty move
|
||||
dice2 = 0;
|
||||
|
|
@ -147,6 +165,13 @@ impl BotStrategy for DqnBurnStrategy {
|
|||
to2 = 0;
|
||||
}
|
||||
|
||||
// Gestion prise de coin par puissance
|
||||
let opp_rest_field = 13;
|
||||
if to1 == opp_rest_field && to2 == opp_rest_field {
|
||||
to1 -= 1;
|
||||
to2 -= 1;
|
||||
}
|
||||
|
||||
let checker_move1 = CheckerMove::new(from1, to1).unwrap_or_default();
|
||||
let checker_move2 = CheckerMove::new(from2, to2).unwrap_or_default();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue