Oh man, that's a tough one to get right. I recently gave
Flotsam (a town builder in early access) a try and one thing I noticed that gets on my nerves is that the villagers are
too freaking dumb.
First of all, when a building needs a resource they
don't pick the nearest storage but sometimes go halfway across town for no apparent reason. The same applies to storing resources of course, so that makes things much worse. That's already pretty stupid. But then there's the fact that can only carry up to five things at once, but cannot (for example) pick three units up in one storage department and two in another. So in the end they're wasting at least 50% of the time walking back and forth needlessly.
I know enough about programming to understand that this is a hard problem to to solve (especially if you have multiple actors all vying for the same resources) but goodness, it's so infuriating to watch and have zero control over.
Agreed, it's complicated and difficult to implement correctly. I do believe I have a good shot of getting it right.
Here's how the mechanic works:
At its' core, the game has "harvesters" and "storage sites". The harvesters can extract resources and move them between storage sites.
The storage sites have a CAPACITY and a DESIRED amount for each resource. Capacity is an intrinsic value while the "desired" amounts are fully controlled by the player.
Every harvester has a STRATEGY parameter which can take one of 3 values:
"Prioritize Nearest" - this will cause the harvester to load up on resources from the physically closest storage site (irregardless of its' 'desired' value) and bring the resources to its' target
"Prioritize Desired" - this will cause the harvester to load up on resources from the closest storage site where the "stored" amount is greater than the "desired" amount (i.e. the storage site has "excess" resources
"Prioritize Gathering" - if possible, the entity will gather raw resources to meet the "desires" of its' target storage site.
Moreover, every harvester has a priority list of resources, which controls the order in which he will transport the resources.
This allows for pretty good control without needing to baby the workers. Besides this, you also have full manual control - you can tell a harvester to chop a specific tree, or drop off resources at a specific site (as in classic RTS games).
Moreover, I am also focusing on "intelligence" of the workers. They handle all kinds of events gracefully. Tree chopped down? Move on to the nearest one. Source storage site destroyed? Move on to the nearest one. Needing to build a building? The peasant will transport required units (respecting priority and strategy parameters) and then immediately get to building. No need to manually set every single step.
This is all enabled by a decent pathfinding system. The units avoid each other and generally don't get stuck. (Though there are some iffy sticky cases that exist in the current build).
I'm going to demo it and talk about it in the next devlog.
Meanwhile, here's another screenshot: