This commit is contained in:
Henri Bourcereau 2024-01-09 20:50:52 +01:00
parent 23ab966602
commit 14ae91eae7
2 changed files with 22 additions and 11 deletions

View file

@ -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/ 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 #### State data
* piece placement * piece placement -> 77bits (24 + 23 + 30 max)
* dames * dames
* active player * active player -> 1 bit
* step * step -> 2 bits
* roll dice * roll dice
* mark points (jeton & fichet) & set bredouille markers (3rd jeton & pavillon) * mark points (jeton & fichet) & set bredouille markers (3rd jeton & pavillon)
* move pieces * move pieces
* dice roll * dice roll -> 4bits
* points * points 10bits x2 joueurs = 20bits
* points * points -> 4bits
* trous * trous -> 4bits
* bredouille possible * bredouille possible 1bit
* grande bredouille possible * grande bredouille possible 1bit
Total : 77 + 1 + 2 + 4 + 20 = 104 bits = 13 * 8 (8^2 = 256) = 17.3333 * 6 (18 u64) -> 108 possible

View file

@ -9,7 +9,9 @@ use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt; 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)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Stage { pub enum Stage {
PreGame, PreGame,
@ -17,7 +19,7 @@ pub enum Stage {
Ended, 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)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TurnStage { pub enum TurnStage {
RollDice, RollDice,
@ -72,6 +74,11 @@ impl GameState {
GameState::default() 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> { pub fn who_plays(&self) -> Option<&Player> {
self.players.get(&self.active_player_id) self.players.get(&self.active_player_id)
} }