# Ludios exists in 74.9% of dungeons

318 views

### Robert R. Schneck

Oct 18, 2002, 9:16:50â€¯PM10/18/02
to
So, I modified the source to create a series of random dungeons, and
then create each non-special level from Dlvl 11 to Medusa inclusive.

Out of 1 000 000 dungeons, 748 850 had Ludios, about 74.9%.

Corroborating evidence: a couple of years back I posted a formula
which will give the chance of Ludios if you can tell it the chance
that a normal level has a vault (see
for this). Of the 12 233 838 normal levels I created, 4 281 342 had
vaults. That's ever so slightly under 35%, leading to a calculated
Ludios chance of 74.87% or so.

These percentages are lower than I expected. In particular, I had
always thought that almost every level that has the chance to get a
vault, gets one, which is to say almost half. That would lead to a
Ludios chance of closer to 85%. Instead, it seems like the other
requirements for getting a vault fail considerably often. I wonder if
it's coincidental that my experimental vault percentage is so close to
exactly 35%; I find the mklev.c code too hard to know for sure.)

Robert

### Great Erdrick

Oct 20, 2002, 12:13:52â€¯PM10/20/02
to
> Corroborating evidence: a couple of years back I posted a formula
> which will give the chance of Ludios if you can tell it the chance
> that a normal level has a vault (see
> for this). Of the 12 233 838 normal levels I created, 4 281 342 had
> vaults. That's ever so slightly under 35%, leading to a calculated
> Ludios chance of 74.87% or so.
>
> These percentages are lower than I expected. In particular, I had
> always thought that almost every level that has the chance to get a
> vault, gets one, which is to say almost half. That would lead to a
> Ludios chance of closer to 85%. Instead, it seems like the other
> requirements for getting a vault fail considerably often. I wonder if
> it's coincidental that my experimental vault percentage is so close to
> exactly 35%; I find the mklev.c code too hard to know for sure.)
>
> Robert

I have taken a look at your old post and I think that you forgot
something, that Ludios caon only appear once per game. For example, if
Ludios have 35% chance to appear on level 1 and 40% chance to appear on
level 2, the actual chance that it will appear in this game is:

35% + 40% * (1 - 35%)

that is, the chance that the portal appear on level 2 is also affected by
level 1, to have the portal appear ob level 2, it must not appear on level
1, so for level 2: [chance that it appear on level 2] * [chance that it
doesn't appear on previous levels].

I don't fully understand your old post but that might explain why the
actual result is lower than you expected...

- Great Erdrick

### Robert R. Schneck

Oct 20, 2002, 4:04:09â€¯PM10/20/02
to
Great Erdrick <lone...@videotron.ca> said:
> I have taken a look at your old post and I think that you forgot
> something, that Ludios caon only appear once per game. For example, if
> Ludios have 35% chance to appear on level 1 and 40% chance to appear on
> level 2, the actual chance that it will appear in this game is:
>
> 35% + 40% * (1 - 35%)
>
> that is, the chance that the portal appear on level 2 is also affected by
> level 1, to have the portal appear ob level 2, it must not appear on level
> 1, so for level 2: [chance that it appear on level 2] * [chance that it
> doesn't appear on previous levels].

In fact, I measure the chance that Ludios *doesn't* exist, so no such
problem. (For example, in your example the chance of no Ludios on the
first two levels is 65%*60%.)

> I don't fully understand your old post but that might explain why the
> actual result is lower than you expected...

It's the experimental results that are surprisingly low. The
theoretical result agrees with experiment. (As far as it goes: I have
no theoretical result on the chance of a level getting a vault.)

Robert

### Dylan O'Donnell

Oct 21, 2002, 5:28:36â€¯AM10/21/02
to
"Robert R. Schneck" <sch...@math.berkeley.edu> writes:
> These percentages are lower than I expected. In particular, I had
> always thought that almost every level that has the chance to get a
> vault, gets one, which is to say almost half. That would lead to a
> Ludios chance of closer to 85%. Instead, it seems like the other
> requirements for getting a vault fail considerably often. I wonder if
> it's coincidental that my experimental vault percentage is so close to
> exactly 35%; I find the mklev.c code too hard to know for sure.)

Well, the hard code is in rect.c (split_rect()) and sp_lev.c
(create_room()); makerooms() in mklev.c is straightforward enough.

Rooms are created until the rectangle code says "sorry mate, no more
space"; each room created after the sixth has a 50% chance of being
Just _how_ the rectangle code decides what slices of levelspace to
allocate or not is the tricky part :-)

