This is the first blog for automagica.. What should i write in these blogs? Maybe just anything i do regarding the game.
️⚙️ Framework Choice
The game will be created using the rust programming language, I’ve spent a few days pondering libraries and such in rust, and have come to decide on these for the game:
Library | Purpose | Choice |
---|---|---|
hecs | entity-component-system | Originally i considered using the bevy game engine, but upon further research i really felt like i was going to have trouble implementing a deterministic system there without circumventing many of the actual intended features of bevy, so i chose hecs which provides a more minimalist library which allows me to organise the game however i want |
ggez | 2D crossplatform game framework | Less-frequent updating means less version chasing, while providing a pretty strong batteries-included base for building the “engine” automagica will be built off |
glam | simple and fast 3D math library for games and graphics. | This is just a linear algebra library, which through serde , and libm features can be made deterministic and serializable/deserializable |
serde | Serialization & deserialization | Allows us to easily serialize and deserialize the game state information to any format |
📂 Project Structure
Rust provides a pretty powerful project management function through the usage of cargo workspaces, When creating the project i am currently thinking of the usage of a client - authoritative server networking system for multiplayer (pretty feature-creepy) but i would still like to plan ahead for that, To facilitate that i am structuring the project as follows:
Workspace | Type | Usage |
---|---|---|
client | Binary | All client-specific rendering code and such will go in here |
server | Binary | All the server-specific networking code and things will be here |
common | Library | Anything which is shared between client-server such as simulation code or such will be in here |
I will be naming the current version 0.0.1-early-dev
to reflect the earliness in development.
🔢 Determinism In Rust
For the future in networking and multiplayer if i ever get to that point, I want to have the game be fully deterministic cross-platform.
This will allow me to easily re-replicate issues from client inputs, do unit testing on parts of the game replicably on all platforms, and implement a Deterministic Lockstep style networking if need be.
There are a few issues with this in rust:
Floating Point numbers (f32, f64) are only partly deterministic, such as in utilising operations defined by IEEE 754, Other functions not defined by this though however are non-deterministic, such as exp or ln, This can be solved by instead using libm which would provide a guaranteed cross-platform deterministic version of these methods.
Hash based data structures by default as found in HashMap are non-deterministic as the hashing is non-deterministic and the iteration order of the map is arbitrary.
Some libraries such as pseudorandom number generators may be deterministic on the same platform, but non-portable and have non-deterministic behaviour across platforms due to the usage of usize or transcendental functions which utilise std instead of libm, care should be taken to ensure all libraries use deterministic mathematics.