MODULE: SeededRandom v1.1

Started by Kweepa, Sat 22/05/2010 20:32:00

Previous topic - Next topic

Kweepa

Here's a module to allow you to have a reproducible random number stream.

http://www.kweepa.org/step/ags/tech/SeededRandom.scm (2k)

Functions are:
RandomSetSeed(int seed)
RandomSetSeedString(String seedString)
int RandomInt()
float RandomFloat()
int RandomMax()
int RandomRange(int max)


See the header/code for more details.
Steve

Version History:
1.1 Updated to use x = (16809*x)%(2^31-1), so it has a period of ~2^31 instead of ~2^16
1.0 Initial version
Still waiting for Purity of the Surf II

Monsieur OUXX

Quote from: SteveMcCrea on Sat 22/05/2010 20:32:00reproducible random number stream.

Very useful for those who want to create procedural universe, but don't want to store everything in memory. The seed is enough.

Think of the random dungeons in early RPGs (but it's still the same dungeon if you visit it twice).

I say yey for Steve.

 

abstauber

I've recently read an article about Elite just before I've seen this module :)

Do you have any plans about a space opera?

Joseph DiPerla

Steve, you never cease to amaze me.
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

Jim Reed

Roguelikes use seeded randoms a lot.
Why isn't anybody making a roguelike in AGS? Quick, somebody, make my dreams come true! =)

Wonkyth

Haven't I told anyone about my roguelike sidescroller?
I really thought I had...
"But with a ninja on your face, you live longer!"

discordance

Quote from: Jim Reed on Mon 24/05/2010 02:39:23
Roguelikes use seeded randoms a lot.
Why isn't anybody making a roguelike in AGS? Quick, somebody, make my dreams come true! =)

I tried :) Then gave up and started writing it in python. AGS isn't great if you want to use ascii.

abstauber

@Wonkyth
In case you also feel like explaining how you did pathfinding, you know where to find my ears  ;)

Wonkyth

Oh, it's still got a long way to go before it's ready for that, but mostly it relies on strong AI in all parts of the code, handling things dynamically.
"But with a ninja on your face, you live longer!"

Kweepa

Updated the random number generator to have a period of about 2^31 instead of about 2^16, using the 'minimum standard' generator described in Park and Miller's 1988 paper:
http://www.firstpr.com.au/dsp/rand31/p1192-park.pdf
This is a great generator because it works with signed ints as provided by AGS scripting. Most simple generators rely on unsigned ints or smaller word lengths.
So, err, hooray!
Still waiting for Purity of the Surf II

cat


SMF spam blocked by CleanTalk