Adventure Game Studio | Forums

AGS Support => Modules & Plugins => Topic started by: Kweepa on 22 May 2010, 20:32

Title: MODULE: SeededRandom v1.1
Post by: Kweepa on 22 May 2010, 20:32
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
Title: Re: MODULE: SeededRandom v1.0
Post by: Monsieur OUXX on 23 May 2010, 16:47
reproducible 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.

Title: Re: MODULE: SeededRandom v1.0
Post by: abstauber on 23 May 2010, 18:54
I've recently read an article about Elite just before I've seen this module :)

Do you have any plans about a space opera?
Title: Re: MODULE: SeededRandom v1.0
Post by: Joseph DiPerla on 24 May 2010, 01:22
Steve, you never cease to amaze me.
Title: Re: MODULE: SeededRandom v1.0
Post by: Jim Reed on 24 May 2010, 02:39
Roguelikes use seeded randoms a lot.
Why isn't anybody making a roguelike in AGS? Quick, somebody, make my dreams come true! =)
Title: Re: MODULE: SeededRandom v1.0
Post by: Wonkyth on 24 May 2010, 08:17
Haven't I told anyone about my roguelike sidescroller?
I really thought I had...
Title: Re: MODULE: SeededRandom v1.0
Post by: discordance on 24 May 2010, 20:34
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.
Title: Re: MODULE: SeededRandom v1.0
Post by: abstauber on 24 May 2010, 20:39
@Wonkyth
In case you also feel like explaining how you did pathfinding, you know where to find my ears  ;)
Title: Re: MODULE: SeededRandom v1.0
Post by: Wonkyth on 25 May 2010, 11:38
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.
Title: Re: MODULE: SeededRandom v1.1
Post by: Kweepa on 05 Jun 2010, 07:54
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!
Title: Re: MODULE: SeededRandom v1.1
Post by: cat on 01 Jun 2019, 07:28
I used this module for a generated maze (https://www.adventuregamestudio.co.uk/site/games/game/2348/). Thanks!