<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.sierrahelp.com/index.php?action=history&amp;feed=atom&amp;title=Random</id>
	<title>Random - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.sierrahelp.com/index.php?action=history&amp;feed=atom&amp;title=Random"/>
	<link rel="alternate" type="text/html" href="http://wiki.sierrahelp.com/index.php?title=Random&amp;action=history"/>
	<updated>2026-11-15T21:42:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>http://wiki.sierrahelp.com/index.php?title=Random&amp;diff=70775&amp;oldid=prev</id>
		<title>Andrew Branscom: 2 revisions imported</title>
		<link rel="alternate" type="text/html" href="http://wiki.sierrahelp.com/index.php?title=Random&amp;diff=70775&amp;oldid=prev"/>
		<updated>2025-02-16T20:58:19Z</updated>

		<summary type="html">&lt;p&gt;2 revisions imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:58, 16 February 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Andrew Branscom</name></author>
	</entry>
	<entry>
		<id>http://wiki.sierrahelp.com/index.php?title=Random&amp;diff=70774&amp;oldid=prev</id>
		<title>Andrew Branscom: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://wiki.sierrahelp.com/index.php?title=Random&amp;diff=70774&amp;oldid=prev"/>
		<updated>2024-06-03T05:11:39Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:11, 3 June 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Andrew Branscom</name></author>
	</entry>
	<entry>
		<id>http://wiki.sierrahelp.com/index.php?title=Random&amp;diff=70773&amp;oldid=prev</id>
		<title>sierraw&gt;Andrew Branscom: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://wiki.sierrahelp.com/index.php?title=Random&amp;diff=70773&amp;oldid=prev"/>
		<updated>2022-01-28T16:19:46Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The &amp;#039;&amp;#039;&amp;#039;random&amp;#039;&amp;#039;&amp;#039; command generates a random number within a specified range.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&lt;br /&gt;
random([[number|byt]] LOWER, [[number|byt]] UPPER, [[variable|var]] vRESULT);&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
The value of variable &amp;#039;&amp;#039;&amp;#039;vRESULT&amp;#039;&amp;#039;&amp;#039; is set to a pseudo random number between &amp;#039;&amp;#039;&amp;#039;LOWER&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;UPPER&amp;#039;&amp;#039;&amp;#039; inclusive. The algorithm  that AGI uses to generate random numbers is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;agi&amp;quot;&amp;gt;if (rndseed == 0)&lt;br /&gt;
  {&lt;br /&gt;
  rndseed = current_clock_count; [ use internal clock count as starting seed&lt;br /&gt;
  }&lt;br /&gt;
rndseed = (rndseed * 0x7C4D) mod 0xFFFF + 1;&lt;br /&gt;
vRESULT = LOWER + rndseed mod (UPPER - LOWER + 1);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Possible Errors ==&lt;br /&gt;
&lt;br /&gt;
To work correctly, &amp;#039;&amp;#039;&amp;#039;UPPER&amp;#039;&amp;#039;&amp;#039; must be greater than or equal to &amp;#039;&amp;#039;&amp;#039;LOWER&amp;#039;&amp;#039;&amp;#039;. If If &amp;#039;&amp;#039;&amp;#039;LOWER&amp;#039;&amp;#039;&amp;#039; is greater than &amp;#039;&amp;#039;&amp;#039;UPPER&amp;#039;&amp;#039;&amp;#039;, then the returned value will be in the range 0 - 255. If  &amp;#039;&amp;#039;&amp;#039;LOWER&amp;#039;&amp;#039;&amp;#039; is exactly = &amp;#039;&amp;#039;&amp;#039;UPPER&amp;#039;&amp;#039;&amp;#039; + 1, it causes a divide by zero situation, which will [[crash AGI]].&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;agi&amp;quot;&amp;gt;&lt;br /&gt;
random(0, 10, v50);&lt;br /&gt;
print(&amp;quot;%v50 is greater than or equal to 0 &amp;quot;&lt;br /&gt;
      &amp;quot;AND less than or equal to 10&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Technical Information ==&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
| style=&amp;quot;background-color: #efefef&amp;quot; width=&amp;quot;200&amp;quot; | &amp;#039;&amp;#039;&amp;#039;Required Interpreter Version:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| width=&amp;quot;175&amp;quot; | Available in all AGI versions.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color: #efefef&amp;quot; | &amp;#039;&amp;#039;&amp;#039;Byte-Code Value:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
| 130 (0x82 hex)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[[Mathematical Commands]]&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Category:Commands]]&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>sierraw&gt;Andrew Branscom</name></author>
	</entry>
</feed>