Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Mob Spawning Algorithm Update of Beta (1.1_02)


  • Please log in to reply
108 replies to this topic

#1

xfs
    xfs

    Tree Puncher

  • Members
  • 23 posts

Posted 26 December 2010 - 05:14 PM

Mob Spawning Science thread is in a locked board.

Most described details in that thread are not changed. Here are some clarification and update for alpha 1.2.6 and beta 1.1_02.

Quote

mobs spawn in packs of up to 12
4 per chunk at a time, maybe less, no more.

Quote

2) Mobs can spawn on man-made materials.
Mobs only spawn on opaque blocks, don't spawn in liquid. Non-blocks, plants and liquid are obviously not opaque. But these are also not opaque:
leaves (only when graphics are fancy), glass, stone slab, monster spawner, wooden/cobblestone stairs, soil(60), snow, ice, cactus, fence.

Quote

3)Spawn activity only exists in a 144x144 area around you and not within 24m of you.
17x17 chunks area around all players are marked as eligible for spawning. These chunks are stored in a HashMap which doesn't guarantee traversal order.

Quote

7)There is a cap of 200 hostile mobs and 15 friendly mobs at any given time.
cap <= maxNumberOfCreatureType * numberOfEligibleSpawningChunks / 256
monster type is 100, animal type is 20. so 112 monsters and 22 animals for single player.

Quote

3) Roll a random number. 1:10 chance proceed to 4), otherwise skip chunk and go back to 2).
1:50 chance

Quote

6) If L1 is inside a rock or other solid area, bail out of the spawn function completely. Ignore the remaining chunks.
Only ignore this one chunk and process the remaining chunks

Quote

7) If L1 is legal it will be the location of a mob pack, pick 6 locations roughly normally distributed around L1, L(i)
12 locations. But there is also a local limit checking that should be added to the original algorithm:

14) ...
14-a) If there are already localLimit mobs spawned in this chunk, ignore remaining L(i). localLimit = 4 for any Living entities, or 1 for Ghast.
15) ...

Here is some "despawning" algorithms for why some mobs disappear after spawning:

    [*:1ju0hdfd]Proximity check of living entities happens once every tick. If any living entities are more than 128 meters away (Euclidean distance) from any players, they are set as dead.
    [*:1ju0hdfd]Idling check of living entities happens stochastically once every 40 seconds only for whom have been idle for more than 30 seconds. During this check, if anyone are more than 32 meters away (Euclidean distance) from any players, they are set as dead. If they are within 32 meters to some player during the check or they are taking damage anytime, their idle timers are set to zero. Monsters (except Ghasts and Slimes) idle 2 times faster than other living entities when light level >= 12.
    [*:1ju0hdfd]Chunk unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.

You're welcome to ask me if you find any inconsistency.

Edit: leaves are opaque when graphics is set to fast.
Edit: 12/30/2010
Edit: 12/30/2010
Edit: 1/14/2011 changed the title. Notch has modified the spawning algorithm. So I may look into it after MCP is updated to lastest version. I don't have time to read the source now before it's de-obfuscated.

Register or log in to remove.

#2

leaveittosteven

Posted 26 December 2010 - 05:15 PM

Opaque? Leaves? Monsters are still spawning atop my trees, on the leaves.
BETA

"When we release a pure bugfix update, people get VERY upset ("NOTHING CHANGED!").. Adding features gives us much happier users. But I do realize that it's only happier users in the short term." - Notch

#3

0xA4C639
  • Location: Cowering in a well-lit corner of my base.
  • Minecraft: Exschwasion

Posted 26 December 2010 - 05:15 PM

Wouldn't leaves count as opaque if graphics are on fast?
Would you like a mushroom soup with that?
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#4

xfs
    xfs

    Tree Puncher

  • Members
  • 23 posts

Posted 26 December 2010 - 06:32 PM

leaveittosteven said:

Opaque? Leaves? Monsters are still spawning atop my trees, on the leaves.
I tested it on a cleanroom like flat leaves map. No mob spawned. beta 1.1_02.

0xA4C639 said:

Wouldn't leaves count as opaque if graphics are on fast?
Block opacity is an element of game logic which won't be changed by user setting.

#5

mags1722

Posted 26 December 2010 - 06:45 PM

wait, so now they can spawn on halfsteps?

*edit- btw i've seen them spawn on leaves, i play on fast
Spoiler:

#6

xfs
    xfs

    Tree Puncher

  • Members
  • 23 posts

Posted 26 December 2010 - 07:04 PM

mags1722 said:

