From eae2a1acd8cc8d6f907332f8bcfadddfa5396629 Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Mon, 1 Sep 2025 14:47:09 +0200 Subject: [PATCH] feat: wip TrictracBoard --- bot/Cargo.toml | 2 +- bot/src/training_common.rs | 9 +++++---- bot/src/trictrac_board.rs | 7 ++++++- doc/refs/inspirations.md | 2 ++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bot/Cargo.toml b/bot/Cargo.toml index 21e0128..ce1ee5a 100644 --- a/bot/Cargo.toml +++ b/bot/Cargo.toml @@ -20,7 +20,7 @@ serde_json = "1.0" store = { path = "../store" } rand = "0.8" env_logger = "0.10" -burn = { version = "0.17", features = ["ndarray", "autodiff"] } +burn = { version = "0.18", features = ["ndarray", "autodiff"] } burn-rl = { git = "https://github.com/yunjhongwu/burn-rl-examples.git", package = "burn-rl" } log = "0.4.20" confy = "1.0.0" diff --git a/bot/src/training_common.rs b/bot/src/training_common.rs index 0a581dd..aa54c16 100644 --- a/bot/src/training_common.rs +++ b/bot/src/training_common.rs @@ -4,6 +4,10 @@ use std::fmt::{Debug, Display, Formatter}; use serde::{Deserialize, Serialize}; use store::{CheckerMove, GameEvent, GameState}; +// 1 (Roll) + 1 (Go) + mouvements possibles +// Pour les mouvements : 2*16*16 = 514 (choix du dé + choix de la dame 0-15 pour chaque from) +pub const ACTION_SPACE_SIZE: usize = 514; + /// Types d'actions possibles dans le jeu #[derive(Debug, Copy, Clone, Eq, Serialize, Deserialize, PartialEq)] pub enum TrictracAction { @@ -158,10 +162,7 @@ impl TrictracAction { /// Retourne la taille de l'espace d'actions total pub fn action_space_size() -> usize { - // 1 (Roll) + 1 (Go) + mouvements possibles - // Pour les mouvements : 2*25*25 = 1250 (choix du dé + position 0-24 pour chaque from) - // Mais on peut optimiser en limitant aux positions valides (1-24) - 2 + (2 * 16 * 16) // = 514 + ACTION_SPACE_SIZE } // pub fn to_game_event(&self, player_id: PlayerId, dice: Dice) -> GameEvent { diff --git a/bot/src/trictrac_board.rs b/bot/src/trictrac_board.rs index 80350b8..5e9fc7f 100644 --- a/bot/src/trictrac_board.rs +++ b/bot/src/trictrac_board.rs @@ -6,10 +6,11 @@ use board_game::board::{ use board_game::impl_unit_symmetry_board; use internal_iterator::InternalIterator; use std::fmt; +use std::hash::Hash; use std::ops::ControlFlow; use store::Color; -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct TrictracBoard(crate::GameState); impl Default for TrictracBoard { @@ -78,6 +79,10 @@ impl BoardGameBoard for TrictracBoard { } impl TrictracBoard { + pub fn inner(&self) -> &crate::GameState { + &self.0 + } + pub fn to_fen(&self) -> String { self.0.to_string_id() } diff --git a/doc/refs/inspirations.md b/doc/refs/inspirations.md index 2217ed7..a94aa87 100644 --- a/doc/refs/inspirations.md +++ b/doc/refs/inspirations.md @@ -22,6 +22,7 @@ nombres aléatoires avec seed : parallel ) - front : yew + tauri + - egui - @@ -31,6 +32,7 @@ nombres aléatoires avec seed : - (wasm, rooms) - +- ## Others