Making of LLemMings

A plausible Basher type

ChatGPT: I am _very_ close to max context length here, may have to switch to GPT-4, but it's so darn slow.


There is implementation for Digger/Basher/Miner here, I only quickly tested Digger. But this looks
like another prompt/implementation worth taking a good look at.

>>> Prompt:
We are making a game with lemmings. There are three similar types of lemmings:
- Basher - The Basher will when encountering an obstacle it cannot traverse, instead of turning
around, carve a tunnel in front of it. That is, remove pixels in the background. The height of
the tunnel is the same as the height of the lemming (+ a few pixels maybe)
- Digger - The Digger works almost the same, except that it will not wait for an obstacle before
it starts digging. It will immediately start digging straight down. The hole it digs is a few
pixels wider than the lemming is wide.
- Miner - The Miner works almost the same as the Digger, the only difference is that it will dig
a tunnel diagonally downwards, in the direction it was walking. The size of the tunnel it is
digging is 150% of the height of the lemming.

They all need to be on the ground to be able to dig.

A lemming that has started digging is done digging when it no longer found anything to dig, it should
then be a normal lemming again (set action to null). Remember that the basher is slightly different
in that it will not start digging immediately, but only when it first runs into an obstacle.

Remember that they dig a little bit every frame (make it configurable how much, no instant tunnels),
they all dig at pace of around 20% of the normal walking pace.

They should remove 3 pixels in front of itself in order to be able to move through tunnel to continue
digging. When they are actually digging they should not turn around.

This is parts of the Lemming (object):

... <> ...

- You can find out what type it is by looking at the "action" property of a lemming.
- In addition to clearing (don't just change alpha, set all 4 bytes of a pixel to 0) in background.data,
do it in the collision layer too: oldImgData.data.
- The lemming.x/y/velX/velY are floats. Whenever you work with background.data or oldImgData.data, make
sure your indices are ints.
- Use already implemented functions: getPixelColor(imageData, x, y),
pixelIsColor(imageData, x, y, color) and
getPixelIndex(x, y, width).
Do bounds (canvas.width/height) checking before using these.
- Don't ever use ctx.getImageData() or ctx.putImageData(), it's handled elsewhere.
- Reuse functions where possible. If you use functions that are not in the snippet above, give me those
as well.
- Remove a pixel from the canvas using, e.g.: background.data[(y * canvas.width + x) * 4] = 0;.
- I suggest you make a new function to handle the different diggers, e.g.: startDigging(lemming).
- Make as much as you can configurable with consts.
- You don't need to give me lemming's update function, it calls startDigging() if a lemming is of correct type

You are not human. You are not allowed to make comments where you pretend to be one.
Give me only code, I don't need explanation.