Grid System, and Performance
Hey Folks! As mentioned yesterday, my brain was seriously losing traction on the AI task. By midday, it was getting to the point where all my energy was being spent keeping focused, rather than doing productive work. This usually means it's time for a change of task.
So today was all about the grid system. I resumed yesterday's beginnings of switching the game from a 32-pixel grid to a 16-pixel one. I'll still be keeping the 32-pixel crew for now, though, because my main motivation for the smaller grid is to have more room for ship layout detail. Namely, thinner walls and angled/curved sections.
It took most of the morning to sort out the last of the 32-pixel settings and make it work at a smaller grid size, but I eventually did it. And using a new set of smaller tiles with angled pieces, I was able to get this:
It's not a perfect circle or anything, but I think it gets the point across. And nicely shows that non-orthogonal shapes are possible.
In theory, one could even go a step further and make perfectly curved pieces if they wanted. But the elegance of this type of layout is that it only uses a handful of modular tile types. Basically, a 1x1 box, a 1x1 wedge, and a pair of mirrored 1x2 wedge shapes. And using these to make 12-sided rings means each ring is cocentric with room to walk between each.
It's not without issues, though. For one thing, a crew is still 32x32, so it takes up 2 of these tiles. And when it walks close to a wall, it clips into said wall. I think this can be solved by making the wall block pathfinding on grid squares that border solid wall, though.
Another issue is performance. I had a total of 7 of these cocentric rings in a ship's layout at once, plus some decorative outer shapes. And the overall ship dimensions were 80x58 tiles. Assuming this was a working ship, this would mean wall tiles, floor tiles, ship's equipment and hardware, and lighting. I'd estimate I've got about 1000 tiles in this file, and that's just walls. And performance is certainly struggling. I get about 45fps when I zoom out to see the whole thing.
And this is just in building mode. I was kinda hoping to have AIs doing their thing, and physical simulations going on to handle power, air, water, and other ship systems.
That said, I have barely bothered to optimize anything yet. I found a memory leak by accident, and was able to fix that. And there seems to be a bug with the way the tile grid overlay works, because hiding it kills framerate, and showing it again fixes framerate. (The opposite of what one would expect.)
And there's probably some optimization to be had in simulating periodically, rather than continuously. The AI already does this by ticking once per second, instead of per-frame. And maybe the ship simulator can do the same.
Anyway, I feel like today's major accomplishment was a few things: proving that a non-square layout can be drawn, revealing the limits of performance, and getting a view of what a smaller grid looks like with a larger crew sprite.
More to come next week, but this was at least a high note to end on! Have a good weekend, all!