feat: wip TrictracBoard

This commit is contained in:
Henri Bourcereau 2025-09-01 14:47:09 +02:00
parent 4e299b04e2
commit eae2a1acd8
4 changed files with 14 additions and 6 deletions

View file

@ -20,7 +20,7 @@ serde_json = "1.0"
store = { path = "../store" } store = { path = "../store" }
rand = "0.8" rand = "0.8"
env_logger = "0.10" 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" } burn-rl = { git = "https://github.com/yunjhongwu/burn-rl-examples.git", package = "burn-rl" }
log = "0.4.20" log = "0.4.20"
confy = "1.0.0" confy = "1.0.0"

View file

@ -4,6 +4,10 @@ use std::fmt::{Debug, Display, Formatter};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use store::{CheckerMove, GameEvent, GameState}; 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 /// Types d'actions possibles dans le jeu
#[derive(Debug, Copy, Clone, Eq, Serialize, Deserialize, PartialEq)] #[derive(Debug, Copy, Clone, Eq, Serialize, Deserialize, PartialEq)]
pub enum TrictracAction { pub enum TrictracAction {
@ -158,10 +162,7 @@ impl TrictracAction {
/// Retourne la taille de l'espace d'actions total /// Retourne la taille de l'espace d'actions total
pub fn action_space_size() -> usize { pub fn action_space_size() -> usize {
// 1 (Roll) + 1 (Go) + mouvements possibles ACTION_SPACE_SIZE
// 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
} }
// pub fn to_game_event(&self, player_id: PlayerId, dice: Dice) -> GameEvent { // pub fn to_game_event(&self, player_id: PlayerId, dice: Dice) -> GameEvent {

View file

@ -6,10 +6,11 @@ use board_game::board::{
use board_game::impl_unit_symmetry_board; use board_game::impl_unit_symmetry_board;
use internal_iterator::InternalIterator; use internal_iterator::InternalIterator;
use std::fmt; use std::fmt;
use std::hash::Hash;
use std::ops::ControlFlow; use std::ops::ControlFlow;
use store::Color; use store::Color;
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct TrictracBoard(crate::GameState); pub struct TrictracBoard(crate::GameState);
impl Default for TrictracBoard { impl Default for TrictracBoard {
@ -78,6 +79,10 @@ impl BoardGameBoard for TrictracBoard {
} }
impl TrictracBoard { impl TrictracBoard {
pub fn inner(&self) -> &crate::GameState {
&self.0
}
pub fn to_fen(&self) -> String { pub fn to_fen(&self) -> String {
self.0.to_string_id() self.0.to_string_id()
} }

View file

@ -22,6 +22,7 @@ nombres aléatoires avec seed : <https://richard.dallaway.com/posts/2021-01-04-r
- rayon ( sync <-> parallel ) - rayon ( sync <-> parallel )
- front : yew + tauri - front : yew + tauri
- egui - egui
- <https://docs.rs/board-game/latest/board_game/> - <https://docs.rs/board-game/latest/board_game/>
@ -31,6 +32,7 @@ nombres aléatoires avec seed : <https://richard.dallaway.com/posts/2021-01-04-r
- <https://www.mattkeeter.com/projects/pont/> - <https://www.mattkeeter.com/projects/pont/>
- <https://github.com/jackadamson/onitama> (wasm, rooms) - <https://github.com/jackadamson/onitama> (wasm, rooms)
- <https://github.com/UkoeHB/renet2> - <https://github.com/UkoeHB/renet2>
- <https://github.com/UkoeHB/bevy_simplenet>
## Others ## Others