[Solved] Weird randomness

Found a bug in R'n'D? Report it here!

Moderators: Flumminator, Zomis

Post Reply
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

[Solved] Weird randomness

Post by Zomis »

This bug was found by Darkon and can be seen in his multiplayer battle levelset. I have also made an example level displaying this bug which can be downloaded here.

This level uses 4 Group Elements, which are linked together (see the GE settings). So when the level is generated (starts), you can see that there amount of elements in GE4 is pretty much equal to the amount of GE3. But shouldn't GE4 be more rare than GE3?

I have checked this level and calculated the amount of items twice, and here's my results:
This is showing the group, the element, and the amount of elements I got.

Code: Select all

0 sand		12
0 BD Emerald	15
1 emerald	10
1 diamond	8
2 balloon	5
2 dynamite	5
2 speed pill	2
2 fuel		1
3 bomb		5
3 explosion	5
3 power		0

0 sand		20
0 BD Emerald	16
1 emerald	7
1 diamond	9
2 balloon	3
2 dynamite	4
2 speed pill	3
2 fuel		5
3 bomb		4
3 explosion	3
3 power		4
The higher group number the more rare they should become, but group 2 and 3 above (i.e. GE3 and GE4 in the game) are pretty equal in rareness...
Last edited by Zomis on Sat Apr 23, 2005 3:47 pm, edited 1 time in total.
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

Although this could be seen as a bug, it is indeed intended behaviour. As you have described, one might expect elements in a group element that is part of another group element containing further 9 "real" elements to only show up in 10% of the time when using the "random" method.

But this is not how it works internally. Before the game starts, all group elements are recursively "expanded" to "flat" group elements without any recursive definitions. Knowing this, it's immediately clear why and how the random element selection works as it does.

It was implemented this way to prevent the game engine from being forced to recursively step through a (probably very deep) recursion when selecting an element from a group element.

I know that the different behaviour expected by Zomis may be desired in certain cases, and I may add such a behaviour in later versions, depending on how much it is needed by level creators.
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

Holger wrote:I know that the different behaviour expected by Zomis may be desired in certain cases, and I may add such a behaviour in later versions, depending on how much it is needed by level creators.
Well, I know that Darkon has used it in his multi player battle levelset.

So would it work to use one GE which holds all other GEs, but in different amounts? (for example, 6 common, 4 pretty rare, 2 rare, 1 very rare, 3 empty) and in the other GEs hold all other elements (emeralds, diamonds, sand, rock, etc.)
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

>So would it work to use one GE which holds all other GEs, but in different
>amounts? (for example, 6 common, 4 pretty rare, 2 rare, 1 very rare, 3
>empty) and in the other GEs hold all other elements (emeralds, diamonds,
>sand, rock, etc.)

Apparently it does:
http://www.zomis.net/rnd/download.php?id=362
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

> >So would it work to use one GE which holds all other GEs, but in different
> >amounts? (for example, 6 common, 4 pretty rare, 2 rare, 1 very rare, 3
> >empty) and in the other GEs hold all other elements (emeralds, diamonds,
> >sand, rock, etc.)
>
> Apparently it does:
> http://www.zomis.net/rnd/download.php?id=362

Oops, sorry for not answering here. :-o

Yes, you are right -- it works exactly that way.

So you could, for example, define a GE1 with 10 emeralds, and another GE2 with 10 times GE1 and one diamond. This would result in GE2 creating elements with a probability of roughly 99% emeralds and 1% diamonds.
Post Reply