1
\$\begingroup\$

I am trying to make a cellular automate cave but want to keep the middle empty.

How should I change the chance based on the distance from the middle?

I don't want to completely deny it just want a small enough chance to keep it almost empty.

\$\endgroup\$
1
\$\begingroup\$

You need to think along the lines of uneven distribution. For example squaring the random value:

if Sqr(Random) > (1 - NormalizedDistanceFromCenter) then AddMonster

will give you a nice squared distribution:

Distance | Chance
---------|------
0        | 0%
0.2      | 11%
0.4      | 23%
0.6      | 37%
0.8      | 55%
0.9      | 69%
1.0      | 100%
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I made a different approach : if ( Math.random() > 1-0.8*(Math.abs(half_distance*0.5-distance)/distance) ) { } \$\endgroup\$ – spepe Mar 7 '15 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.