# Difference between revisions of "Probability"

(Put more info) |
(Fixed a typo.) Tags: mobile edit mobile web edit |
||

Line 5: | Line 5: | ||

− | The Great Random - a mysterious force which permeates the very essence of Godville and is treated | + | The Great Random - a mysterious force which permeates the very essence of Godville and is treated as a cruel creature that gods hate because it always goes against the god's wishes, and is also often treated as a deity in itself. |

The majority of in-game events occur randomly. This is not because we are missing some facts but is a result of the usage of random number generators which control the outcome of these events. Since randomness is the mechanism, we can only understand the game mechanics by the use of probabilities. However, true randomness is hard to produce (True randomness is usually achieved through natural events such as radioactive decay and Brownian motion.); the random number generators of Godville are driven by code and are therefore only '''pseudorandom'''. This means certain patterns in numbers produced would be evident should one look for long enough but this is deemed too tedious to be worthwhile and so will not be the focus of the article. [[Image:brownian.gif|thumb|400px|right|2D Random Walk - Brownian Motion example]] | The majority of in-game events occur randomly. This is not because we are missing some facts but is a result of the usage of random number generators which control the outcome of these events. Since randomness is the mechanism, we can only understand the game mechanics by the use of probabilities. However, true randomness is hard to produce (True randomness is usually achieved through natural events such as radioactive decay and Brownian motion.); the random number generators of Godville are driven by code and are therefore only '''pseudorandom'''. This means certain patterns in numbers produced would be evident should one look for long enough but this is deemed too tedious to be worthwhile and so will not be the focus of the article. [[Image:brownian.gif|thumb|400px|right|2D Random Walk - Brownian Motion example]] | ||

The mechanics of gameplay in the game of Godville rely heavily on probability, which can nicely be defined as the long-run relative frequency. By understanding such things we can therefore calculate the likelihoods of certain in-game events occurring. Here is a beginners guide to applying some basic probability theory to the gameplay of Godville. No prior knowledge of statistics is needed. | The mechanics of gameplay in the game of Godville rely heavily on probability, which can nicely be defined as the long-run relative frequency. By understanding such things we can therefore calculate the likelihoods of certain in-game events occurring. Here is a beginners guide to applying some basic probability theory to the gameplay of Godville. No prior knowledge of statistics is needed. | ||

− | |||

==Probability of obtaining certain artifacts, pieces of equipment, skills and auras== | ==Probability of obtaining certain artifacts, pieces of equipment, skills and auras== |

## Revision as of 11:28, 10 April 2017

The Great Random - a mysterious force which permeates the very essence of Godville and is treated as a cruel creature that gods hate because it always goes against the god's wishes, and is also often treated as a deity in itself.

The majority of in-game events occur randomly. This is not because we are missing some facts but is a result of the usage of random number generators which control the outcome of these events. Since randomness is the mechanism, we can only understand the game mechanics by the use of probabilities. However, true randomness is hard to produce (True randomness is usually achieved through natural events such as radioactive decay and Brownian motion.); the random number generators of Godville are driven by code and are therefore only **pseudorandom**. This means certain patterns in numbers produced would be evident should one look for long enough but this is deemed too tedious to be worthwhile and so will not be the focus of the article.

The mechanics of gameplay in the game of Godville rely heavily on probability, which can nicely be defined as the long-run relative frequency. By understanding such things we can therefore calculate the likelihoods of certain in-game events occurring. Here is a beginners guide to applying some basic probability theory to the gameplay of Godville. No prior knowledge of statistics is needed.

## Probability of obtaining certain artifacts, pieces of equipment, skills and auras

These things are plentiful and if a list of them can be acquired, it is possible to calculate the probability of obtaining one. We shall use Auras as an example since there is a definite complete list of them on the wiki. First of all, we shall start with the fact that the hero has received a new aura. We would like to know the probability that the aura is a particular one. Here is our first important fact:

