Miner AI

Miner Digging AI

As a revamp to the Miner Digging AI I would suggest the following..

The Miner is changed to dig a vertical shaft rather than a stair..

This shaft is a 2x1 shaft, with a ladder (You now need to give him ladders) – on one of the x1 Side.. Every 5 levels he will place a torch on the other side of the shaft

















He will do this until he reaches his required depth (dictated by the level of building) – When you upgrade him, he will continue the same shaft downwards instead of starting a new one.

He digs this in the following manner.

The two blocks on plan are set exactly from the Chest.. I.e.  and  for example.

<p class="MsoNormal">He digs out the first two blocks, then places the ladder. Digs out the next two blocks and places the ladder and so on.. After placing the ladder, he checks if he is at <Chest Y-4> – if so he will place a torch in the correct place. After each placement of a ladder he will check if he is at the correct level to place a torch <Chest -9, Chest -14> etc.)

<p class="MsoNormal">When he gets to his set depth, he will begin to dig a spiral of tunnels as per the Spiral Tunnel Plan.

<p class="MsoNormal">

<p class="MsoNormal"> He will dig 2blocks from the tunnel at 90 degrees to the ladder, then turn right and dig 3 blocks, turn right and dig 5 blocks, turn right and dig 7 blocks and so on and so on.. Each time he digs 5 blocks in a straight line, he will turn right and dig a 2 block tunnel – this should connect up each layer of the spiral with the previous (shown above in Green) – this will drastically reduce his time walking about and getting back to his hut.

<p class="MsoNormal">As he digs, if he see’s anything on his target list of Blocks (Should be amendable from the Config File, so people can add blocks from other mods) he will dig out the whole vein

<p class="MsoNormal">As he is digging, as he digs each block, he should check all 6 blocks around it (block check)– in front, behind, left, right, above and below to see if that block is one of the target blocks – if so he will dig that block too – and check again. If this check returns more than 1 block to target, that blocks loc should be added to a “to mine” list, and he should return to it to mine it after a block check returns no more “target” blocks.

<p class="MsoNormal">This should ensure he mines out a complete vein, even if he starts in the middle of it.

<p class="MsoNormal">Once there are no more target blocks visible or on the “to mine” list, he will return to the last block on his tunnel path, and continue.

<p class="MsoNormal">If his tunnel path has an air, water, or lava block on the floor where he should stand, he will put a cobblestone there.

<p class="MsoNormal">If the block check shows a water or lava tile in an adjacent square, he will put a cobblestone there.

<p class="MsoNormal">Probably need some more logic to deal with falling blocks (i.e. he mines out a block, and a gravel/sand falls into it – he will need to recognise it is still full and remine. – perhaps add the block just mined to the block check too?)

<p class="MsoNormal">Miner should try and pick up anything he walks over (so potentially if he mines out a chest in a dungeon, the contents that spew out are picked up.) – If he mines out a mob spawner, this should not be retained.

<p class="MsoNormal">(Most of this is digging logic is likely as he currently operates.)

<p class="MsoNormal"> I would like to also see the following – the miners house has a redstone lamp block on it somewhere visible. If the miner AI gets stuck (i.e. it somehow senses it’s in a loop, or can’t get to where it’s trying to get, it turns the light on.  Giving the player the signal that the miner is in trouble.. The player can then go and search for the miner, or hit the recall button in the chest.) – This might be a pain in the ass to code!!