--
: Dylan O'Donnell http://www.spod-central.org/~psmith/ :
: "It is pitch black. You are likely to be eaten by a grue." :
: -- Dave Lebling and Marc Blank, "Zork" :

### Robert R. Schneck

Oct 22, 2002, 8:11:33â€¯AM10/22/02
to
Dylan O'Donnell <psm...@spod-central.org> said:
> Well, the hard code is in rect.c (split_rect()) and sp_lev.c
> (create_room()); makerooms() in mklev.c is straightforward enough.
>
> Rooms are created until the rectangle code says "sorry mate, no more
> space"; each room created after the sixth has a 50% chance of being
> Just _how_ the rectangle code decides what slices of levelspace to
> allocate or not is the tricky part :-)

It's not quite so simple. Once a room passes the 50% chance, the call
to create_vault() still might fail; and even then, there's a later
call (in makelevel()) to check_room() which might fail before it
becomes a vault. Moreover, if the call to check_room() fails, there's a
last-ditch attempt to get a different vault with new calls to
rnd_rect(), create_vault(), and check_room().

I did another million levels.
On 35695 there were too few rooms for a vault;
on 170627 none of the 50% chance checks passed;
on 143455 create_vault() failed;
on 299852 check_room() failed;
but on 618 of those levels, the last-ditch effort yielded a vault.
(For a total of 350371+618=350989 vaults.)

Robert

### Dylan O'Donnell

Oct 23, 2002, 4:33:39â€¯AM10/23/02
to
"Robert R. Schneck" <sch...@math.berkeley.edu> writes:
> Dylan O'Donnell <psm...@spod-central.org> said:
> > Well, the hard code is in rect.c (split_rect()) and sp_lev.c
> > (create_room()); makerooms() in mklev.c is straightforward enough.
> >
> > Rooms are created until the rectangle code says "sorry mate, no more
> > space"; each room created after the sixth has a 50% chance of being
> > Just _how_ the rectangle code decides what slices of levelspace to
> > allocate or not is the tricky part :-)
>
> It's not quite so simple. Once a room passes the 50% chance, the call
> to create_vault() still might fail; and even then, there's a later
> call (in makelevel()) to check_room() which might fail before it
> becomes a vault. Moreover, if the call to check_room() fails, there's a
> last-ditch attempt to get a different vault with new calls to
> rnd_rect(), create_vault(), and check_room().

Aha. I'd assumed that create_vault() wouldn't be failing under normal
circumstances, and the check for success was just the standard
defensive coding for gracefully handling it if it ever did; clearly
it's more complicated than that (as noted, create_room() is the hard
code :-)

> I did another million levels.

[...]

> (For a total of 350371+618=350989 vaults.)

So, the proportion of "normal" Dungeon levels with vaults is pretty
firmly empirically established at about 35%; I'll amend room-340.txt
accordingly. Thanks for running these trials.

### Rast

Oct 23, 2002, 7:23:59â€¯AM10/23/02
to
Dylan O'Donnell wrote on 23 Oct 2002 09:33:39 +0100 in article
<86wuo9l...@strackenz.spod-central.org>:

> > I did another million levels.
> [...]
> > (For a total of 350371+618=350989 vaults.)
>
> So, the proportion of "normal" Dungeon levels with vaults is pretty
> firmly empirically established at about 35%; I'll amend room-340.txt
> accordingly. Thanks for running these trials.

I wonder if the original poster would be willing to generate a few million
copies of DL2 to determine how often a shop is actually created:
a. If there are the stairs to the Mines on the level.
b. If there are not stairs to the Mines on the level.

Also it would be interesting to know:
c. How many item spaces the average shop has.
d. How often a wand store or a book store gets turned into a general store

