mojira.dev
MCPE-49607

AI pathfinding never ends until their goal is reached

The bug

If an entity identifies a path, they will always attempt to execute it, even if it later becomes mostly (not fully) impossible, unless the player interacts with them via lead (moving them dozens of blocks), breeding, or leaving the world.

This report is not MCPE-46805 or MCPE-45527but does add to the problem.

 

There are many ways to reproduce this, including some that may not be listed here:

Method 1

  1. Make a large cubic area enclosed with any block or fence (suggested 11 x 11)

  2. Spawn about 32 of any equal sized mob

  3. Wait 1-3 minutes

At the end, every mob should be pushed towards one side or corner of the cube, constantly colliding off of each other, until the player interacts with them (in the ways listed above).

Method 2

  1. Make an enclosed 3 x 4 area

  2. Set up a tripwire on one of the two shortest sides

  3. Link it to a command block that teleports any mob (that will be used later) back into the box

  4. Place fences above the tripwire hooks, but leave the block above the tripwire (the string) clear

  5. Spawn a mob that's taller than one block

  6. Wait until they pathfind outside of the area

At the end, that mob should never stop attempting to leave the box until the player interacts with them (in the ways listed above).

Method 3

  1. Spawn a mob that can be leashed

  2. Leash the mob

  3. (optional) Place the lead on a fence

  4. Wait until they pathfind

At the end, that mob should never stop pathfinding in the same direction that they're attempting to, until the player interacts with them (in the ways listed above).

Method 4 (relates to method 3)

  1. Spawn a mob that can be leashed

  2. Leash the mob (do not place the lead on a fence)

  3. Place a fence and any full block next to each other

  4. Stand next to the fence as close as possible on any side (except for on top of the full block)

  5. Wait for the mob to pathfind

When the mob goes too far on the lead, they will come back and jump onto the fence (the block that the player is in) endlessly, until the player interacts with them (in the ways listed above).

Method 5

  1. Spawn a mob in a body of water (a generated ocean coastline or river is recommended)

  2. Wait until they pathfind onto land

  3. Quickly place a full block on land, directly in their way from leaving the water

At the end, they will endlessly jump in the water until the player interacts with them (in the ways listed above).

Related issues

Attachments

Comments

migrated
[media][media][media][media][media][media][media][media]
migrated

This happens to me as well, I constructed a river/coral area and every AI (tropical fish, dolphin, turtle and drowned) pathfinding kept going towards a goal they will never reach on the other side of an iron bar wall.

attached is a photo with mobs headed one direction, all of them constantly pushing eachother and another of the same but all mobs in one. they want whatever is on the other side!

Playing Windows 10 bedrock on a Realm.

 

[media][media]

 

Makzevu

That's not exactly what this report is about. Although the aquatic mobs pathfind endlessly to the other side of the iron bars, something is making them pathfind to the other side in the first place.

That fact alone might need its own report.

Auldrick

I've noticed this for a long time in my livestock pens (but didn't report it). Mobs frequently path to a corner, particularly a northwest corner. When several do it at the same time, the first one in can't get out because of the crush of the ones behind it, and the ones behind just keep trying to push it through the fence to satisfy their pathfinding goal. If you lure them away with food, you can break it up and they scatter, but eventually it happens again. It happens most often with cows because their collision box is so big they have a high probability of blocking each other's path in a narrow space, but it also happens regularly with my sheep.

[media]

[Mod] LateLag

@unknown - That would be MCPE-39073.

migrated

Happen on me as well.  windows 10 bedrock v1.14.30

[media]
migrated

Other perfect example:

Villager may seem like it is stuck to the gate. But, it is actually walking against it without walk animation. Push it off slightly, it will walk back to it, continued walking against it without walk animation.

This is problem for unaware people when the game stutter lag caused by a 1 or more mobs moving against at something in the area. You will have to find them and push them off to end the lag. Not very often thought but people wouldn't even think about the culprit.

Reproducible steps:

Spawn or find naturally spawned villagers
Build a small fence with a gate
Stand behind the gate where you can see the villager(s)
Open it and wait for one of them walk toward it
Close it as soon as it is getting close enough

Repeat if needed

Villager will be stuck to it
Squeeze in gently between the gate and a villager slightly
It will be in walking animated to the gate directly

GoldenHelmet

Evidently, once a mob AI selects a pathfinding target, it can only stop the movement behavior if it reaches the target or if a higher priority behavior becomes possible. The behavior needs to have a third way of finishing based on being stuck. It probably could safely be quite short, such as 1-2 seconds in which the mob’s location does not change by more than a tenth of a block.

migrated

Confirmed still an issue in the 1.16.0.51 beta. This bug causes many issues with gameplay, and device performance. Thus needs to be fixed as soon as possible.

migrated

Somewhat related but I've currently got a chicken, a pig, and a cow trying to pathfind INTO a chest. Not on top, but in the same spot as the chest. Their heads are partly inside the chest but they refuse to move. If they were trying to get on top of the chest they would jump, but there's no jumping.

[EDIT] I just found a cat trying to get into a Soul Sand block, the same way as with the chest above. No jumping, just constantly trying to get into the same spot as the block.

migrated

I've come up with a possible theory as to why this happens.

