From 14ae91eae790b25863e75d8bc06672aacff29669 Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Tue, 9 Jan 2024 20:50:52 +0100 Subject: [PATCH] maj --- doc/backlog.md | 22 +++++++++++++--------- store/src/game.rs | 11 +++++++++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/doc/backlog.md b/doc/backlog.md index 33e1aaa..93a1570 100644 --- a/doc/backlog.md +++ b/doc/backlog.md @@ -88,17 +88,21 @@ Non dénuée d'avantages : Backgammon notation : https://nymann.dev/2023/05/16/Introducing-the-Backgammon-Position-Notation-BPN-A-Standard-for-Representing-Game-State/ +GnuBg : https://www.gnu.org/software/gnubg/manual/html_node/A-technical-description-of-the-Position-ID.html + #### State data -* piece placement +* piece placement -> 77bits (24 + 23 + 30 max) * dames -* active player -* step +* active player -> 1 bit +* step -> 2 bits * roll dice * mark points (jeton & fichet) & set bredouille markers (3rd jeton & pavillon) * move pieces -* dice roll -* points - * points - * trous - * bredouille possible - * grande bredouille possible +* dice roll -> 4bits +* points 10bits x2 joueurs = 20bits + * points -> 4bits + * trous -> 4bits + * bredouille possible 1bit + * grande bredouille possible 1bit + +Total : 77 + 1 + 2 + 4 + 20 = 104 bits = 13 * 8 (8^2 = 256) = 17.3333 * 6 (18 u64) -> 108 possible diff --git a/store/src/game.rs b/store/src/game.rs index 9d336ec..c9c2500 100644 --- a/store/src/game.rs +++ b/store/src/game.rs @@ -9,7 +9,9 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::fmt; -/// The different states a game can be in. (not to be confused with the entire "GameState") +type TGPN = [u8]; + +/// The different stages a game can be in. (not to be confused with the entire "GameState") #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Stage { PreGame, @@ -17,7 +19,7 @@ pub enum Stage { Ended, } -/// The different states a game turn can be in. +/// The different stages a game turn can be in. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum TurnStage { RollDice, @@ -72,6 +74,11 @@ impl GameState { GameState::default() } + /// Format to TGPN notation (Tables games position notation) + fn toTGPN(&self, f: &mut fmt::Formatter) -> TGPN { + b"ll" + } + pub fn who_plays(&self) -> Option<&Player> { self.players.get(&self.active_player_id) }