- In Godville, all in-game events are
**equiprobable**(i.e. have equal probabilities to occur). It's worth saying here that this doesn't apply to all in-game events because for example, the probability of receiving a gold brick when a hero has 3000 gold coins is not the same as when they have only 200 coins, but let's define an in-game event as a range of possibilities that can be picked, given a certain condition is fulfilled. - This leads on to the fact that the probability distribution is a
**discrete uniform distribution**. This looks very boring so a picture of its slightly less-boring c.d.f is provided below.

What about rare artifacts then? We shall come to that later. We must now state what we know about auras.

- There are 6 Auras

*Note: This was true at the time of writing, but there are now more. Mentally edit this article as appropriate.*

Therefore, since all probabilities are equal, the hero has a 1/6 chance of receiving a certain one.

What about the probability of obtaining one aura OR another? We shall call the two auras A & B and P(something) will symbolise the probability of 'something' occurring. Here is our first basic rule of probability:

**P(A or B) = P(A) + P(B)**

*For mutually exclusive events such as those encountered in Godville*

Therefore, the probability of obtaining one of two auras is 1/6 + 1/6 = 1/3.

We can apply these rules to anything where there is a list of outcomes which are all equiprobable. We could do this then for artifacts, equipment and skills but since we do not have a definite complete list of any of them, we cannot carry out a full analysis. However we can easily see why certain types of artifacts are rarer then others:

Why are Activatable Artifacts the rarest type of Artifact a hero can find if all events are equiprobable? The answer is simple: there are hardly any of them (relative to normal artifacts of course). Let us take an example where there are 10 individual artifacts and 3 of them are activatable ones. A hero obtains one of these artifacts. The probability of getting a certain one of them is 1/10. We can then say that the probability of getting an activatable one is 3/10 and the probability of getting one of the normal ones is 7/10.

## Probability in Fights between Monsters and Heroes

In a fight against a monster, it is possible to alter the outcome using the Remote Control but what if the hero is left to their own devices? In this case probabilistic rules come into place. We would like to know the probability that a hero with a certain amount of health will win against a monster who has a certain amount of health. The health of a hero is decided by their level so we will set the level of the hero to an arbitrarily chosen number; 37 (health=244). The hero starts off as fully healed. Let us now state what we know:

- Hero - level 37 therefore health = 244
- Monster - for ease, we will set its health to the same amount

There is a certain range of values for damage which a hero can inflict on a monster. It is exactly the same as the range of damage values a monster can inflict on a hero. All values are equiprobable. From careful observation of a hero in combat we find this range of values:

**Range of Damage Values: 1-20**[This is demonstrably not true right now. Consider accumulating new data?]**Therefore 1/20 chance to inflict a certain value of damage**

These value ranges stay the same regardless of a hero's level or equipment (one has to wonder the point of such things then...). There are 20 values here which means that each one has a 1/20 chance to be inflicted by a hero. Now what if we would like to calculate the minimum number of turns one hero will take to defeat the monster? To do this, the hero would have to inflict the maximum amount of damage they could every turn. This amount of damage is 20. Both heroes' health is 244. 244 divided by 20 equals 12 so we need 12 turns to do this. There is a 1/20 chance to inflict the maximum amount of damage and we need the probability that this 1/20 chance will happen 12 turns in a row which means that this is an ideal time to introduce another basic rule of probability.

**P(A and B) = P(A)P(B)**

*For mutually exclusive events such as those encountered in Godville*

In other words, we must do 1/20 x 1/20 x 1/20... until we have multiplied 1/20 by 1/20 twelve times. This is just 1/20 to the power of 12. The probability that the hero will take the shortest possible amount of time (12 turns) to defeat the other comes out as 0.00000000000000024 or in standard notation, 2.4 x 10^-16. This is clearly a tiny probability and this is the best possible scenario too!

Now what if we want to calculate the probability that the hero will take the longest possible time to defeat the monster? The process is much the same. There is still a 1/20 chance that the lowest amount of damage (1) will be inflicted by the hero. 244 divided by 1 gives 244 which is therefore the number of turns needed to defeat the other hero. We now want the probability that this 1/20 chance occurs 244 times in a row. 1/20 to the power of 244 gives our final answer which is far too large to write out fully but in standard notation it is 3.5 x 10^-318. That's 317 zeroes after the decimal point followed by 35, tiny! You would have to calculate the probability that the monster defeats the hero by that amount of turns though as this would be more likely to happen.

