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/
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

View file

@ -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)
}