Here's how I think it works
1. Pick a random block near itself
2. Can it see the block? If not, go to step 1 (observed with fish trying to go through glass and iron bars and various land mobs trying to go through fences)
3. Does the block completely fill the space (is the block that's already there 1m x 1m x 1m)? If so, go to step 1 (observed with mobs trying to go into the same block as a chest)
4. Find the shortest route to that block, repeat until destination is reached (observed with a villager trying to find its bed but running into a wall, then moving around the wall)

How I think it should work (probably not exactly like this but sometime similar maybe?)
1. Pick a random block near itself
2. Can it see the block? If not, go to step 1
3. Does the block completely fill the space? If so, go to step 1
4. Is there any path to get to that block? If not, go to step 1 (this would be the first part of a fix)
5. Follow that path to get to that block.
6. Has it made it to its destination? If so, go to step 10.
7. Has anything new obstructed the path to that block? If yes, go to step 4.
8. Has X amount of ticks passed since trying to find a block to go to? If yes, go to step 6. (This would be a very short time to give the mob a chance to change its path)
9. Has Y amount of ticks passed since trying to find a block to go to? If no, go to step 6. (This would be a longer time to eventually stop them from trying to get to a spot it can't get to)
10. Stop moving and proceed with other things. (the eventual stopping point)

[EDIT} It seems that villagers are ignorant of the Y position of their destination (a bed for instance) if the X/Z position of their destination is closer than a path that leads them away from the X/Z before getting to the same Y. Not sure if that's a separate issue or related to this.

GoldenHelmet

@Brendan Hansen: I think what you are describing better fits MCPE-46805. Would you consider moving your comment to that ticket?

migrated

Affects 1.16.0.55.

migrated

Zombies have this issue, without hitting one of them, they never have the 4 second time out before pathfinding ends if the player is behind a wall. they indefinitely pathfind towards the player even if they cannot get to the player.

migrated

Affects 1.16.100.53

migrated

Affects 1.16.100.58 Beta.

TaikiTheWarrior

Affects 1.16.100.58 beta, hoglins that run away of fungus, keep running even if fall from a platform (like in a farm) to lava, making them swimming in lava. Also happen with any other mob than fall

migrated

Affects 1.16.100.59
Affects 1.16.100.60

migrated

AI pathfinding never ends when they try to go through a barrier wall (that's made from the border block), I've seen this a whole lot more than I should have.

TheTamedWolf

Yes the cows going into the corner happens all the time and it happens in Java too. I saw it while watching Hermitcraft. 

GoldenHelmet

Method 1 appears to be fixed by the fix for MCPE-41092 / MCPE-45800. I can still reproduce methods 2-5 in 1.17.11 Hotfix.

Methods 3-4 are the same as MCPE-47168.

Another repro method is described in MCPE-60160.

migrated

I've seen this happen many times in sheep pens, they will gather in corners and reduce wool generation efficiency because all of the sheep are standing on one dirt patch when there are plenty of grass blocks behind them

Auldrick

@unknown: The issue you're talking about was reported in MCPE-41092, which was fixed (finally!) in 1.17.10. It should no longer be occurring, and indeed, I saw it for years in my own world in cow and sheep pens but it has stopped happening now.

If you're still experiencing that issue, please comment about it and provide any additional information, such as screenshots, in MCPE-41092.

migrated

im still experiencing this issue in 1.18.2 just like in this picture : 

[media]
GoldenHelmet

Based on younes smati's screenshot I retested MCPE-41092, and it's not that bug. So it looks like just mobs getting pinned into corners by other mobs. Mobs actually do stop pathfinding in that situation, and if you watch animals in pens like the ones shown for a while you will see that the ones pushing into the corners stop and the stuck ones wander toward another part of the pen. It is possible for them to get perpetually stuck if you have too many mobs enclosed in a small area. But that's not a bug, it's just a result of how the pen is built. If you want to see animals wander in a more natural looking way, you need to give them more space.

Consider the details given for Method 1 in the description. An 11 x 11 fenced area contains 9 x 9 = 81 grass blocks. If you spawn 32 animals, that's less than 3 blocks for each animal to move around in without bumping another. Looked at another way, any time an animal tried to wander within the pen, there would be a 32/80 = 40% chance the destination spot it chose would already be occupied.

migrated

I hope that corner problem in that screenshot gets fixed somehow.

Anyway, I'm still having a lot of problems in 1.18 with singular mobs getting stuck on non-full blocks like gates, fences, glass panes, hanging lanterns etc. They just freeze in place, it seems like they're trying to get through gates and glass panes but can't, so they just freeze forever. This is not limited to cows etc, but villagers as well, which causes them to lose job sites and beds. This gets much worse in the 1.18 update, my villagers are getting stuck in places they were previously okay with, such as walls with glass panes, and a line of wooden gates.

There are also cases of Iron Golems and horses jumping repeatedly on carpets, causing them to freeze, and chickens not moving at all when surrounded with dead corals. This has been a bug for a long time.


Reply from @unknown:

Mobs getting stuck on blocks line panes and fence posts is tracked at MCPE-46805.
I've reopened your report on dead corals (MCPE-128687) since it was not fixed by the fixed to pathing on partial blocks.

Makzevu

I cannot reproduce this in 1.18.10.26 beta. Method 4 still occurs, but it's no longer endless (it's a different issue).

Makzevu

(Unassigned)

244137

Confirmed

Multiple

1909 (18363.535)

1.18.0.22 Beta, 1.17.40.20 Beta, 1.17.11 Hotfix, 1.17.0.54 Beta, 1.16.220.50 Beta, ..., 1.17.0, 1.17.2 Hotfix, 1.17.41 Hotfix, 1.18.0, 1.18.2 Hotfix

1.18.10

Retrieved