Jump to content

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

Mob Spawning Science


  • Please log in to reply
385 replies to this topic

#1

fr0stbyte124
  • Location: (0,64,0)

Posted 24 September 2010 - 07:47 AM

Sorry for the confusion causing.  This post details the way mob spawning worked prior to the Halloween update.  In the current version, the 0,0 exploit no longer works, and the bail-out clause has been removed entirely.  The spawnable region is now 17x17 chunks, mobs spawn in packs of up to 12, and to the best of my knowledge, slimes don't spawn naturally anymore.  Other than that, it hasn't changed too much.
I'll probably write it up properly one of these days, but for now this will have to suffice.



I've heard a lot of myths and rumors regarding the way mobs spawn and the best ways to capitalize on this.  So I've started doing some research.  Some of the information was collected via experimentation on codewarrior's CleanRoom map, a massive empty world which consists of one layer of adminium and one layer of wool above it.

Posted Image
The rest was gathered by decompiling the spawning code.  There are still a few gaps in our understanding of it, but nothing critical.  Special thanks to wabbiteh for helping me work out the algorithm.

Section 1: The Almighty Rules of Mob Spawning™:

1) Difficulty does not affect spawn frequency.
For reals.  This has been verified in code.  The spawning algorithm makes no check of the difficulty parameter in spawning mobs.  Even Peaceful technically has the same spawning rate, though the hostile mobs are removed immediately afterward.

2) Mobs can spawn on man-made materials.
Cobblestone, double steps :stair:, and wool work precisely as well as stone and dirt.  They will not spawn on glass or half steps  :_:, though.  There is no difference in frequency of spawns either.

3)Spawn activity only exists in a 144x144 area around you and not within 24m of you.
Specifically, it happens in the local 81 chunks around the player.  The minimum distance mobs can spawn from the player can be described as a spherical bubble with a 24m radius.
Looks like this:
Posted Image
Mobs also can't spawn within 24m of the player spawning point.

4) Large slimes can exist on peaceful.
While they won't spawn on peaceful, they will spawn on any other difficulty.  Unlike other hostile mobs, however, slimes won't disappear when switched to peaceful mode, even large ones.  If you kill a large slime on peaceful, it won't turn into mini-slimes.  Slimes can also spawn at any light level, but only in the bottom 15 layers.

5) Hostile mobs spawn at light level 7 or lower.  Friendly mobs spawn at 9 and above, and only on grass.
The light level of a tile is calculated in an odd way.  It's base light level is compared against the 4 tiles neighboring it and the air block above it.  The brightest of these blocks is considered the main tile's light level.  This means that even if a tile is level 7, if any of the neighboring blocks are 8, a hostile mob cannot spawn.
*edit* This expanded sensitivity is only for dirt and half-steps.  I have no idea why.

6) The probability of a hostile mob spawning on a specific tile is affected by the light level of that tile (and by properties of the surrounding region).
A random number R between 0 to 7 is rolled.  If the light level is ≤ R, a mob can spawn on that tile on that turn, so a pitch dark cave at level 0 will spawn mobs at 175% the rate of moonlit areas at level 4.  For reference, torches produce level 14 light, fire and sunlight produce 15, moonlight produces 4, and redstone torches produce level 7.  Every block removed from a light source, the level drops by 1.
To understand the regional affects, see section 3.

7)There is a cap of 200 hostile mobs and 15 friendly mobs at any given time.
Once the cap is reached, no new mobs can be spawned until some either die, despawn, or unloaded with a chunk.

8)Placing torches in one room won't affect the probability of mobs spawning in another room.
The exception, of course, is when the population cap has been reached.  A mob gets one shot to get placed in a chunk per turn.  If a torch prevents it from spawning, it doesn't get to repick its location, so no other location is affected by that torch.  In other words, you can't use torches to funnel mobs into a single area.

9)Slime spawns are broken.
All sorts of broken.  The algorithm takes the X,Y coordinates instead of the X,Z coordinates to locate the current chunk, on top of a seriously confusing random seeding operation.  But fear not.  This thread has a patch if you are interested. (Slimes will still be elusive creatures after the patch, just better distributed chunk-wise).

Section 2: The Spawning Algorithm:

The spawning algorithm is called typically 20 times per second.  It is executed twice per turn; once for hostile mobs and once for friendly mobs.

