City4k

This City4K seems to be a complicated but very interesting game. My comment about it will not be as deep as some others : I just regret one can’t move the map with the arrow keys or by grabbing it with the mouse.

This being a 4k entry, you can probably work around the entire issue by making 150 inhabitants the end goal. Then calculate a score based in the time it took to finish the game. This even adds some additional replay value. Win-win solution :slight_smile:

Good suggestion!

I don’t understand. Why can’t I get population?

If people won’t move into your residential units either
The land value is too low, (Click on the purple V in the lower Left Hand Corners, if the Squares with power are red or orange they won’t develop)
There is no road they can use to get to a job
There is no residential demand
There is no electricity

— Algorithm changes
I’ve changed any usage of arraylists to a strict array based approach
The array has to indexes one representing the top and the other representing the bottom. This means I can reuse the structure without any object creation or garbage collection.
For Traffic I use a BFS to find the nearest job with an additional array tracking the optimal path to any given square (Dynamic Programming style.) Then after finding the job we walk back along the path array to get to the start position adjusting traffic along the way.

Regarding the power; if I understand correctly the only way to disrupt power right now is to build a road over a wire, right? So if you change that so it makes a road under the wire (like when you place a wire on a road) the power can only expand to new cells (cells that are powered will never lose power). That way you only need to check the neighbors of each new cell to see if it’s powered (there are no new cells that require power but don’t spread it, so this should work)

EDIT: just played it again and it seems to do a lot better already. The limiting factor seems to be the drawing now, when I click on the traffic overview the game suddenly runs a lot smoother (pop 450 city).
EDIT2: I do realize this doesn’t make any sense, trees shouldn’t bee easier to render than buildings, but that’s what I’m experiencing
EDIT3: it doesn’t seem to slow down much more after that, I’m up to 1000 population right now :slight_smile: I did notice the traffic calculations might be wrong. I have a single road connecting my entire residential/commercial area to my entire industrial area and it’s only slightly congested.

I do really like the game btw, in case that wasn’t obvious :slight_smile:

Yeah, it is strange how often we code things that makes us later puzzled how we could have done it that obviously stupid way :slight_smile: Also, that’s why I love competitions like that, it let you learn on OTHER people mistakes, which is always nicer than learning on your own mistakes :slight_smile:

I was trying to suggest this: “I’ve changed any usage of arraylists to a strict array based approach. The array has to indexes one representing the top and the other representing the bottom. This means I can reuse the structure without any object creation or garbage collection.” :slight_smile: So, has it worked out better?

Land value - do not make any checks if people can inhabit it or not (can always inhabit). Instead make the income of R and C zones equal to base income*land value. It will be both more realistic and use less code.

Classes of buildings - well, maybe you could make simply numerical levels of these (without gfx) and when you hover the mouse over it you see the house level? Or dynamically change the colour of the building without changing the image? Not sure if these would work through…