Iterations inside the brain

==Definition==
An iteration means the process of running a page inside the brain for one time. There are multiple brain tiles that can change how the brain iterates, but the default (a brain with nothing inside it) is infinite iterations for the game session (which means that the brain will run over and over an infinite amount of times while the player initiates a game session), and 30 iterations per second (which corresponds to 30 fps, or the brain running the page x 30 times in one game frame). 
So iterations in game time equals the following:
==Always==
To make the DO side work always, simply leave the WHEN side blank, meaning there is no condition to execute before moving to the DO side.
===Example: Game Camera===
An example is the camera, which we usually want to work while we play. This is why we leave the WHEN side empty.
==Once==
Anything stated after this tile will run only once. There is no possible way to make the section run again in the specific brain that this tile is placed, even if you switch pages and run it again. "Once" also restricts any tiles with duration to work more than 1 game frame. So basically the limit to run a tile with duration is 0.9999 game frames. "Once" is best used when initiating variables at the beginning of the game (that do not reset afterwards). 
===Example: Initializing Player's Starting Position===
 In this example we set an initial position in X,Y,Z that the game will remember for the rest of the playthrough. the reason we do that is if we want the player to spawn back at the beginning when he gets killed, we can state When [is dead] Do [position]=[player starting position]
==Duration 1 in frames==
To have something only work once every time the page is activated, you can use two ways to do it. one of them is to use [Duration][1][in frames] which will work only one time since the game iterates once per game frame. This approach is best used for sounds, position changes, variable assignments etc. that we need to only work once when the brain page is activated.
===Example: Kill Counter===
In this example, we use [duration][1][in frames] to increase our kill counter "dead enemies" by one when this enemy gets killed.
==Started to==
Another way of having something work only once/ page activation is [started to]. Using a [started to] tile with no condition after it will make the DO side work only once.
===Example: Kill Counter using [Started to]===
Same as the previous example, but now we use [started to] to increase our kill counter "dead enemies".
Category:Brains