Rustorio v0.1.0 - Using Rust's type system as a game engine
Version 0.1.0 of Rustorio is now up on crates.io!
The first game written and played entirely in Rust's type system (well almost). Not just do you play by writing Rust code, the rules of the game are enforced by the Rust compiler! If you can write the program so it compiles and doesn't panic, you win!
A while ago I realized that with Rust's affine types and ownership, it was possible to simulate resource scarcity. Combined with the richness of the type system, I wondered if it was possible to create a game with the rules enforced entirely by the Rust compiler. Well, it looks like it is.
The actual mechanics are heavily inspired by Factorio and similar games, but you play by filling out a function, and if it compiles and doesn't panic, you've won! As an example, in the tutorial level, you start with 10 iron
fn user_main(mut tick: Tick, starting_resources: StartingResources) -> (Tick, Bundle<Copper, 1>) {
let StartingResources { iron } = starting_resources;
You can use this to create a Furnace to turn copper ore (which you get by using mine_copper) into copper.
let mut furnace = Furnace::build(&tick, IronSmelting, iron);
let copper_ore = rustorio::mine_copper::<8>(&mut tick);
furnace.add_input(&tick, copper_ore);
tick.advance_until(|tick| furnace.cur_output(tick) > 0, 100);
Because none of these types implement Copy or Clone and because they all have hidden fields, the only way (I hope) to create them is through the use of other resources, or in the case of ore, time.
New features
- Revamped recipe system. Recipes and technologies are now defined using macros, allowing much more variation and stuff like automatic and standardized documentation. Many thanks to talshorer for implementing most of the proc-macros. I'd never worked with them before so I don't know if I would have gotten it done without their help.
- Territories. Some people mentioned that optimizing the game was kinda pointless when you were limited by hand mining ores anyway. This has now changed! You can still hand mine the territories to start, but to scale you can add miners to the territories to automate the process.
- Scale. You now need 200 points to win the game, and points require not iron and copper, but circuits and steel. Together these should give you much more to optimize on.
Next steps
Playtesting: This is not so much a task for the developers, but for you. The game is now at a point where I wanna start focusing on the actual, you know, gameplay. This means that any and all feedback on this point is incredibly valuable, whether it's a pain point or something you enjoy. I'd even love to see your entire playthrough to get a picture of the things people get up to. Rustorio has a unique user interface for a game so we have to reinvent a lot of game design from scratch which means playtesting is essential. So please do leave a comment here, send me a DM or join the Discord.
Other than that I'm considering setting up an official leaderboard where players can submit playthroughs that is then run and ranked on how few ticks they take.
I'm also looking into supporting subfactories. This brings quite a few interesting technical difficulties and I think it's essential for making more complex gameplay a good experience.