HN user

Evbn

3,114 karma
Posts0
Comments2,823
View on HN
No posts found.

In the US, public transport is at least $20 per week, for a minimum commute.

x2 for 2 wage earners.

$1/day(!) per person is another $5 each.

Replacing worn out clothes adds a touch.

Water/sewer is ~$5/wk/person for very light use. Energy for light/heat/cooking is similar.

That is bare minimum for survival.

I obsess over price per ounce of my food while I am in the store. (Though it gets harder as I age and my brain weakens, and as prices and sizes get intentionally harder to compare)

Even still, I myself that groceries I eat are super cheap compare to food I throw away and restaurant meals. (And I avoid packaged meals and name brand cereal, which are near restaurant priced)

Every now and then I remember that the vast majority of people don't or can't think about food costs, and shudder. Paying $2 for a bottle of water with a scoop of sugar poured in. $5 for a box of Kellogs instead of $3 for generic. $4 for the frozen brocolli with fake cheese sprinkled top instead of $2 for plain. Etc

That is an example of a theoretical solution that may be overkill in practice, especially if you are stuck in JS. Unless you send window positions back to the server for analysis.

And can you code an AABB tree on a whiteboard? :-)

One could try placing the new window at (100x, 200y) for integer x,y, and check for intersection each time with all the existing windows. 3600 overlap tests in the worst case, but you get huge benefits in practice by hinting the location of the last new window.

Optimize a bit by sorting lists of windows by x and y, so you can binary search for the few candidates to overlap test, and you are down to about 1000 window checks. You miss some cases if windows are very maliciously aligned off grid, but you can mitigate that by using a slightly finer grid.

Or test the 8 neighbors (edges and corners) of each existing window (if any), as it is nearly impossible for available space to be not one of those positions.

(You can compute the next window position after the previous window creation or move, so there is no latency when rendering a new window.)

And an easy way to prevent massive revenue from unbalancing the game.

Remember that simcity is a socialist fantasy world: all development is directly purchased by central government. In the real world, zoning doesn't cost money, and stadiums are sometimes owner financed.