<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>libtcod documentation | Pseudorandom number generator</title>
<script type="text/javascript" src="../js/doctcod.js"></script>
<link href="../css/style.css" rel="stylesheet" type="text/css"></head>
<link type="text/css" rel="stylesheet" href="../css/shCore.css"></link>
<link type="text/css" rel="stylesheet" href="../css/shThemeDefault.css"></link>
<script language="javascript" src="../js/shCore.js"></script>
<script language="javascript" src="../js/shBrushBash.js"></script>
<body><div class="header">
<p><span class="title1">libtcod</span><span class="title2">documentation</span></p>
</div>
<div class="breadcrumb"><div class="breadcrumbtext"><p>
you are here: <a onclick="link('../index2.html')">Index</a> &gt; <a onclick="link('random.html')">7. Pseudorandom number generator</a><br>
<a class="prev" onclick="link('list.html')">6. All purposes container</a> | <a class="next" onclick="link('mouse.html')">8. Mouse support</a>
</p></div></div>
<div class="filter"><input type="checkbox" id="chk_c" name="chk_c" onchange="enable('c',this.checked)" checked='checked' ><label  for='chk_c'> C   </label><input type="checkbox" id="chk_cpp" name="chk_cpp" onchange="enable('cpp',this.checked)" checked='checked' ><label  for='chk_cpp'> C++   </label><input type="checkbox" id="chk_py" name="chk_py" onchange="enable('py',this.checked)" checked='checked' ><label  for='chk_py'> Py   </label><input type="checkbox" id="chk_lua" name="chk_lua" onchange="enable('lua',this.checked)"  disabled='disabled'><label class='disabled' for='chk_lua'> Lua   </label><input type="checkbox" id="chk_cs" name="chk_cs" onchange="enable('cs',this.checked)"  disabled='disabled'><label class='disabled' for='chk_cs'> C#   </label></div>
<div class="main"><div class="maintext">
<h1>7. Pseudorandom number generator</h1>
<div id="toc"><ul><li><a onclick="link('random_init.html')">7.1. Creating a generator</a></li>
<li><a onclick="link('random_distro.html')">7.2. Using a generator</a></li>
<li><a onclick="link('random_use.html')">7.3. Using a generator</a></li>
</ul></div>
<p>This toolkit is an implementation of two fast and high quality pseudorandom number generators:<br />* a Mersenne twister generator,<br />* a Complementary-Multiply-With-Carry generator.<br />CMWC is faster than MT (see table below) and has a much better period (1039460 vs. 106001). It is the default algo since libtcod 1.5.0.<br /><br />Relative performances in two independent tests (lower is better) :<br /><table class="param">
    <tr>
      <th>Algorithm</th>
      <th>Numbers generated</th>
      <th>Perf (1)</th>
      <th>Perf (2)</th>
    </tr>
    <tr class="hilite">
      <td>MT</td>
      <td>integer</td>
      <td>62</td>
      <td>50</td>
    </tr>
    <tr>
      <td>MT</td>
      <td>float</td>
      <td>54</td>
      <td>45</td>
    </tr>
    <tr class="hilite">
      <td>CMWC</td>
      <td>integer</td>
      <td>21</td>
      <td>34</td>
    </tr>
    <tr>
      <td>CMWC</td>
      <td>float</td>
      <td>32</td>
      <td>27</td>
    </tr>
</table><br /><br /><h6>For python users:</h6><br />Python already has great builtin random generators. But some parts of the Doryen library (noise, heightmap, ...) uses RNG as parameters. If you intend to use those functions, you must provide a RNG created with the library.<br /><br /><h6>For C# users:</h6><br />.NET already has great builtin random generators. But some parts of the Doryen library (noise, heightmap, ...) uses RNG as parameters. If you intend to use those functions, you must provide a RNG created with the library.<br /> </p>

</div></div>
<div class="footer"><div class="footertext">
	<p>libtcod 1.5.2, &copy; 2008, 2009, 2010, 2012 Jice & Mingos<br>
	This file has been generated by doctcod.</p>
	<p><table width='100%'><tr><td><a href="http://doryen.eptalys.net/libtcod">libtcod website</a></td>
	<td><a href="http://doryen.eptalys.net/forum/index.php?board=12.0">libtcod on Roguecentral forums</a></td>
	<td><a href="http://doryen.eptalys.net/libtcod/tutorial">libtcod tutorials</a></td>
  </tr></table></p>
</div></div>
</body>
<script>
initFilter();
SyntaxHighlighter.all();
</script>
</html>
