From 58d9ee97e26da40b7ac1d9178d329912d0ec84ca Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Thu, 15 Jan 2026 17:03:16 +0100 Subject: [PATCH] refact: docs --- README.md | 38 ++++++++++++++++++- doc/{refs => ai/history}/claudeAIquestion.md | 0 .../history}/claudeAIquestionOnlyRust.md | 0 doc/{ => book}/traité.md | 0 doc/refs/geminiQuestions.md | 19 ---------- doc/{ => specs}/diagrammes.md | 0 .../stateEncoding.md} | 0 doc/{ => specs}/store.puml | 0 doc/{ => specs}/vocabulary.md | 0 doc/{ => specs}/workflow.md | 0 10 files changed, 36 insertions(+), 21 deletions(-) rename doc/{refs => ai/history}/claudeAIquestion.md (100%) rename doc/{refs => ai/history}/claudeAIquestionOnlyRust.md (100%) rename doc/{ => book}/traité.md (100%) delete mode 100644 doc/refs/geminiQuestions.md rename doc/{ => specs}/diagrammes.md (100%) rename doc/{refs/specifications.md => specs/stateEncoding.md} (100%) rename doc/{ => specs}/store.puml (100%) rename doc/{ => specs}/vocabulary.md (100%) rename doc/{ => specs}/workflow.md (100%) diff --git a/README.md b/README.md index d2808fa..349bb14 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,41 @@ # Trictrac -Game of [Trictrac](https://en.wikipedia.org/wiki/Trictrac) in rust. +This is a game of [Trictrac](https://en.wikipedia.org/wiki/Trictrac) rust implementation. -wip +The project is on its early stages. +Rules (without "schools") are implemented, as well as a rudimentary terminal interface which allow you to play against a bot which plays randomly. +Training of AI bots is the work in progress. +## Usage + +`cargo run --bin=client_cli -- --bot random` + +## Roadmap + +- [x] rules +- [x] command line interface +- [x] basic bot (random play) +- [.] AI bot +- [] network game +- [] web client + +## Code structure + +- game rules and game state are implemented in the _store/_ folder. +- the command-line application is implemented in _client_cli/_; it allows you to play against a bot, or to have two bots play against each other +- the bots algorithms and the training of their models are implemented in the _bot/_ folder + +### _store_ package + +The game state is defined by the `GameState` struct in _store/src/game.rs_. The `to_string_id()` method allows this state to be encoded compactly in a string (without the played moves history). For a more readable textual representation, the `fmt::Display` trait is implemented. + +### _client_cli_ package + +`client_cli/src/game_runner.rs` contains the logic to make two bots play against each other. + +### _bot_ package + +- `bot/src/strategy/default.rs` contains the code for a basic bot strategy: it determines the list of valid moves (using the `get_possible_moves_sequences` method of `store::MoveRules`) and simply executes the first move in the list. +- `bot/src/strategy/dqnburn.rs` is another bot strategy that uses a reinforcement learning trained model with the DQN algorithm via the burn library (). +- `bot/scripts/trains.sh` allows you to train agents using different algorithms (DQN, PPO, SAC). diff --git a/doc/refs/claudeAIquestion.md b/doc/ai/history/claudeAIquestion.md similarity index 100% rename from doc/refs/claudeAIquestion.md rename to doc/ai/history/claudeAIquestion.md diff --git a/doc/refs/claudeAIquestionOnlyRust.md b/doc/ai/history/claudeAIquestionOnlyRust.md similarity index 100% rename from doc/refs/claudeAIquestionOnlyRust.md rename to doc/ai/history/claudeAIquestionOnlyRust.md diff --git a/doc/traité.md b/doc/book/traité.md similarity index 100% rename from doc/traité.md rename to doc/book/traité.md diff --git a/doc/refs/geminiQuestions.md b/doc/refs/geminiQuestions.md deleted file mode 100644 index 2801fe2..0000000 --- a/doc/refs/geminiQuestions.md +++ /dev/null @@ -1,19 +0,0 @@ -# Description du projet - -Je développe un jeu de TricTrac () dans le langage rust. -Pour le moment je me concentre sur l'application en ligne de commande simple, donc ne t'occupe pas des dossiers 'client_bevy', 'client_tui', et 'server' qui ne seront utilisés que pour de prochaines évolutions. - -Les règles du jeu et l'état d'une partie sont implémentées dans 'store', l'application ligne de commande est implémentée dans 'client_cli', elle permet déjà de jouer contre un bot, ou de faire jouer deux bots l'un contre l'autre. -Les stratégies de bots sont implémentées dans le dossier 'bot'. - -Plus précisément, l'état du jeu est défini par le struct GameState dans store/src/game.rs, la méthode to_string_id() permet de coder cet état de manière compacte dans une chaîne de caractères, mais il n'y a pas l'historique des coups joués. Il y a aussi fmt::Display d'implémenté pour une representation textuelle plus lisible. - -'client_cli/src/game_runner.rs' contient la logique permettant de faire jouer deux bots l'un contre l'autre. -'bot/src/strategy/default.rs' contient le code d'une stratégie de bot basique : il détermine la liste des mouvements valides (avec la méthode get_possible_moves_sequences de store::MoveRules) et joue simplement le premier de la liste. - -Je cherche maintenant à ajouter des stratégies de bot plus fortes en entrainant un agent/bot par reinforcement learning. -J'utilise la bibliothèque burn (). - -Une version utilisant l'algorithme DQN peut être lancée avec `cargo run --bin=burn_train -- dqn`). Elle effectue un entraînement, sauvegarde les données du modèle obtenu puis recharge le modèle depuis le disque pour tester l'agent. L'entraînement est fait dans la fonction 'run' du fichier bot/src/burnrl/dqn_model.rs, la sauvegarde du modèle dans la fonction 'save_model' et le chargement dans la fonction 'load_model'. - -J'essaie de faire l'équivalent avec les algorithmes PPO (fichier bot/src/burnrl/ppo_model.rs) et SAC (fichier bot/src/burnrl/sac_model.rs) : les fonctions 'run' sont implémentées mais pas les fonctions 'save_model' et 'load_model'. Peux-tu les implémenter ? diff --git a/doc/diagrammes.md b/doc/specs/diagrammes.md similarity index 100% rename from doc/diagrammes.md rename to doc/specs/diagrammes.md diff --git a/doc/refs/specifications.md b/doc/specs/stateEncoding.md similarity index 100% rename from doc/refs/specifications.md rename to doc/specs/stateEncoding.md diff --git a/doc/store.puml b/doc/specs/store.puml similarity index 100% rename from doc/store.puml rename to doc/specs/store.puml diff --git a/doc/vocabulary.md b/doc/specs/vocabulary.md similarity index 100% rename from doc/vocabulary.md rename to doc/specs/vocabulary.md diff --git a/doc/workflow.md b/doc/specs/workflow.md similarity index 100% rename from doc/workflow.md rename to doc/specs/workflow.md