Sunday Fun-Day?


The good stuff: 

Boy oh boy... Remember when I suggested I'd have big 'ole progress by today?  Sadly, this has not come to pass in any visually meaningful sense.  I spent Saturday decompressing, but today ran into some particularly silly bugs; bugs which occupied a much greater portion of time than they warranted.  Let me not get ahead of myself - first, as the header supposes, the good stuff!  

I managed to:

  • Rework a good portion of the data framework that powers the card traits.  
  • Clean up some nasty bugs within the pathfinding
  • Actually plug in turn order (Player, then AI,  etc.) and then straighten up that code a little

The unpleasant stuff:

Four nasty bugs reared their ugly heads!  

The first was fairly foolish on my part.  My pathfinding process is an extremely naïve implementation of the Dijkstra algo.  So simple that I bundled it with the solver so it dumps out the next best position to move to.  For some reason I forgot this and the section of code was poorly organized under the assumption (BAD) that I would return the next day.  The result returned was either the next path or null but I was treating it like it was returning bool.  Worse still I was asking for a path and checking against other possible targets to see which was closest, and instead modifying the START position (as opposed to the new best target).  We won't talk about how long it took to solve this riddle.


The next issue was more insidious, but even more ridiculous.  Sometimes, joining two objects into one would throw an error.  Eventually I discovered this was due to how I had restructured the various pools of card data.  I still need to refactor this, but the issue has been solved.  It turned out (after much testing) to be an extremely amateurish problem: I was modifying a collection while reading from it.  As this was happening over time an not in a wrapper such as foreach, it took a while for me to catch.


More fun?  Sure - without any discernable cause Moss would sometimes fill 3/4th of the screen and then stop.  Why would this happen?  It turns out my Scriptable Object solution worked fine on its own, but was not very extensible.  So I had split it further into subgroups of traits, rather than concise data packages.  This lead to global data, (which is my fault, as I was abusing Unity's SO), and so all the mosses were adding to the global rate, resulting in a stalemate.  The fix was to completely rip apart my system and rewrite it as basic classes.  This is less easy to work with, but more flexible and safer.  Oh well, I knew I was playing with fire...


Lastly, over time as more cards would get played to the board there started to be this weird slowdown.  This made no sense as the game runs at a rock-solid 60 FPS with V-Sync on.  Profiling showed the weird "slowdown" to be tied to pointless recursion of a single function.  This, compliments of Unity's Update method, and how it lives in the overall runtime.  The fix is a bit involved for this blog, but the important thing is it's fix.  

The game rests currently in a stable, if further behind than I would like, state.

I'm considering running a coding stream on Twitch this week, maybe on wed.  If there is any interest let me know!   I appreciate all the comments!

Eli

Leave a comment

Log in with itch.io to leave a comment.