As long as you know the health of the monster, you can calculate probabilities in the same way as we have done for duels between a hero and another hero. There is one extra factor though: you may want to find probabilities concerning the amount of Gold coins a hero receives when they defeat a monster. Again, since all events are equiprobable, there is a range of values, which is provided below for your use:

**Range of Gold Coin Values: 1-40****Therefore 1/40 chance to receive a certain value of gold coins**

## Probability in Equipment Durabilities

A hero will occasionally change their Equipment. They will either downgrade or upgrade this piece of equipment but eventually in the long run will continue to upgrade and the durability of the equipment will increase more and more. How will we model this process probabilistically then?

We need a solution where all events remain equiprobable, so we must have a range of values for which the durability of equipment can change by. From observation of equipment, it is possible to see that it can upgrade by a range of 1-3 and downgrade by a range of 1-2 so what do we do? We actually have all we need now:

**The range of values by which the durability of a piece of equipment may change by goes from negative 2 to positive 3****This means that each value has a 1/6 chance to be chosen (including the value zero in which case the hero does not change their equipment)**

A negative value obviously represents a downgrade and a positive value an upgrade. Since there are more positive than negative values there is a higher probability of upgrading than downgrading which means that instead of staying near zero (as in what would happen with a one-dimensional random walk where the probabilities of moving forwards and backwards are both equal), we would get what we actually see: a constant upgrading. Now we will quickly use this to calculate the probability that a hero upgrades a piece of equipment by ten points in the quickest possible way. This would be done by the process [+ 3 points + 3 points + 3 points + 1 point] to the durability. This takes four trips to the trader. Each value is equiprobable so we just do 1/6 to the power of four to get the answer 0.000771604938 and we see that it is simple.

### Copernican Principle

Now we will approach probabilities from a different point of view. The range of values for equipment durability change goes from negative 2 to positive 3. These 6 values are all equiprobable and all of this we have just mentioned. However, are they really equiprobable? First, a brief diversion:

The Copernican Principle is an old one, named after Nicolaus Copernicus who was the first to propose that the Earth orbited the Sun instead of the other way round. It states that you are not special; a simple idea, but one that when extended can make profound predictions. If you are not special, then you are likely not to be at the beginning nor at the end of a time line, as these make up the smallest percentages of the time line itself. Instead you are likely to be living in the largest portion of the time line (the greatest percentage of it) which is the middle. To make it easier to understand, imagine a time line split up into 3 parts: the first 5%, the middle 90% and the end 5%. If there is an equally likely chance that you will be at any point in this time line (which there is no reason why not), the portion of time line with the highest probability of you living in it is the middle as it is the largest part. The Copernican Principle states that you are not special, so you are in the part of the time line with the highest probability of you being there. For example, since the highest percentage of humans ever born will be at the prime of human civilisation, I am most likely to be born around this time and I'm not special, so I was, and therefore there is not much time left for human civilisation as it is around its peak at this time. This is a version of the **doomsday argument** but there are more mathematical ones if you are interested so look it up.

Now back to the world of Godville. These are our values: -2, -1, 0, 1, 2, 3

It is most likely that the one chosen will be in the middle: there is a 1/3 (2/6 simplified) chance that it will be either -2 or 3 but there is a 2/3 (4/6 simplified) chance that it will be either -1, 0, 1 or 2. Therefore these are the values you are most likely to see. Of course, the median (middle value) of these values is 0.5 which if you put full faith in the Copernican principle means that this is the most likely value to be chosen. However, 0.5 is not one of our values so we can round down to zero or round up to 1 to get our most likely value. This actually then agrees with observations: if you watch your hero while they are at a trader's store, it does seem to be more likely that a hero will not bother changing their equipment, and instead write a diary entry along the lines of 'I couldn't find any pieces of equipment that fitted me' or 'I must have missed a sale, everything was sold out' or instead just upgrade durability by one to keep it ever increasing.