--
"Sometimes I stand by the door and look into the darkness. Then I
am reminded how dearly I cherish my boredom, and what a precious
commodity is so much misery." -- Jack Vance

### Robert R. Schneck

Oct 23, 2002, 7:23:01â€¯PM10/23/02
to
Rast <ra...@hotmail.com> said:
> I wonder if the original poster would be willing to generate a few million
> copies of DL2 to determine how often a shop is actually created:
> a. If there are the stairs to the Mines on the level.
> b. If there are not stairs to the Mines on the level.

I was surprised to find that it (almost) doesn't matter. In fact, the
mines stairs are placed *after* the shop is made. There's even a
non-zero chance that the stairs end up inside the shop (but the chance
is somewhat less than one in 10^60... so don't hold your breath).

There's only about a 45.3% chance of getting a shop. This is lower than
I expected. Another 44.9% of the time there's no room with one door;
the remaining 9.8% of the time there are stairs in all such rooms. The
"almost" from the preceding paragraph is that, if you are at the mines
branch level, the chance of having too few rooms is greater, but I saw
it on only 365 in a million levels (as opposed to 0 in a million on
non-branch levels).

(A slightly related oddity: it looks like there's a buglet in the
[normal] stairs placement so that the upstairs is very rarely in the
rightmost room, and only if the downstairs is in the
second-to-rightmost. This means that the rightmost room is more often
free to be a shop; and if not, then the leftmost is free.)

> Also it would be interesting to know:
> c. How many item spaces the average shop has.
> d. How often a wand store or a book store gets turned into a general store

c. 19.9.
d. 52% of the time.

Here's some more data, if you're interested in shop sizes:

Levels: 1000000 (No mines)
Shops by size of room:
4:563 6:8871 8:6366 9:31297 10:5272
12:48518 14:2947 15:37118 16:18461 18:29876 20:28369
21:15460 22:861 24:34515 25:11384 26:748 27:12134 28:11138 30:27534
32:9040 33:3803 35:8674 36:18158 39:3692 40:14883
42:10360 44:2939 45:7082 48:8159 50:6097
52:3473 54:4482 55:2583 56:5878 60:7666
65:3531 66:1502
Shops by size of shop:
2:563 3:3697 4:7651 5:2288 6:37199 7:1346 8:25042 9:24805 10:22076
11:493 12:51260 13:444 14:8385 15:26905 16:19452 18:27154 20:25719
21:11989 22:2116 24:27889 25:7918 26:2162 27:8948 28:10700 30:17599
32:7310 33:3330 35:5860 36:14263 39:3994 40:9439
42:6591 44:2561 45:4557 48:6082 50:2548
52:4321 54:2916 55:2625 60:3237
Total: 453434 Av. room size: 25.001469 Av. shop size: 19.879914
Wand and book: 27228, with 14078 made general
Too few rooms: 0
No room with one door: 448526
Stairs in all such rooms: 98040

Levels: 1000000 (Mines)
Shops by size of room:
4:573 6:8939 8:6519 9:30948 10:5153
12:49002 14:2982 15:37116 16:18295 18:29826 20:28724
21:15575 22:846 24:33918 25:11482 26:790 27:12146 28:11131 30:27440
32:9080 33:3749 35:8542 36:18367 39:3669 40:14699
42:10197 44:2821 45:6896 48:8405 50:6262
52:3406 54:4640 55:2581 56:5969 60:7498
65:3472 66:1439
Shops by size of shop:
2:573 3:3744 4:7801 5:2245 6:36835 7:1376 8:25316 9:24939 10:21941
11:484 12:50844 13:488 14:8409 15:27351 16:19583 18:27187 20:25594
21:11926 22:2135 24:27769 25:7748 26:2156 27:9170 28:10651 30:17540
32:7039 33:3296 35:5792 36:14223 39:3999 40:9435
42:6667 44:2648 45:4561 48:6246 50:2496
52:4393 54:2796 55:2549 60:3152
Total: 453097 Av. room size: 24.979269 Av. shop size: 19.861275
Wand and book: 27282, with 14107 made general
Too few rooms: 365
No room with one door: 448833
Stairs in all such rooms: 97705

Robert

### Rast

Oct 23, 2002, 8:23:40â€¯PM10/23/02
to
Robert R. Schneck wrote on Wed, 23 Oct 2002 23:23:01 +0000 (UTC) in article
<ap7b0k\$1hlr\$1...@agate.berkeley.edu>:

> There's only about a 45.3% chance of getting a shop.

So can we say that for lower levels, the actual chance of a shop is about
.151 * DL ?

> This is lower than I expected.

Fits in with my experiences.

> Another 44.9% of the time there's no room with one door;
> the remaining 9.8% of the time there are stairs in all such rooms.

I don't understand this. You said stairs are placed after the shop is
chosen? Or just the Mines stairs?

> > c. How many item spaces the average shop has.

> c. 19.9.

-snip data- And the median shop size is 16.

> > d. How often a wand store or a book store gets turned into a general store
>

> d. 52% of the time.

Hmm, so those shops are twice as rare as the spoiler would indicate...

By the way, is the number and size of rooms on a level at all dependant on
DL? I'd imagine not, but just checking.

Hey, when you generate these levels, does it generate items too? If so,
what's the chance of finding the following on DL2...

One or more /oW? /oDeath? /oPoly?
" " " speed boots?
" " " power gloves?
" " " magic whistle?
" " " bag of holding?
Magicbane or a cloak of magic resistance?
An amulet or shield of reflection?
A good artifact weapon? (Grayswandir, *brand, Magicbane, Mojo, Stormbringer)
Any artifact weapon at all?
One magic lamp?
Two magic lamps?
Three or more magic lamps? (yeah right)

An altar?
Altars of two different alignments?
Altars of all three alignments?

### Robert R. Schneck

Oct 24, 2002, 8:55:26â€¯PM10/24/02
to
Rast <ra...@hotmail.com> said:
[stairs vs. shops]

> I don't understand this. You said stairs are placed after the shop is
> chosen? Or just the Mines stairs?

Just the mines stairs. Ordinary up & down stairs are placed first.

> By the way, is the number and size of rooms on a level at all dependant on
> DL? I'd imagine not, but just checking.

As far as I can tell, no.

> Hey, when you generate these levels, does it generate items too? If so,
> what's the chance of finding the following on DL2...

It does generate items (and monsters... in fact, I have to reset the
born counter to avoid extinction-related problems). I think the more
interesting question is DL1, myself. I will probably try to answer
your question, but not for a few days (I do have to do productive work
too). I think item-related probabilities can be obtained directly
from analysis of the code, given a probability distribution for the
number of rooms. (Though it's probably easier just to run the
experiment.)

Robert

### Dylan O'Donnell

Oct 25, 2002, 6:05:29â€¯AM10/25/02
to
"Robert R. Schneck" <sch...@math.berkeley.edu> writes:
> Rast <ra...@hotmail.com> said:
> [stairs vs. shops]
> > I don't understand this. You said stairs are placed after the shop is
> > chosen? Or just the Mines stairs?
>
> Just the mines stairs. Ordinary up & down stairs are placed first.

The important stages of level creation, picked out from mklev() and
makelevel(); Rogue levels skip some of these.

Assign level-dependent object probabilities (at present, just the
range of possible gems).
If this is a predefined level or a maze level, make that instead and
skip down to "Mineralise"; otherwise, carry on through this list.
Place the rooms. Chance of a vault being made here.
Place the normal up and down stairs, in different rooms if possible.
Lay out the corridors.
If makerooms() didn't give us a vault, possibly create one now.
Make a shop or special room(s), if wizmode SHOPTYPE or the dieroll call
for one it.
Place branch stairs or portal.
For each ordinary room, put things inside (varying chances of each):
Monster or monster group.
Traps and mimics.
Gold.
Dungeon furniture: fountains, sinks, altars, graves.
Statues.
Boxes/chests.
Engravings.
Random objects.
Mineralise the rock with gold and gems, add kelp to water.

: "Go not to Usenet for counsel, for they will say both :
: 'No' and 'Yes' and 'Try another newsgroup'." :
: -- Usenet Rule 17. :

### Jukka Kuusisto

Oct 25, 2002, 7:55:46â€¯AM10/25/02
to
psmit...@spod-central.org (Dylan O'Donnell) writes:

>For each ordinary room, put things inside (varying chances of each):
> Monster or monster group.

Does this mean that monsters are never generated in corridors? What
about monster generation that occurs after the level has been visited?
What about areas that have been dug out of stone?

-Jukka
--
Jukka Kuusisto

### Robert R. Schneck

Oct 25, 2002, 8:47:02â€¯AM10/25/02
to
Dylan O'Donnell <psm...@spod-central.org> said:
> The important stages of level creation, picked out from mklev() and
> makelevel(); Rogue levels skip some of these.
[...]

> Place the rooms. Chance of a vault being made here.
[...]

> If makerooms() didn't give us a vault, possibly create one now.

I actually think this second stage takes the pre-vault created by
makerooms(), and uses check_room() to decide if it actually *is* a
vault. (Maybe because corridors could have gotten in the way?) Only
at this stage is add_room() called (create_room() usually calls it,
but not when it's create_vault()), and zorkmids appear.

Robert

### Dylan O'Donnell

Oct 25, 2002, 9:50:05â€¯AM10/25/02
to
jkuu...@cc.hut.fi (Jukka Kuusisto) writes:
> psmit...@spod-central.org (Dylan O'Donnell) writes:
>
> >For each ordinary room, put things inside (varying chances of each):
> > Monster or monster group.
>
> Does this mean that monsters are never generated in corridors?

Not at level-generation time. Wizmode-confirming this is easy; wish for
and quaff a blessed potion of monster detection, then ^V and ^F down
the dungeon. All in rooms.

(Strictly speaking, this isn't quite true; while the seed monster of a
group is always inside a room, the subsequently-created members can
straggle out into the corridor. Also, mimics can be created in
doorways, but that's a special case.)

> What about monster generation that occurs after the level has been
> visited?

That can be in any viable-for-a-monster-to-be-in space, with a
significant effort made to have it be out of sight if possible.

> What about areas that have been dug out of stone?

Once you've dug it, monsters can appear in it.

### Boudewijn Waijers

Oct 25, 2002, 5:46:04â€¯PM10/25/02
to
Dylan O'Donnell <psmit...@spod-central.org> wrote:
> jkuu...@cc.hut.fi (Jukka Kuusisto) writes:
>> psmit...@spod-central.org (Dylan O'Donnell) writes:

>> What about monster generation that occurs after the level has been
>> visited?

> That can be in any viable-for-a-monster-to-be-in space, with a
> significant effort made to have it be out of sight if possible.

"Out of sight" meaning out of eye-sight, I guess.

I was just strodding around blinded, with telepathy, and a group of orcs was
created next to me in the same room...

I am fairly sure that they were *not* created in, say, a corridor behind the
room's wall, but I could be mistaken.

--
Boudewijn Waijers (bwaijers at tiscali.nl).

"Xander, stop reading Latin in front of the books!"
- Rupert Giles, in "Buffy, the Vampire Slayer".

### Dylan O'Donnell

Oct 28, 2002, 4:30:25â€¯AM10/28/02
to
"Boudewijn Waijers" <bwai...@tiscali.REMOVETHIS.nl> writes:
> Dylan O'Donnell <psmit...@spod-central.org> wrote:
> > jkuu...@cc.hut.fi (Jukka Kuusisto) writes:
> >> psmit...@spod-central.org (Dylan O'Donnell) writes:
>
> >> What about monster generation that occurs after the level has been
> >> visited?
>
> > That can be in any viable-for-a-monster-to-be-in space, with a
> > significant effort made to have it be out of sight if possible.
>
> "Out of sight" meaning out of eye-sight, I guess.

It looks at whether you can see the location, not a monster there. So,
ESP doesn't count as "sight", but astral vision from the Eyes does.

> I was just strodding around blinded, with telepathy, and a group of
> orcs was created next to me in the same room...

("strodding"?) Be careful with using group monsters as examples; creation
restrictions often only apply to the initial seed monster, and the other
members of the group get placed where another monster might not.