wait, so now they can spawn on halfsteps?

*edit- btw i've seen them spawn on leaves, i play on fast

Halfsteps now have an offical name: stone slab.

You are right. Leaves are turned to opaque when graphics is set to fast. I ignored this when dumping data.

Edit: only the opacity of this block is changed.

#7

triggerfin
    triggerfin

    Lapis Lazuli Collector

  • Members
  • 965 posts
  • Minecraft: Tfin

Posted 27 December 2010 - 08:18 AM

Thank you for this, xfs.

I hope you can keep this up to date, and get it fully organized to completely replace the old thread.
Fan Metric: Franc Time!

#8

Chezz
    Chezz

    Zombie Killer

  • Members
  • 169 posts

Posted 27 December 2010 - 07:12 PM

Awesome data!  I hope this thread stays up to date!

#9

thejaapsneep

Posted 27 December 2010 - 08:42 PM

sweet, sweet data

#10

fr0stbyte124
  • Location: (0,64,0)

Posted 29 December 2010 - 10:26 AM

Thanks for doing this.  I've been feeling guilty for not keeping up with the updates, and this is really helpful.

#11

CarloTheCurious
  • Location: London, UK

Posted 29 December 2010 - 08:57 PM

xfs said:

Quote

mobs spawn in packs of up to 12
4 per chunk at a time, maybe less, no more.

Quote

Quote

7) If L1 is legal it will be the location of a mob pack, pick 6 locations roughly normally distributed around L1, L(i)
12 locations

Seems inconsistent?

EDIT: Or does it pick 12 possible locations but only use 4?

#12

Rayziik
    Rayziik

    Redstone Miner

  • Members
  • 568 posts
  • Location: Eastern USA
  • Minecraft: Rayziik

Posted 29 December 2010 - 09:16 PM

Mobs can spawn on Double stone slabs, I've had many a creeper skydive kamikaze me from my roof made of them.

Double stone slab =  :)  on top of a  :D
Mods ruin Minecraft. Bronies are dumb. Herobrine is fake. Sue me.

#13

fr0stbyte124
  • Location: (0,64,0)

Posted 29 December 2010 - 10:34 PM

CarloTheCurious said:

xfs said:

Quote

mobs spawn in packs of up to 12
4 per chunk at a time, maybe less, no more.

Quote

Quote

7) If L1 is legal it will be the location of a mob pack, pick 6 locations roughly normally distributed around L1, L(i)
12 locations

I don't have my notes out, but I'm pretty sure it's now 4 sets of 3.  L(i) gets randomly offset from the previous move, then returns to L1 for the next set to keep the pack from spreading too far out.
Or maybe it was 3 sets of 4, now that I think of it.  Either way, 12 total.

#14

Deathviatar

Posted 29 December 2010 - 10:43 PM

Quote

17x17 chunks area around all players are marked as eligible for spawning. These chunks are stored in a HashMap which doesn't guarantee traversal order.

I've tested this multiple times, and NO mobs have been able to spawn in the outer 208 chunks, even when mobs aren't allowed to spawn in the inner 81 chunks.
Posted Image

#15

dave11
    dave11

    Diamond Miner

  • Members
  • 746 posts

Posted 29 December 2010 - 11:11 PM

xfs said:

Quote

3)Spawn activity only exists in a 144x144 area around you and not within 24m of you.
17x17 chunks area around all players are marked as eligible for spawning. These chunks are stored in a HashMap which doesn't guarantee traversal order.
Maybe I'm not clear on all the details yet about how the game works, but this seems like quite a big increase in size.
Am I missing something or wouldn't a nearly 4 times larger spawning area make the game quite a lot easier, at least if you don't move around a lot?

And are you also saying below this that the monster cap is actually lower now? 112 instead of 200? or am I wrong?
So fewer monsters in a much larger area then.
____________________________________________________________

#16

triggerfin
    triggerfin

    Lapis Lazuli Collector

  • Members
  • 965 posts
  • Minecraft: Tfin

Posted 30 December 2010 - 12:10 AM

dave11 said:

xfs said:

Quote

3)Spawn activity only exists in a 144x144 area around you and not within 24m of you.
17x17 chunks area around all players are marked as eligible for spawning. These chunks are stored in a HashMap which doesn't guarantee traversal order.
Maybe I'm not clear on all the details yet about how the game works, but this seems like quite a big increase in size.
Am I missing something or wouldn't a nearly 4 times larger spawning area make the game quite a lot easier, at least if you don't move around a lot?

