<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GuShH&#039;s DevBlog &#187; quake</title>
	<atom:link href="http://gushh.net/blog/?tag=quake&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://gushh.net/blog</link>
	<description>This blog is about software, electronics engineering and game development.</description>
	<lastBuildDate>Tue, 24 Jan 2012 00:31:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Random Floats using built-in PRNG</title>
		<link>http://gushh.net/blog/random-floats-using-built-in-prng/</link>
		<comments>http://gushh.net/blog/random-floats-using-built-in-prng/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 16:59:58 +0000</pubDate>
		<dc:creator>GuShH</dc:creator>
				<category><![CDATA[PureBasic]]></category>
		<category><![CDATA[pb]]></category>
		<category><![CDATA[prng]]></category>
		<category><![CDATA[pseudo random number generator]]></category>
		<category><![CDATA[purebasic]]></category>
		<category><![CDATA[q3a]]></category>
		<category><![CDATA[quake]]></category>
		<category><![CDATA[random float]]></category>

		<guid isPermaLink="false">http://gushh.net/blog/?p=78</guid>
		<description><![CDATA[Random floats are kind of a mystical thing in PB, however it can be achieved to a certain degree without having to stack calls on a per decimal fashion. Here is a simple implementation that will get you going, this is meant specifically for games but it could find other uses&#8230; Macro RandomF&#40;&#41; ; returns [...]]]></description>
			<content:encoded><![CDATA[<p>Random floats are kind of a mystical thing in PB, however it can be achieved to a certain degree without having to stack calls on a per decimal fashion.</p>
<p>Here is a simple implementation that will get you going, this is meant specifically for games but it could find other uses&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">Macro</span> RandomF<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span> <span style="color: #ff0000; font-style: italic;">; returns a random float from 0.0 to 1.0</span>
	<span style="color: #000066;">&#40;</span> <span style="color: #0000ff;">Random</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">64325</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">*</span> <span style="color: #CC0000;">0.00001555</span> <span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndMacro</span>
<span style="color: #000066; font-weight: bold;">Macro</span> RandomFC<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span> <span style="color: #ff0000; font-style: italic;">; returns a random float from -1.0 to 1.0</span>
	<span style="color: #000066;">&#40;</span> <span style="color: #CC0000;">2.0</span> <span style="color: #000066;">*</span> <span style="color: #000066;">&#40;</span> RandomF<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #CC0000;">0.5</span> <span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndMacro</span></pre></div></div>

<p>Try it out yourself, if you need a wider range of numbers just multiply the result by a certain factor. I use this and other similar macros for most of my float random needs in PB.  Should you need to stack the calls, just make procedures out of the macros.</p>
<p>Similar routines are found inside the Quake3 sources if you care to read them (hint: if you look carefuly there is a comment line inside the game source that reads &#8220;// What the fuck?&#8221; &#8212; Just priceless, seriously).</p>
<p>Cheers.</p>
<g:plusone href='http://gushh.net/blog/random-floats-using-built-in-prng/'></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://gushh.net/blog/random-floats-using-built-in-prng/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: gushh.net @ 2012-02-09 06:49:30 by W3 Total Cache -->
