4 ms·
This bug is a design smell. They have a "Player" module that can likely be controlled by a human or by an "AI" module. This is good design. The problem here i
by crimsonalucard 7y ago
This bug is a design smell.
They have a "Player" module that can likely be controlled by a human or by an "AI" module. This is good design.
The problem here is likely that IO is tightly integrated with Player and every other module as a dependency. This is what can cause the bug to occur.
Proper design is for the "Player" module to never depend on IO as a dependency...
1. the player module should be able to output the next gamestate of a game given the action and previous gamestate.
2. The AI should calculate the action when given a gamestate.
3. IO should be a function that when given gamestate, it displays it on the screen, or saves it to the DB.
4. All modules should be unaware of the other modules.
No dependencies.
Likely the fix that the poster is doing doesn't involve separating the "Player" module from all knowledge of IO, but the fix he is doing is making AI a special case in the "Player" module. This speaks to all kinds of wrong.
Following these design patterns over a long period of time leads to code that is "tech debt" heavy and messy. It's an inevitable consequence for programmers who don't know how to design things. Also note that this is normal. I would say 99% of programmers don't know this and are likely doing some garbage like using dependency injection to make every module in the system depend on IO.