And are you also saying below this that the monster cap is actually lower now? 112 instead of 200? or am I wrong?
So fewer monsters in a much larger area then.

I've no code to back it up, but my observations (in Clean Room, and using transparent textures) have been that mobs can despawn within the spawning radius, if they're far enough from the player. These were not just passing out of draw range, as I could see other mobs out beyond the ones that disappeared.

EDIT: forgot the point of that! If more distant mobs are randomly removed, eventually they build up closer to the player.
Fan Metric: Franc Time!

#17

xfs
    xfs

    Tree Puncher

  • Members
  • 23 posts

Posted 30 December 2010 - 08:00 AM

Rayziik said:

Mobs can spawn on Double stone slabs, I've had many a creeper skydive kamikaze me from my roof made of them.

Double stone slab =  :_:  on top of a  :_:

Yes, but double stone slabs are not stone slabs.

#18

xfs
    xfs

    Tree Puncher

  • Members
  • 23 posts

Posted 30 December 2010 - 08:09 AM

CarloTheCurious said:

xfs said:

Quote

mobs spawn in packs of up to 12
4 per chunk at a time, maybe less, no more.

Quote

Quote

7) If L1 is legal it will be the location of a mob pack, pick 6 locations roughly normally distributed around L1, L(i)
12 locations

Seems inconsistent?

EDIT: Or does it pick 12 possible locations but only use 4?
This is an update to the original algorithm. Now there will be 12 locations for "Individual Spawn Loops". And I thought there is a local spawning limit checking in the original algorithm between (14) and (15)? Anyway, it should be:
14) If mob class was Spider, roll a random number. 1:100 chance also spawn a skeleton and have it mount the spider.
14-a) If there are already localLimit mobs spawned in this chunk, ignore remaining L(i). localLimit = 4 for any Living entities, or 1 for Ghast.
15) Get next L(i) and go back to 8).
I think this can make mobs more possible to spawn on irregular terrains.

#19

xfs
    xfs

    Tree Puncher

  • Members
  • 23 posts

Posted 30 December 2010 - 09:20 AM

Deathviatar said:

I've tested this multiple times, and NO mobs have been able to spawn in the outer 208 chunks, even when mobs aren't allowed to spawn in the inner 81 chunks.

You raised an interesting issue. This thread is about how mobs are spawned, not how they are "despawned". However, as you've asked, I can answer this for you:

    [*:2599n1zy]Proximity check of living entities happens once every tick. If any living entities are more than 128 meters away (Euclidean distance) from any players, they are set as dead.
    [*:2599n1zy]Idling check of living entities happens stochastically once every 40 seconds only for whom have been idle for more than 30 seconds. During this check, if anyone are more than 32 meters away (Euclidean distance) from any players, they are set as dead. If they are within 32 meters to some player during the check or they are taking damage anytime, their idle timers are set to zero. Monsters (except Ghasts and Slimes) idle 2 times faster than other living entities when light level >= 12.
    [*:2599n1zy]Chunk Unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.

If you find it incomprehensible why mobs are spawned and killed, you have just learned what is Notch Logic.

#20

triggerfin
    triggerfin

    Lapis Lazuli Collector

  • Members
  • 965 posts
  • Minecraft: Tfin

Posted 30 December 2010 - 10:06 AM

xfs said:

You raised an interesting issue. This thread is about how mobs are spawned, not how they are "despawned". However, as you've asked, I can answer this for you:

    [*:2tsxtpz2]Proximity check of living entities happens once every tick. If any living entities are more than 128 meters away (Euclidean distance) from any players, they are set as dead.
    [*:2tsxtpz2]Idling check of living entities happens stochastically once every 40 seconds only for whom have been idle for more than 30 seconds. During this check, if anyone are more than 32 meters away (Euclidean distance) from any players, they are set as dead. If they are within 32 meters to some player during the check or they are taking damage anytime, their idle timers are set to zero. Monsters (except Ghasts and Slimes) idle 2 times faster than other living entities when light level >= 12.
    [*:2tsxtpz2]Chunk Unload. At least it may affect entities in some way, but I don't want to look into this part for now because related source is almost not de-obfuscated and difficult to read.

If you find it incomprehensible why mobs are spawned and killed, you have just learned what is Notch Logic.

32 meters!?
I'm reading "Euclidean distance" as meaning real-world measurement in 3 dimensions, like the 24 meter radius no-spawn bubble. Right? So there's only an 8 meter zone out there at 24-32 where mobs both can spawn and can't despawn? Interesting... but probably not something I can use right now.
Fan Metric: Franc Time!