This page will only parse completely when it is included in another page.
[template]documentation subpage[/template]
This template generates a pseudo-random integer between 0 and [i]count[/i]-1.
; Usage:
[list][*] <tt>&#123;&#123;Rand&#124;</tt>[i]count[/i]<tt>&#124;</tt>[i]seed[/i]<tt>&#124;</tt>[i]prime[/i]<tt>&#125;&#125;</tt>
[*] All parameters are optional and have default values. They must be integers.
[*] The default [i]count[/i] is 100 (so by default, this template generates values between 0 and 99) and must be non-zero.
[*] The default [i]seed[/i] is &#123;&#123;&#35;time:z&#125;&#125; and can be set to any other integer value (used to generate distinct values on the same page).
[*] The default [i]prime[/i] is 67 and should be a prime number above 17 (used to generate distinct values on the same page).
[/LIST]
; Examples generating numbers between 0 and 999:
[list][*] <tt>&#123;&#123;Rand&#124;1000&#125;&#125;</tt> = [template]Rand|1000[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;[template]#tim e:z[/template]&#124;67&#125;&#125;</tt> = [template]Rand|1000|[template]#time:z[/template]|67[/template] (same as above)
[*] <tt>&#123;&#123;Rand&#124;1000&#124;[template]#tim e:z[/template]&#124;61&#125;&#125;</tt> = [template]Rand|1000|[template]#time:z[/template]|61[/template] (this and others should all be different)
[*] <tt>&#123;&#123;Rand&#124;1000&#124;6&#125;&#125 ;</tt> = [template]Rand|1000|6[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;5&#125;&#125 ;</tt> = [template]Rand|1000|5[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;4&#125;&#125 ;</tt> = [template]Rand|1000|4[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;3&#125;&#125 ;</tt> = [template]Rand|1000|3[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;2&#125;&#125 ;</tt> = [template]Rand|1000|2[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#125;&#125 ;</tt> = [template]Rand|1000|1[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;0&#125;&#125 ;</tt> = [template]Rand|1000|0[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;17&#125 ;&#125;</tt> = [template]Rand|1000|0|17[/template] (varying the prime number)
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;19&#125 ;&#125;</tt> = [template]Rand|1000|0|19[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;23&#125 ;&#125;</tt> = [template]Rand|1000|0|23[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;29&#125 ;&#125;</tt> = [template]Rand|1000|0|29[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;31&#125 ;&#125;</tt> = [template]Rand|1000|0|31[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;37&#125 ;&#125;</tt> = [template]Rand|1000|0|37[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;41&#125 ;&#125;</tt> = [template]Rand|1000|0|41[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;43&#125 ;&#125;</tt> = [template]Rand|1000|0|43[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;47&#125 ;&#125;</tt> = [template]Rand|1000|0|47[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;51&#125 ;&#125;</tt> = [template]Rand|1000|0|51[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;53&#125 ;&#125;</tt> = [template]Rand|1000|0|53[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;59&#125 ;&#125;</tt> = [template]Rand|1000|0|59[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;61&#125 ;&#125;</tt> = [template]Rand|1000|0|61[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;67&#125 ;&#125;</tt> = [template]Rand|1000|0|67[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;71&#125 ;&#125;</tt> = [template]Rand|1000|0|71[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;73&#125 ;&#125;</tt> = [template]Rand|1000|0|73[/template]
[*] <tt>&#123;&#123;Rand&#124;1000&#124;1&#124;79&#125 ;&#125;</tt> = [template]Rand|1000|0|79[/template]
[/LIST]
; Note:
[list][*] Varying [i]seed[/i] linearly generates numbers that generate a linear sequence on the same page, with equal cyclic steps;
[*] Varying [i]prime[/i] (provided that they are odd prime numbers) generates pseudo-random that have independent random distribution.
[*] Note that when [i]count[/i] is even (such as 100 by default, or 1000 in the examples above), the generated numbers (on the same page) are all odd or all even when you are varying the [i]seed[/i] or [i]prime[/i], unless half of the calls use an even [i]seed[/i] and the others used an odd [i]seed[/i]. However, later invokations will still alternate odd and even numbers on output (this problem only occurs on the same page where multiple random numbers are invoked).
[*] On the same page, multiple invokations of this template with the same parameters will generate the same ouput value, so it is possible to create multiple links related to the same article.
[/LIST]

Tags for this Page

Similar Pages

  1. Rand
    By Arjan in forum Template
    Comments: 0
    Last Post: 11-23-2008, 08:24 PM

Bookmarks

Posting Permissions

Posting Permissions
  • You may not create new articles
  • You may not edit articles
  • You may not protect articles
  • You may not post comments
  • You may not post attachments
  • You may not edit your comments
BIRTHRIGHT, DUNGEONS & DRAGONS, D&D, the BIRTHRIGHT logo, and the D&D logo are trademarks owned by Wizards of the Coast, Inc., a subsidiary of Hasbro, Inc., and are used by permission. ©2002-2010 Wizards of the Coast, Inc.