 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
eldritch Archmage of Mayhem and Plotscripting

Joined: 18 Sep 2003 Posts: 62 Location: Chicago Area
|
Posted: Thu Oct 09, 2003 7:30 am Post subject: Seeding the Random Function |
|
|
I need some aid with the random number function. I want to know if there is a way to determine the seed for it so one may get the results one desires say for... generating a random dungeon floor from a player's actions in game. _________________ "Live by the dice, die by the dice."
"I'd tell you but then I'd turn into a badger."
"Semper Fideles means 'we eat our dead.'"
-Anonymous marine |
|
Back to top |
|
 |
Setu_Firestorm Music Composer

Joined: 26 Mar 2003 Posts: 2566 Location: Holiday. FL
|
Posted: Thu Oct 09, 2003 12:31 pm Post subject: |
|
|
Someone correct me if I'm wrong, `cause I don't mess with this level of plotscripting much.
Code: | script, Randomstuff,outcome begin
variable (outcome)
set variable (outcome,random (1,3))
if (outcome == 1)
then (type stuff)
if (outcome == 2)
then (type stuff)
if (outcome == 3)
then (type stuff) |
Like I said, I haven't messed with this level of scripting for a long time, so I'm probably inaccurate. But at least I'm trying to help.
*shrugs* _________________
Facebook: http://www.facebook.com/georgerpowell
Newgrounds: http://setu-firestorm.newgrounds.com |
|
Back to top |
|
 |
Flamer The last guy on earth...

Joined: 04 Feb 2003 Posts: 725 Location: New Zealand (newly discovered)
|
Posted: Thu Oct 09, 2003 1:03 pm Post subject: |
|
|
that's probably what i'd do, if i was maing some kind of random map generating script.
if it's something to do with a complete modification of the entire map, then good luck with finding the help coz it all depends on so many factors it's just not worth the effort... _________________ If we were a pack of dogs, IM would be a grand Hound, CN would be a very ficious little pitball, and Giz...well, it doesn't matter breed he is, he'd still be a bitch
(no offense to anyone that was mentioned) |
|
Back to top |
|
 |
Setu_Firestorm Music Composer

Joined: 26 Mar 2003 Posts: 2566 Location: Holiday. FL
|
|
Back to top |
|
 |
Cube Dimensional Traveller

Joined: 02 Feb 2003 Posts: 294
|
Posted: Thu Oct 09, 2003 2:43 pm Post subject: |
|
|
There's a command to reseed the random generator in plotscr.hsd that isn't documented in the dictionary:
108,seedrandom,1,0 #? reseed the random number generator
So basically, it's "seedrandom(seed)". I actually don't know how seeds work, since.... I've never really looked into it . But anyhow, maybe that's what you want. |
|
Back to top |
|
 |
planethunter Lost In Emotion

Joined: 07 Jul 2003 Posts: 258 Location: Éire
|
Posted: Sat Oct 11, 2003 2:42 pm Post subject: |
|
|
I think it's just a command to reset the original value of a variable to it's original value. Here's what I mean...
script, resetingvalues, begin,
variable (x,y,dir,loop,time)
x:= herox(me)
y:=heroy(me)
dir:=random(0,3)
time:=random(2,6)
for (loop,0,01)
do(
wait (time)
create npc (1,x,y,dir)
reseed
)
)
instead of using the ":=" command to reset dir and time to random values again, the reseed command will set new values for them.
I haven't tested this script, but it should work...
As far as I know an script buffer overflow will eventually happen anyway since all those npcs being created 'til infintity is bound to cause trouble
[/quote] _________________ ~PH
 |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Oct 11, 2003 8:47 pm Post subject: |
|
|
No, that's not right-
This is what the reseed function would do (if it does work, that is): It reseeds the random number generator, effecting the numbers that random will produce. Normally, the random number generator is automatically seeded with the number of second since midnight (that's the practise with QBasic programs at least), which would be a perfectly random number in itself. The rand generator will always produce the same sequences of numbers from the same seed and limits.
What this means is that if you reseed the random function at the beginning of your script with the same number, you will always get the same numbers out of random.
So in
Code: |
variable (a,b,c,d)
reseed (1500)
a:= random(0,10)
b:= random (99,100)
c:= random (100, 1000)
d:= random (0,1)
|
a, b, c, and d will alway have the same values. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
eldritch Archmage of Mayhem and Plotscripting

Joined: 18 Sep 2003 Posts: 62 Location: Chicago Area
|
Posted: Mon Oct 13, 2003 8:44 am Post subject: |
|
|
Thank you very much, and yes, I need the seed to make it so that certain choices will always result in the same 'thing' being created within a random generation function I am making. _________________ "Live by the dice, die by the dice."
"I'd tell you but then I'd turn into a badger."
"Semper Fideles means 'we eat our dead.'"
-Anonymous marine |
|
Back to top |
|
 |
Mr B
Joined: 20 Mar 2003 Posts: 382
|
Posted: Tue Oct 14, 2003 6:54 am Post subject: |
|
|
Yay! More undocumented tidbits... *drool* I've gotta write that down somewhere. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|