Hacker News new | ask | show | jobs
by verdagon 1710 days ago
Indeed, ECS might not be a good fit for turn-based games.

We explored the topic quite thoroughly in [0] and came to the conclusion that Roguelikes are more suited for something in-between ECS and OO, named just "EC".

ECS is better suited to real-time games, or games which have a lot of iteration over large arrays and parallel (not as in multi-threading, but as in, batchable) computations, where ECS can really shine due to its data layout. Most turn-based games like roguelikes don't iterate over large arrays in the same way.

With EC on the other hand, you're a little more free to group components into their parent entity, and use interfaces (traits), which can make things more understandable.

Whether idiomatic Rust likes EC is an open question though. Idiomatic Rust tends to dislike heap allocation and virtual dispatch, both which can make life a lot easier for Roguelike games, which tend to prioritize flexibility and features, and don't need the data-oriented optimization.

Additionally, a lot of people suggest using ECS in Rust because that's the only architecture that the borrow checker doesn't fight you in, for various reasons.

[0]: https://www.reddit.com/r/roguelikedev/comments/i3xekn/ec_vs_...

1 comments

> Idiomatic Rust tends to dislike heap allocation and virtual dispatch

Maybe Rust the way most people end up writing it, but Rust the language has no issue with these things. I think the idioms come more from the fact that Rust empowers you to avoid these things, not that it's poorly-suited to them.

I think both are true. Rust is poorly-suited to certain architectures, and empowers us to use other architectures. Rust's idioms take both its strengths and weaknesses into account.

It can make up for it in other ways, but in my experience, Rust is poorly-suited for Roguelike architecture specifically.

Broadly speaking yes, it's good and bad at different things. Specifically ownership is obviously the big challenge, and is often associated with heap allocation and dynamic dispatch. But the latter two in their own right are not any harder or more limited in Rust than anything else.