diff --git a/README.md b/README.md index e5a0f39..d2808fa 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,7 @@ # Trictrac -This is a game of [Trictrac](https://en.wikipedia.org/wiki/Trictrac) rust implementation. +Game of [Trictrac](https://en.wikipedia.org/wiki/Trictrac) in rust. -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. +wip -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/specs/diagrammes.md b/doc/diagrammes.md similarity index 100% rename from doc/specs/diagrammes.md rename to doc/diagrammes.md diff --git a/doc/ai/history/claudeAIquestion.md b/doc/refs/claudeAIquestion.md similarity index 100% rename from doc/ai/history/claudeAIquestion.md rename to doc/refs/claudeAIquestion.md diff --git a/doc/ai/history/claudeAIquestionOnlyRust.md b/doc/refs/claudeAIquestionOnlyRust.md similarity index 100% rename from doc/ai/history/claudeAIquestionOnlyRust.md rename to doc/refs/claudeAIquestionOnlyRust.md diff --git a/doc/refs/geminiQuestions.md b/doc/refs/geminiQuestions.md new file mode 100644 index 0000000..2801fe2 --- /dev/null +++ b/doc/refs/geminiQuestions.md @@ -0,0 +1,19 @@ +# 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/specs/stateEncoding.md b/doc/refs/specifications.md similarity index 100% rename from doc/specs/stateEncoding.md rename to doc/refs/specifications.md diff --git a/doc/specs/store.puml b/doc/store.puml similarity index 100% rename from doc/specs/store.puml rename to doc/store.puml diff --git a/doc/book/traité.md b/doc/traité.md similarity index 100% rename from doc/book/traité.md rename to doc/traité.md diff --git a/doc/specs/vocabulary.md b/doc/vocabulary.md similarity index 100% rename from doc/specs/vocabulary.md rename to doc/vocabulary.md diff --git a/doc/specs/workflow.md b/doc/workflow.md similarity index 100% rename from doc/specs/workflow.md rename to doc/workflow.md