mojira.dev
MC-31153

Bias in passive mob AI - still results in self-stranding passive mobs, even with Northwest bug fixed

There is [still a] hidden bias in the passive mob AI causes them them to wander from their supposedly preferred terrain (grass) and then get 'locked in place'.

To reproduce, pick an island in an ocean biome, or some grass on the edge of a desert. (Or a grass island in the middle of the desert for clearer results.) Populate it generously with passive mobs. The more you use the more the bias is apparent. A few stacks of mob eggs should do.

Start mining, or just moving about in the area. As you move about, the mobs aboveground that are still in range will wander. Some will wander into the sea (or desert). Once out of range of grass, they will get 'lost' and wander randomly. As they're surrounded by water (or sand), with grass in only one direction, the probability is that wandering further at random will tend to make matters worse. Eventually you can find them so far out at sea they're out of sight of land! The screengrab is a max-zoomed map, marking my original island, and how far out at sea I was when I found some chickens swimming about. Not just one, there were several just in that one area. Around the whole island perimeter I estimate 40-60 chickens had made it out to that kind of distance. Splashing about in the shallows is one thing, but that's 200-300 blocks, which is ridiculous! What's more, once they're stuck, as soon as the player moves out of range again they freeze in place, which means they can't get back to shore again.

The result is a very considerable built-in bias that causes passive mobs to venture further and further and further into unsuitable terrain, most noticeably desert and sea - and also down caves. Even with the northwest bug fixed this still happens, it's just much slower.

Note also that the bias is [still] cumulative. It's not particularly notiecable after a few minutes, but the longer you operate in an area the further the mobs will wander. And once they do blunder somewhere inappropriate, either they wander raondomly, which means the odds against them finding their way home are low, or else the game freezes them there so they can never get back to suitable terrain again!

Linked issues

Attachments

Comments 13

I believe you are describing nothing more than standard entropy, given random motion, particles distribute themselves fairly evenly throughout their environment. I don't believe that there is any coding in minecraft to cause mobs to favour grass (other than spawning there initially.) If I am right, and you are saying that their movements should prefer grassy areas, then I think that's a feature request rather than a bug report

They're /documented/ as being attracted to grass. (And also light.) Animals supposedly attracted to grass that spontaneously set out on long, random-walk sea voyages when they already had a perfectly good island covered in grass on which to live, can hardly be said to behaving the way their AI presumably intends them to behave.

The 'randomness' part is a red herring. Roll a perfectly fair dice. If it's a one, stop rolling. Otherwise roll again. What's the inevitable long-term result? Even though the dice is a fair one?

Oh sorry, I hadn't red that they were attracted to them. Before they were persistent, the wiki said that the light attraction part at least, was a falsehood brought about by spawning patterns. I wish there was a reference though.

You didn't mention the direction of movement, but could this be a result of MC-10046?

It's possible. Note that the map pointer is NorthWest of the island, but the reason I found the mobs there was because /I/ was myself heading Northwest to an island at the top left of the map.

It would be nice to confirm whether passive mobs really are supposed to be attracted to grass, because if they are, I suspect there's two bugs; the NW bias, /and/ something else that is supposed to keep them near grass and is currently failing. The NW bias explains which way they go, but the failure of the 'keep near grass' algorithm would explain why they set out in the first place.

I would expect a 'keep near grass' rule to make the Northwest bias much less apparent, unless the terrain is either all grass, or, as here, /no/ grass.

3 more comments

I agree that this is no longer a duplicate of MC-10046, but the current behavior is probably intended. The last time I looked into the mob AI, it does have a weighting system for preferring certain blocks as destinations. However, I don't remember if that's the old AI or the new AI, and I think it was always a weak preference. I believe the behaviors are weighted to prefer random movement over the strict sort of rules you're suggesting.

The algorithm also has a limited search range, so if mobs wander outside the range of any of their preferred block types, they'll wander as you've described. There's not really anything that can be done about that – the larger the search radius, the more computationally expensive it is, and it will affect performance.

I think Mojang will have to make a decision on this one, but I think they'll either consider it part of Minecraft's charm, or they'll decide to rework the AI in the future, unrelated to this ticket.

Anthony Thyssen

All the wandering I have seen has mostly been the result of the north-west bias, which is supposedly fixed.

However the fact that even with this bais, mobs tended to swim out to sea shows that most passive mobs do not even try to stay in grassy areas. They do migrate toward sky lit areas, but not grass. or at least avoid 'water' area.

Ideally passive land mobs (sheep, cows, chickens, and now rabbits) should make a few random destination rolls, then pick preferentially sky lit, grass (mycellium for mooshrums), then dry land, and only select water, if all the random choices was water.

That is not to say mobs won't swim across rivers or lakes to get to the grass on the other side, but at least they shouldn't drift out to sea, unless left no choice.

An easy fix for this would be to penalize 2 deep water in the AI, mobs would be free to splash in the shallows, but would have a lot less chance to be stranded.

Anthony Thyssen

+Ryan Leach Mobs don't stand in shallows they swim!
if that was to change it would likely break a lot of things, especially mob-a-vators, something that has been in the game since it was beta!

However the AI has been resolved. There is a different bug involving mobs not swimming very fast if they decide to change direction while in water, resulting in mobs getting stuck in ponds and rivers, especially chickens, but that is not this bug.

Is this still an issue in the most recent versions (currently that is 1.10.2, or 16w43a) of Minecraft? If so, please update the affected versions and help us keeping this ticket updated from time to time. If you are the owner/reporter of this ticket, you can modify the affected version(s) yourself.

Simons Mith

michael

Community Consensus

AI, animal, mob, pathing, swimming, water

Minecraft 13w37b, Minecraft 14w25a

Retrieved