Hi there,
Some little corections on my own:
hwoarangmy {l Wrote}:2 - We just reduce the probability that they switch task. If so, how much ? Until when ?
MCmic {l Wrote}:When picked/dropped, pile is emptied and maybe the range used for action search is shorter.
IMHO, indeed, there are 2 kinds of behavior there. The standard one (when the worker was idling), the forced one, (when he was dropped near his new target).
I do sincerely think the code should reflect that as it will be much more straight-forward to do.
hwoarangmy has already coded the forced one (when dropped), and it is looking fine so far, so I won't elaborate more than necessary but he has described the worker action order in the forums and within the code. Just have a look:
https://github.com/OpenDungeons/OpenDun ... e.cpp#L797As for the standard behavior, the one when finishing a task, or when idling if you prefer, IMO:
- The chance to make a worker change unexpectedly from a task to another should be removed as it is hard to debug, and isn't what the player is expecting.
Later, we can always readd chances to make the worker go idle if it is tired or something, but this shouldn't be mixed now as the default behavior is still not reliable.
- In standard mode, the worker should always take the top most priority available action even when doing something else, as it is what the user will expect.
I.e.: If enemies come near-by, the worker will have to go in "battle mode", making it either flee or fight immediately, whatever the former action was.
- Here is the action priority list I have in mind for the standard mode, feel free to correct me: (but IMO it's quite the same than yours)
1. Fight (Look for enemies near-by)
2. Drop gold when full of gold.
3. Dig gold (Look for marked gold tiles. The nearest reachable first, the farther next.)
4. Drop whatever gold it has.
5. Dig (Look for marked tiles. The nearest reachable first, the farther next.)
6. Claim tile
7. Claim wall
8. Idle.
Again, the top most available action should be checked every turn or every few ones, in standard mode. This means a worker will stop claiming whenever some reachable tiles are marked to be dug. A worker will immediately start fighting/fleeing whatever it was doing before if enemies come, ...
What makes it hard to follow with those actions in the code atm, is the intermediate actions needed to make this work. I.e: The worker will have to "walk" before it can "dig", ...
Atm, the action related code is treating every actions at the same level (walk is an action as important as dig.). This means that workers can be stuck walking randomly for odd and edge cases AFAIK. Maybe some differentiation might later help with this? (I mean separate creature current action, from current objective? Thus treat objectives in a separate way than actions, making them shape actions, for instance?)
Also, in DK1, they added room detection support, where the AI detected when you add dug shapes corresponding to a fitting room. This is making the workers come around and claim tiles and walls in an optimized way, so you can start using your new room more quickly. IMHO, this can be left for later.
Regards,