Main Spawn Loop:
1) Load all of the 81 local chunks into a semi-random list. (It is not truely random, but a specific order cannot be guaranteed)
2) If the list is not empty, take one chunk from the list.
3) Roll a random number.  1:10 chance proceed to 4), otherwise skip chunk and go back to 2).
4) Chose a mob class at random (for friendlies: pig,cow,chicken,sheep.  For hostiles: spider,skeleton,zombie,creeper,slime).
5) Chose a completely random location L1 within the chunk.
6) If L1 is inside a rock or other solid area, bail out of the spawn function completely.  Ignore the remaining chunks.
7) If L1 is legal it will be the location of a mob pack, pick 6 locations roughly normally distributed around L1, L(i)

Individual Spawn Loop:
8) Check that current L(i) is unoccupied, has spawnable ground below, and an empty space above.
9) If check fails, get next L(i) and go back to 8).
10) Check that L(i) is 24m+ from (any) player.  Also check they are 24m+ from the spawn point.  If not, get next L(i) and go back to 8).
11) Prepare mob for spawning (position, orientation, etc).
12) LGT(i) = light level of L(i)
13) (hostile mobs) Roll random R from 0 to 7.  If LGT(i) ≤ R, spawn mob at L(i).
13) (friendly mob) If LGT(i) > 8, spawn mob at L(i).
14) If mob class was Spider, roll a random number.  1:100 chance also spawn a skeleton and have it mount the spider.
15) Get next L(i) and go back to 8).
16) When done with all L(i), go back to 2).
17)return

(note: slimes have special rules regarding elevation and light levels, as mentioned in section 1)

Section 3: Discussion:
Assuming you are trying to maximize the number of mob spawns for a harvester or something, there are a few things that should be addressed.  The ideal spawning area is like that of CleanRoom: entirely empty space except for a single floor to spawn on.  In CleanRoom, mobs spawn so fast that at night it can reach the 200 mob cap within seconds.

The reason for this is that the bailout clause at step 6 is almost entirely avoided as only a mere 0.8% of the locations in the chunks are occupied by solid blocks.  Therefore, most of the time all 81 chunks get their chance to spawn a mob pack.

You might think that having multiple floors to spawn on would increase the spawn rate even more, having a larger surface area to work on.  While strictly speaking this is true, it also increases the chance of triggering the bailout clause which in the long run is far more harmful.

Assuming most people don't have the resources to dig out a 144x144 pit, the best thing you can do for your spawn rate is to find areas with low elevation and as many caves as possible.  The more open air there is, the better the spawn rate will be.  Even without mapping out the cave systems you can locate good places.  Explore around until you encounter an area with disproportionate amount of mobs.  Chances are that area will continue to support a high population of mobs.

Section 4: The Black Magic Spawning Tower:
The chunk traversal order is unique for every chunk the player is in, but there is one exception.  If the chunk (0,0) (blocks 0,0 to 15,15) is one of the 81 chunks visited, it will always be the first evaluated.  This can be exploited.  Regardless of the terrain, there is a 100% chance the algorithm will not bail out before getting to this chunk.  This means that chunk (0,0) has the highest chance of spawning mobs than any of the other 8 chunks.  It's as high as CleanRoom.

To illustrate this, I built a 19x19x64 tower over chunk (0,0) with 16 spawning floors.  After a couple of minutes there were about 150 mobs in the tower, and there probably would have been more if the cap hadn't been reached.
(glass was hacked in with NBTForge for your viewing convenience.  Original walls were rock.)
Posted Image
This technique should work on any map, and if I'm not mistaken, SMP, too (as of yet unverified).

To learn how to utilize this trick like a pro, check out Bucyruss's thread on the subject.

I may add a few more things in the future, but this is more or less the final version.
Hope it helps, and happy harvesting.

Register or log in to remove.

#2

freelife101

Posted 24 September 2010 - 07:49 AM

i like, should test which mobs spawn at ertain light strength's
Posted Image
Posted Image
Posted Image
Posted Image

RichardJames said:

I can destroy a mountain with a feather. What's so wrong about that?

#3

Alfa
    Alfa

    Diamond Miner

  • Members
  • 729 posts
  • Location: Victoria, Australia

Posted 24 September 2010 - 08:02 AM

I find the half-step spawning interesting, this would mean that if I covered my base with halfsteps I could never need to use torches! This could come in handy on coal-lacking new maps.

