From KeenWiki
Jump to: navigation, search

Probability is what controls all of the random events in Keen. No matter what the game, probability works very similarly in all of them. This page details how probability works in Keen and also how probability patches work.

Firstly, nothing in Keen is truly random, computers are simply not capable of that at present, and the game makes no attempt to do so. Rather, 'random' events are governed by several variables, each of which can have many values, such as the time of day, the last key the player pressed and the current state of the game. Thus, though in theory it is possible to play the same game twice, in practice even the tiniest difference is rapidly multiplied in a sort of pseudo-butterfly-effect.

Notice that in Keen galaxy when demos are recorded and played the random variables are 'cleared'; meaning the game will always play the same way. This stops Keen coming across something random in demo mode and messing things up. It will be noticed by experienced players that when recording demos the game is far more predictable.

Whenever the game needs to decide whether to do something random, it takes a value from the 'random table' and sees if it is bigger or smaller than a certain stored value. If it is bigger it will do something, if it is smaller, it won't. The 'random table' is always changing, so the values it gets are almost random. The value got from the table is one byte in size, having values between 0-255 ($00-$FF).

A typical probability patch is listed below, it gives the probability of a Keen 4 Blue Bird landing when it is next to the ground Keen is standing on:

Patch: Keen 4
#Chance of landing
%patch $10489 $80

The value here, $80, is the stored value the game checks the random value against. It can immediately be seen, since the random value is between 0-255 that there is a 50%$ chance that it will be bigger than this. If the value is set to zero, the bird never lands. If it is set to $FF then it always lands. Most check values are $80, though there are some exceptions.

However, this is not to say the bird landing is as simple as a coin flip; the game nearly always keeps checking (That is, it doesn't flip a coin just once, but keeps flipping the coin until it gets heads.) This means that unless the check value is zero something WILL eventually happen; the chance of something happening in time t depend on how often the game performs the check, and the chance of something happening in time 2t are doubble that of it happening in time t.

This has important consequences for how these patches work. If you halve the value (Here from $80 to $40) the chance of the bird landing is not halved, it is quartered and thus the average time before it lands is quadrupled. The following table gives rough values for probabilities of things happening:

Value	Probability
$00	0%
$12	1%
$28	5%
$39	10%
$40	12.5%
$51	20%
$5B	25%
$63	30%
$68	33%
$72	40%
$80	50%
$8C	60%
$93	66%
$97	70%
$9D	75%
$A2	80%
$A9	87.5%
$AC	90%
$B0	95%
$B4	99%
$FF	100%