This is my clone of Minecraft, built without a game engine, purely on WGPU (and some egui for interface).
It is a turn-based, 2.5d game: the field looks 2d, but you can break the top block, or place a block on top of an existing one.
Key features:
- The game has crafting, and for some items you will need a crafting table nearby.
- The map is infinite in 2 dimensions.
- Player needs different tiers of pickaxes to break some blocks.
- Zombies on unloaded chunks do not vanish. They remain in place until the chunk is loaded again.
- Banelings (hostile mobs) are better than creepers: they blow up and destroy walls if they can't find a short route to the player, even if the player is a few blocks away from the explosion radius.
- Zerglings are smart and only attack in groups.
- Self-shooting turrets can be placed to help you defend.
Part of the purpose of this project is to build a training environment for ML agents.
The environment is similar to the famous MineRL, as it has the same complexity in terms of progression: mine tree -> make crafting table -> make pickaxe -> etc.
But does not require computer vision, and runs significantly faster.
The grey circle on every game tile indicates the height of the tile. The darker the circle, the lower the block.
minecraft_bot_github.mp4
The agent is traveling instead of building a house, which is a viable strategy since the game has 2 kinds of mobs that are difficult to deal with when the player is camping behind walls. It also makes sure to mine all diamonds it sees, as it significantly increases the game score.
The game_logic
crate serves as the game engine, computing all game state changes such as player actions, mob movements, and field generation.
The minecraft
crate handles graphics, using WGPU and egui to render the game state in a human-accessible format.
It supports both live gameplay and replay viewing, including replays generated by bots.
The ffi
(Foreign Function Interface) crate provides a Rust-to-C interface for the game engine.
Its exposed functions allow complete interaction with the game without the overhead of rendering.
The interface is computationally efficient, supports batching, and achieves 20 thousand FPS in single-thread performance
when actions are provided through Python.
The python_wrapper
crate implements a C-to-Python interface for the ffi
.
It packages the interaction logic as a gymnasium environment,
making it easier to train RL agents.
The reinforcement_learning
directory contains Python code for training and evaluating RL agents.
The video above demonstrates results from a 6-hour training run on a single GPU.
- Most of the blocks - minecraft
- PLayer - Riley Gombart
- Zergling and Baneling - Starcraft 2
- Cow - Minecraft
- Hit animations - Sinestesia