Remix.run Logo
lmorchard 5 days ago

Meanwhile, Undertale, one of the most celebrated video games, famously has a 1000+ line switch statement and AI had nothing to do with it. Sometimes you have to bang out something that works, just to even get the chance to be annoyed at how bad it is for next version.

tytho 5 days ago | parent | next [-]

Game development is often a completely different set of skills and maintenance profile compared to enterprise SaaS development. Many single-player games especially indie ones don’t need to worry about multi-year contracts or having to work through many cycles of different developers coming in and out of a project. Having a 1000+ line switch statement seems totally reasonable on a project with a handful of developers that will continue to work on the project.

My understanding is that the switch statement was for npc character conversation text. That seems pretty reasonable, even in enterprise SaaS for something like translations. It might not be as easy to maintain in other circumstances.

airbreather 5 days ago | parent [-]

I would suggest that the 1000 line switch statement implies a state machine that has suffered from the "state explosion".

This usually results from an inadequate system-subsystem decomposition and/or not considering modes, both of which lead to hierarchal state machines instead of one big flat one.

This aspect of architecture is difficult to teach, it is one of the "black arts" that comes from experience and is difficult to codify.

Just one example why, is that often it might require the synthesis of state machines not directly evident as needed from the functionality, eg to perform a one to many or many to one functionality.

8note 4 days ago | parent [-]

https://i.redd.it/vglorgtzx0kd1.png

can't find the actual code, but its a look up table for what dialogue to use. The existence of a switch statement does not force the code to be a state machine.

it could still be some architectural deficit around making it harder to look up the dialogue rather than having it in place when uts triggered, but it makes it nice to understand all the dialogue in the game at once

airbreather 3 days ago | parent [-]

Even if not explicitly looking like a state machine, it will have state based behaviour that could be represented by a state machine.

Almost everything is state based behaviour.

whateveracct 4 days ago | parent | prev [-]

Toby Fox also took a LONG time to realize its sequel, DeltaRune.

He attributed it to not being able to program the more complex systems he wanted to build. So code earlier compounds later - good or bad. As is tradition.