As there's no fear to break threaded ai, as there really isn't distinct threaded ai yet (this patch is first to make it behave slightly different from classic which all users should still be using) I'm about to leave further improvements to future tickets.

- Mutex protection for city existence. Now there should be no possibility of crash because of lack of mutex protection. It's possible that some data it handles is inconsistent due to main thread modifying it at the same time, but I consider this part of the nature of current threadedd ai (we're not after 100% accurate results, but fuzzy heuristics of what is likely the best action)
- Evaluats road and base building tasks, assigning them only if player is able to build extras in question to the tile

This proof-of-concept patch adds first real work to threaded AI's subthread. In the beginning of the player phase, cities evaluate potential worker tasks in their area, and send best one to the main thread to set for the city. When workers then have time, they take these tasks.

This still needs a lot of work before it gives as good results as current model of settlers always looking for job themselves.
- Supports only a few worker tasks, no road or base building
- Assumes that any task it evaluates is possible, i.e., may request impossible tasks
- Virtually no mutex protection so threads may handle the city simultaneously leading them to get inconsistent values
- Does not give out values of the tasks. Worker may end working on almost-zero-value task of one city when nearby city has urgent task.
- Does not care about lenght of the work, only about value of sfinished work

Copyright (C) 2004-2006, the Gna! people. Posted items are owned by whoever posted them.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.