## Probability of Influences in the Arena

These are the possible effects of Encouragement and Punishment influences in the Arena.

Encouragement |
Punishment |
---|---|

Heal the hero (by small amount) | Punish the enemy (by small amount) |

Heal the hero (by medium amount) | Punish the enemy (by medium amount) |

Heal the hero (by large amount) | Punish the enemy (by large amount) |

Backfire | Backfire |

It should be noted that the amount that a hero is healed or punished by is randomly selected from a range of values which increases with each level that the hero gains. These ranges are unfortunately unknown at the moment. Anyway, we can see from this that there is a 1/4 chance of backfiring. What do we mean by backfiring though? When 'backfire' has been randomly selected, this isn't the end of the story because there are different backfire outcomes.

Encouragement |
Punishment |
---|---|

Heal the enemy | Punish the hero |

Heal both the hero and the enemy equally | Punish both the hero and the enemy equally |

Do nothing (make a rainbow or some other omen) | Do nothing (the lightning bolt misses) |

Each backfire has a 1/3 chance of happening AFTER backfire has been selected. This means the probability of one of the three backfires is not 1/3 but is actually a 1/4 x 1/3 which equals 1/12. Now that this is explained, we can return to the probability of any backfire; 1/4. In probabilistic terms where the highest probability is one (a certainty), this is quite a large one. It definitely accounts for the skewed random complaint and this is why: we shall calculate the probability of a backfire happening five influences in a row. We know by now that this is just 1/4 to the power of 5 which is 1/1024. This looks like a tiny irrelevant probability which means that it is time for a new rule for calculating our long-run average:

**Expected Value = Probability x sample size**

*Note: Ok, yes this is for the binomial distribution. Different distributions may be discussed here in this article in the future actually.*

So let us say that there are about 5000 players in a all of Godville. There are not, but we do not know the true figure so we shall arbitrarily choose this one. According to our rule, to calculate a prediction of how many players (on average) will suffer, we multiply 1/1024 by 5000 which roughly equals 5. This shows that even when seemingly small probabilities are scaled up, the impact can be significant. This is a very simplistic model because in actual fact, each of the 5000 players would use a certain number of influences and there would be many other factors involved, but this model is still enough to showcase what can happen with large sample sizes which is why it is used here. The main message in any case is that with such a large sample size, players with long streaks of misfortune are inevitable.

## Probability with Voice of God Commands

For voice of god commands, these are the possible outcomes:

Outcome |
Probability |
---|---|

Command is completely ignored | 1/3 |

Hero hears the command but doesn't understand it | 1/3 |

Hero carries out the instruction | 1/3 |

It is important that the conditions for the particular command to work are right or the probability drops to zero. This is because the 'all events are equiprobable' rule only applies for everything that involves random selection as noted at the very beginning of this article; the schedule of the hero obviously is separate from probabilistic rules. The probabilities for voice of god commands are exactly the same outside the arena as they are inside it.

*NB: these probabilities have been checked numerous times and have always been found to be accurate. In actual fact, the probabilities were discovered by running many trials, and the events associated with them matched up afterwards.*

### Digging

For the 'dig' effect, there is more than one possible effect so we shall use it as our main example. Remember that the condition for this command to have the 1/3 probability of working is that the hero must be travelling and finding his way. This time, we shall go straight to a table of outcomes and probabilities:

Outcome |
Probability |
---|---|

Command is completely ignored | 1/3 |

Hero hears command but doesn't understand it | 1/3 |

Hero digs and finds gold (range: 50-200) | 1/15 |

Hero digs and finds gold (range: 500-2500) | 1/15 |

Hero digs and finds a random artifact | 1/15 |

Hero digs and finds a gold brick | 1/15 |

Hero digs and finds nothing | 1/15 |

Since you know how to use them, these tables serve as useful reference material that demonstrates how things work.