This post is going to be pretty short (like for real, not how I usually say that it’s going to be short and then I ramble on anyway. Just short. Except for this explanation about how it’s going to be short). I fixed the bug that I was facing yesterday and, as predicted, it was pretty simplistic once I eventually figured out what was going on. This took enough time that (besides some new debugging output code), nothing else was accomplished. However, things look like this now:
— Terence Martin (@OdatNurd) December 22, 2016
To recap what was happening yesterday, I implemented the mechanism whereby each player gets their own unique set of balls to push, which is not actually stored in the maze but instead in an outside data structure, so we can swap them back and forth. I was experiencing a bug where swapping the balls back and forth did not do what I expected it to do.
It turns out that I’m too smart for my own good. In order to get this working, we show the balls that are for the current player and hide the balls that are not being used. Unfortunately for me, I had this “clever” code implemented that scans the pool of balls and kills all of the ones that are currently hidden, removing them from the maze.
When an entity is dead, it doesn’t get updated or rendered because the code in ActorPool that does this only invokes it for live entities (which made total sense at the time, and still does). So as soon as we hide the computer balls, they get reaped away and no longer updated. Of course they’re still in our external data structure, where we put them into the maze and they don’t render and can’t be interacted with because they’re dead. To use a single word to describe my feelings on this bug (while not being profane) I would have to use “GAH!”.
The fix for this is to scan the maze for hidden balls and just null them away instead of marking them as dead, since they are still potentially needed. We could actually kill the balls when they are vanished away, since in that case we know that we’re done with them, but I’m leaving that alone for now because, you know, gun shy.
Anyway, bug fixed, so basically by the end of today we’re back where we were at the end of yesterday, only now the code does what we want it to do, there is some extra debugging logic (pressing the question mark key in debug mode dumps info about the current debug cell to the console), and my sanity is returning.
Progress shall continue tomorrow.