AngleWyrm / Colonies

Minecraft mod MineColony Reboot
7 stars 8 forks source link

Professional Citizens Go To Work AI Module #80

Open boycat97 opened 11 years ago

boycat97 commented 11 years ago

Tasks:

  1. Once citizens learn a profession they will now take on AI that allows for the following:
    • Search for a target.
    • Move to that target.
    • Commit an action, chop wood, fish, mine, build against that target.
    • Place an item from their inventory.
  2. Moving will activate the mutex bit for movement.

Classes that look promising for examples:

I would love any input on scope for the initial module, along with breaking this up in to additional classes for use.

AngleWyrm commented 11 years ago

Search performance can generate lag, if it's doing a set of nested loops over a large set of x,y,z coordinates. If it has to be a many-point search, then break it up into short stages that can be continued in future calls to the AI module. This is how the FindShelterFromRain search operates. It's also possible to set a tick counter so that it doesn't execute every update tick.

Breaking up jobs into sub-tasks is likely specific to the job. For example, a miner carries torches and lights the mineshaft along the way. This could be a separate task module for the miner: If light-level is low, place a torch. The Mining task could then have in it's reasons-to-idle section a minimum light level to continue work. If not met, then mining is done for the moment. Until the placetorch task gets accomplished.

For lumberjack, they chop trees, gather lumber and saplings, and plant saplings. Those might be three separate AI task modules..

A more global AI task, suited to everyone, could be emptying a full inventory into their place-of-employment chest.

boycat97 commented 11 years ago

Ok I have the beginning stages, thank you for the direction and codem on how to do the searching for the block. I will add a bit more but currently testing out what its like for the lumberjack to look for the wood block., he only runs to the wood of the tree for right now. There is quite a bit more work but at least its started.