mrcrazymonkey said:

Have I've been trolled?

#4

fr0stbyte124
  • Location: (0,64,0)

Posted 24 September 2010 - 08:08 AM

freelife101 said:

i like, should test which mobs spawn at ertain light strength's
*edit*
Mobs can spawn in level 8 light or lower.  It's possible they can spawn in level 7, but I have yet to see that.  For reference, 0 is absolute darkness, moonlight is 4, redstone torches produce 7, regular torches produce 14, and sunlight is 15.  Light sources drop 1 level every block removed.

#5

Mine_Ender

Posted 24 September 2010 - 08:34 AM

Things to check:
* Spawn rate (how many per minute/night)
* Is spawn rate effected by the number of dark squares in the spawn radius (ie. multiple layers vs. one layer of black)

#6

U.C.
    U.C.

    Coal Miner

  • Members
  • 101 posts
  • Location: In my room, infront of a computer desk, in the middle of the night.

Posted 24 September 2010 - 08:53 AM

fr0stbyte124 said:


2) Difficulty does not affect spawn frequency.
In the CleanRoom map, I would get around 200 mobs present one every difficulty level except for peaceful.

That's actually a pretty significant find for me, I've always been sure there were more on easy but I guess this shuts me up on that.

#7

Chimbaru

Posted 24 September 2010 - 10:08 AM

fr0stbyte124 said:

2) Difficulty does not affect spawn frequency.
In the CleanRoom map, I would get around 200 mobs present one every difficulty level except for peaceful.
Brilliant find. I've been playing on Normal because I thought it was the hardest mode, but I'm definitely switching to Hard now.

Chimbaru gonna' Chimb.


#8

Steks
    Steks

    Void Walker

  • Members
  • 1747 posts

Posted 24 September 2010 - 11:05 AM

Awesome GJ i was hoping someone would do something like this.

#9

fr0stbyte124
  • Location: (0,64,0)

Posted 24 September 2010 - 12:29 PM

Ran a few more experiments.  Mobs can unload with the chunks, so I'm not sure what causes them to disappear normally.

Regardless of the time of day, mobs will continue to spawn (fairly quickly) in acceptable locations until the area reaches its saturation limit, after which no new mobs will spawn.  I'm still trying to figure out the rules determining the saturation limit.

Spawns are randomly distributed amongst all acceptable areas.  If there is only one available area, they will spawn quite densely.

Friendly mobs spawn twice a day, once at dusk and once at dawn.  Hostile mobs have no such limitation.

To optimize mob harvesting try these things:
1) Light up every cave within 70 squares of your spawning area.  You can use cartograph in cave mode to figure out which ones are unlit.  Also light up the surface, unless that is part of your machine.  This will force mobs to spawn in your spawn area.
2) Don't stand too near your spawning area.  Mobs won't spawn within 30 blocks of you.  Not sure if this counts the vertical axis or not.  If you need to draw them into your trap, include a safe way to enter/exit the chamber, such as a glass catwalk.

*edit*
Hostile mobs can spawn in at least level 7 light, and most likely 8.

#10

Armitige
    Armitige

    Diamond Miner

  • Members
  • 834 posts

Posted 24 September 2010 - 12:48 PM

I know that a monster can spawn in the square at the centre of 4 torches placed in a 7x7 square.

ex.
:--+: :Green:  :Green:  :Green:  :Green:  :Green:  :--+:
  :Green:  :Green:  :Green:  :Green:  :Green:  :Green:  :Green:
:Green:  :Green:   :Orange:  :Orange:  :Orange:   :Green:  :Green:
:Green:  :Green:   :Orange:    :Black:  :Orange:   :Green:  :Green:
:Green:  :Green:   :Orange:  :Orange:  :Orange:   :Green:  :Green:
:Green:  :Green:  :Green:  :Green:  :Green:  :Green:  :Green:
:--+:  :Green:  :Green:  :Green:  :Green:  :Green:  :--+:

  :Black: is the darkest point during the night (obviously) and is dark enough to spawn a monster.
:Orange: monsters will never spawn on these blocks or any blocks outside this area.
I've actually witnessed first hand a monster spawn in this fashion when my courtyard was lit by torches arranged in 7x7 squares in this fashion. I might be calculating incorrectly, but that black square would be at light level 8.
Posted Image

#11

X52
    X52

    Stone Miner

  • Members
  • 98 posts
  • Location: Nyköping, Sweden

