3 ms·
So there's nearly as many answers to your question as there are gamedevs. I've seen quite a few use an OO modeling approach. That's fallen out of favor for goo
by jasonwatkinspdx 5y ago
So there's nearly as many answers to your question as there are gamedevs.
I've seen quite a few use an OO modeling approach. That's fallen out of favor for good reason.
Another approach is Entity Component Systems. I suggest googling for one of the better blog posts on that.
Another approach is to build the equivalent of a datalog engine.
An approach I favor is to have a stack per entity, and as you parse input events things get stacked up. Then a processing pass iterates across popping things off the stack. If you know how MTG rules work it's roughly the same idea.
None of these are a panacea, because you can have logical contradictions in your ruleset that are subtle and only emerge in very niche situations.
It's definitely very difficult problem. What you suggest is similar to what I termed the datalog style. If you've ever tried to debug a prolog or datalog program, you'll know that it all being in one file is a trivial concern compared to the emergent complexity and potential for you to have misstated your logic or included contradictions.
- iamwil 5y agoIndeed I was thinking of a datalog engine. (!) I've had minimal experience with datalog, but you should be able to query it for how it got to its resulting fact, no? So if you find a fact that doesn't make sense, I thought you'd be able to query for the path it took to get that fact? If you have a stack per entity, like MTG, how would you find a contradicting rule?
- jasonwatkinspdx 5y agoYou can query it sure, but that doesn't mean the problem will be readily obvious. Again, this stuff can get complex fast, and it's easy to armchair quarterback that away. So the stack approach essentially doesn't, because it forces a linearization. You'd have to rewind back through and see why what the system did didn't match your expectation. But at least the order is comprehensible vs some of the other approaches.