| Crates.io | game_logic |
| lib.rs | game_logic |
| version | 0.1.1 |
| created_at | 2025-04-04 15:26:26.125039+00 |
| updated_at | 2025-04-05 08:16:56.017642+00 |
| description | A crate for simulating turn-based games with customizable game logic and agent behavior. |
| homepage | |
| repository | https://github.com/EyalLitvin/game_logic |
| max_upload_size | |
| id | 1620219 |
| size | 18,727 |
A crate for simulating turn-based games with customizable game logic and agent behavior.
This crate provides traits for implementing your own turn-based games.
First, implement a gameMove and a gameState types. these types should represent a stateless frozen move in the game or a state of the game (respectively). then, you can create a gameLogic type.
Such a type is responsible for managing a game. you should think of the type itself as the general game, and every instance of it as a "variant" of the game.
For example, you could have a NimGameLogic1 type (as is implemented in the tests), and every instance would have a specific initial pile size, and maximum "takes" per turn.
Once these are implemented, you will have to implement an Agent for your game - and then you can simulate the game using game_logic::game_simulation::simulate_game.
Every game goes like this:
GameLogic::init methodinit method also outputs the set of players who need to make a moveAgent::digest_state method
b. Or is queried for a move, using the Agent::calculate_next_move method. this method is also implicitly in charge of notifying the agent of the new stateThis process should be flexible enough for almost any turn-based games.
Notice that each agent is getting a "masked state" - perhaps there are some details of the state that the game should be aware of, but some (or all) of the agents shouldn't be.
This crate still requires some work. mainly:
GameLogic be fully in charge of it)I am very new to rust, and this is one of my first actual projects. Obviously I have a lot to learn about rust and development in general. Every criticism is welcome :)
This is not the classic universal combinatorial game (due to the Sprague-Grundy theorem), but a version where every turn you are allowed to take at most some specified amount of matches. ↩
These projects practically amount to creating a generic implementation for the agent object, together with some wrapper around the simulation function. they will be linked here when created. ↩