I am currently working on a City Builder Game and I often come across the problem of having to decide wich location to use.
- The citizen has a job and needs a home. There are several buildings with open slots.
- The citizen is at a positon and is hungry. There are several restaurants on the map.
How can I choose the right building to go to? I don't really wan't to check the distance for each, because there could potentially be hundreds of buildings and that decision problem occurs quite often.
I also don't care for the optimal solution, any nearby result is fine.
Currently all buildings register them self in a LinkedList. When searching for something I'd start at the beginning and the first occurrence that was 'good enough' would be returned. Citizen now drive across the map for something that was right next to them if the one far away was built earlier in the game.