Time for this weeks programming related research.

**Instantiation**

Okay I think I can take a shot at explaining this one without the need for googling for information. During the Global Game Jam our coder (Kelly) used Instantiation to randomly generate scenery in our endless runner game.

I gave her several pieces of scenery which were plugged into a list and an instantiate looked at the parent object in the list and created a duplicate off screen based on whatever parameters you provide. They then scrolled on screen for the player to avoid, once they had vanished from sight they were set to be destroyed so they didn’t continue to consume memory.

**While Loops**

Ah the massive memory leak or outright system killer that a while loop can be if used ineffectively. If a set of instructions get trapped in a while loop it will go on infinitely until the program is terminated or the system crashes if the loop consumes too much memory. I know Kelly will have used the same example (we worked the same job in the same office prior to this) but we used to manage servers for ITV on a morning, there had been a number of occasions where someone had made edits to the SQL database scripts which caused a while loop when trying to retrieve the data from an FTP server. Many fun phone calls used to ensue.

Anyway a while loop will run a chunk of code over and over until a given condition is met, at which point the while loop terminates and you progress onto the next bit of code.

**Math: Probability and Averages**

Time to break out the tabletop role-player in me. Probability is the chance of something happening, in the simplest of terms. To find a probability you take the number of ways an outcome could happen and divide it by the total amount of possible outcomes. Here is a simple six sided dice example (no way am I working this out on d20s).

If we have two dice, both of which have six outcomes then the maximum outcomes is 36 (6*6). Lets say we want to roll two six’s, I found this handy diagram of somebody else explaining:

The table totals the value of both dice being rolled through all outcomes. We know that two six’s would equal 12 and from all outcomes there is only one way that can happen. So the probability of rolling two sixes is 1 in 36 (1/36). That’s about as simple as an explanation gets.

Averages is all about finding the number most typical within a range of numbers. There are a few types: mean, ,median and mode.

Mean: The most common type of average that most of us tend to use day to day. It’s achieved by taking the sum of all your numbers and dividing that value by the amount of numbers. Eg. 4 + 8 + 12 + 16 = 40 / 4 = 10

Median: You place your set of numbers in order and the median is equal to the one that falls in the middle. If you have two middle numbers (so an even amount of numbers in your set), then it’s the mean of those two numbers that’s the median. Ex) 1, 1, 2, 3, 3, 4 = 2 and 3 = average of 2.5

Mode: The simplest average, it’s the number that appears most often in the set. Ex) 1, 2, 2, 2, 3, 4, 4 = average of 2