Looking for advice on space/time complexity trade off in tactics game [closed]


Make no mistake, I am not pouring hours into thinking about this since, like most people advise, there are bigger fish to fry in gamedev. This is more figuring out good design practice for structuring my game.

I have a 3D Unity turn-based tactics game with a Breadth-first search algorithm to show the possible movement range during cursor hover. (A* will come down the line.) Out of habit I stored the BFS searches because it felt wasteful to re-run them every time the user moves the cursor over any unit, which of course led me to this debate of trade offs.

My only real goals are:

  • No delays with user input
  • Reasonable performance across platform, including mobile
  • Possible online multiplayer down the line

On average, I’m thinking 25 units per map, max 30 tiles per range, so round up and say ~800 POCO refs to be stored in memory if I save them all. (Technically they’re Monobehaviours but down the line I’m replacing the prefabs for shaders). The maps are only going to be ~800-900 tiles in size, so it’s nothing remotely close to Civ-sized maps.

Since everything is relatively “small-medium” in size, both space and time are pretty much equal for BFS here.

So I’m left wondering which if saving the searches like I am is good practice. My gut is saying protect time because I’m sure I’ll find ways to slow Unity down with bad code. On the other, I hardly ever consider memory limitations and while we’re not in the 2000’s anymore, it’s not something to shrug off.

Again, I’ll probably just keep rolling with what I normally do because there are many more problems I’ll have to solve down the line.

I’m just curious if anyone has some wisdom they can share on the matter.

tl;dr Which is the better habit? Prioritizing time or space?