<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [ <!ENTITY copyrightDates '1999,2000,2001'> <!ENTITY % METACOSM SYSTEM "../en.metacosm.ent"> %METACOSM; ]> <article lang="EN"> <articleinfo> <title>RFC - Random generator and random numbers</title> <corpauthor>&author;</corpauthor> <revhistory> <revision> <revnumber>M1</revnumber> <date>July, 15th 2001</date> <revremark>Conversion to Docbook-DTD</revremark> </revision> <revision> <revnumber>0.2</revnumber> <date>March, 30th 2000</date> <authorinitials>Ruffy</authorinitials> <revremark>Conversion to metacosm-DTD</revremark> </revision> <revision> <revnumber>0.1</revnumber> <date>January, 30th 1999</date> <authorinitials>Ruffy</authorinitials> <revremark>First written version</revremark> </revision> <revision> <revnumber>First discussions</revnumber> <date>Summer 1999</date> </revision> </revhistory> <abstract> <simpara>The goal of this document is to define the use of random numbers and the way of generating them, in the Metacosm project.</simpara> </abstract> </articleinfo> &license; &project; <sect1> <title>Why random numbers?</title> <para>Yes, that's a good question... Do you really want an answer? OK, I'll try to give you some keys.</para> <para>If we don't use random numbers, the game will be entirely determinist (i.e. a given situation will always evolve in the same way) *without* players.</para> <note><para>we consider absolute time as a random number (because we don't control it). So we suppose that situations are not a function of absolute time, or only of duration.</para></note> <para>But it won't be a game if there aren't players, will it? With the first player, we lose the determinist behavior of the game (we suppose that the player is active, so he/she interacts with the game...). The player acts when he/she wants and does what he/she wants. With time, the player can understand how the game works (and even more with the source :) and uses these informations to cheat. With several players, each player acts when he/she wants and does what he/she wants, but there are as many degrees of liberty as players, so it would be more difficult to have a full understanding and knowledge of the game (i.e. to find the formula which manages the game and describes its future). But, if players decide to cheat together, they'll control the future. That's the first reason of having random numbers: it increases the cheat difficulty.</para> <para>In the real life, a classical philosophical question is "Is the world completely determinist but chaotic, or do we have some freedom to do what we want when we want?". The answer does not matter for us. The only important point is: the world is unpredictable for us. So if we want to do the same in the game, we can either code extremely complex functions (impossible to reverse to cheat and able to create all or many various situations), either we simply use random numbers and keep human code (i.e. simple but buggy :p). That's the second reason.</para> <para>The use of random numbers create such a chaos that even we will be surprised by the game evolution. It's even more true for players. That's nice for game-play: various and unpredictable situations. That's the third reason.</para> </sect1> <sect1> <title>How?</title> <para>It seems you like questions :). We use a random generator. You'll say which one, which type, which period, etc. The answer is we don't care. Even if the generator is bad, random numbers are used in many different parts of the game, so it has no effect. And moreover, players are an other source of randomness. These two points show that a basic generator is enough. But a better one will also work :).</para> <para>We only need a generator able to provide us integers (several sizes) and floats (simple or double precisions). The generator is encapsulated behind an interface, so we can change it if needed. This interface provides basic functions such as to throw dice or dices.</para> <para>An important point in the generator choice is the ability to use a seed (i.e. a number to initialize it).</para> </sect1> <sect1> <title>Why a seed?</title> <para>For players, we need an unpredictable game. For coders, we need an easy to debug game, so we need to be able to replay a situation, to recreate it. We need to be able to obtain again the same list of random numbers, and the way to do it is to use a seed.</para> <para>The seed is loaded by the game at the beginning and saved sometimes to allow debugging. With the seed and a good logger, we are able to replay the game and debug it.</para> <note><para>the seed and the current state of the random generator should be unavailable to players, and even to supervisors (no temptation), to avoid cheating.</para></note> </sect1> </article>