Posted 24 September 2010 - 12:52 PM

Very good thread. I, like many others, thought it were less enemies on hard then on the other settings, but if this is true it shouldn't matter amirite? Keep this up, cant w8 to see what more you find...
Check out my 32-combination-lock using redstone :D
viewtopic.php?f=35&t=45018

#12

Icky Love

Posted 24 September 2010 - 01:00 PM

This should help me out with a topic I posted earlier.  Helps immensly.  Propose a sticky with the results!

#13

fr0stbyte124
  • Location: (0,64,0)

Posted 24 September 2010 - 01:21 PM

Armitige said:

I know that a monster can spawn in the square at the centre of 4 torches placed in a 7x7 square.

ex.
:--+: :Green:  :Green:  :Green:  :Green:  :Green:  :--+:
  :Green:  :Green:  :Green:  :Green:  :Green:  :Green:  :Green:
:Green:  :Green:   :SSSS:  :D  :Notch:   :Green:  :Green:
:Green:  :Green:   :Pig:    :Black:  :Pig:   :Green:  :Green:
:Green:  :Green:   :Pig:  :Orange:  :Orange:   :Green:  :Green:
:Green:  :Green:  :Green:  :Green:  :Green:  :Green:  :Green:
:--+:  :Green:  :Green:  :Green:  :Green:  :Green:  :--+:

  :Black: is the darkest point during the night (obviously) and is dark enough to spawn a monster.
:Orange: monsters will never spawn on these blocks or any blocks outside this area.
I've actually witnessed first hand a monster spawn in this fashion when my courtyard was lit by torches arranged in 7x7 squares in this fashion. I might be calculating incorrectly, but that black square would be at light level 8.
I've tried to confirm this myself, so far with no luck.  I got one spider and a creeper to spawn at level 7 light, but as of yet nothing has spawned at 8.  Perhaps the likelihood of a mob spawning is influenced by the light level of that square...

#14

niels
    niels

    Glowstone Miner

  • Members
  • 3862 posts
  • Location: I am not at places you think i can be
  • Minecraft: niels

Posted 24 September 2010 - 01:23 PM

Posted Image
i just had to do this...
Me on twitter :D

#15

X52
    X52

    Stone Miner

  • Members
  • 98 posts
  • Location: Nyköping, Sweden

Posted 24 September 2010 - 01:23 PM

niels said:

Posted Image
lol
Check out my 32-combination-lock using redstone :D
viewtopic.php?f=35&t=45018

#16

DemiImp
    DemiImp

    Carpenter

  • Members
  • 52 posts

Posted 24 September 2010 - 02:07 PM

I'd be curious as to know if there's specific type of spawns.  Such as, above my cave entrance there always seems to be a skeleton or 2 when I leave.  Sometimes spiders.  I don't think I've experienced creepers or zombies there though.

Underneath by base (it's a tower/sky base thing) there's usually a skeleton ready to shoot arrows at me.  Before I lit it up better/had most of the area get blown up by creepers, it'd usually include a zombie.  Usually creepers spawn a distance away from the entrance from my base, which means I only really see them when I decide to venture out in the night.

The skeleton underneath my base is probably the most reliable and I will now consider keeping an eye out for where it spawns.

#17

nocare
    nocare

    Zombie Killer

  • Curse Premium
  • Curse Premium
  • 219 posts

Posted 24 September 2010 - 02:17 PM

so the ultimate mob killing machine would be to take a 141x141 square cleared out to bedrock.

Then a 31x31 mob killer in the middle, then create some scaffolding so you can lure mobs and just stand in the center of the trap.

course you could always just build a 141x141x101 trap above ground too. But I like the idea of a dark hole of death much more :o

It's good information nonetheless, now I know why mobs weren't spawning in my previous spawn box, got a large area of caves they must be spawning in instead of my box

#18

Knightlord64

Posted 24 September 2010 - 02:35 PM

Can you test if mobs spawn on water?
Posted Image
Clicks would be much appreciated

#19

Bletzkarn

Posted 24 September 2010 - 02:52 PM

good thread, keep the research up.

#20

soul4hdwn

Posted 24 September 2010 - 02:53 PM

you didn't seem to test quantity for modes vs fequency.  are already know a minimum of a 3 cube location will spawn give or take a block in each direction from a testing black tunnel mob trap.