Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Seeding the Random Function

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
eldritch
Archmage of Mayhem and Plotscripting




Joined: 18 Sep 2003
Posts: 62
Location: Chicago Area

PostPosted: Thu Oct 09, 2003 7:30 am    Post subject: Seeding the Random Function Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Setu_Firestorm
Music Composer




Joined: 26 Mar 2003
Posts: 2566
Location: Holiday. FL

PostPosted: Thu Oct 09, 2003 12:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Flamer
The last guy on earth...




Joined: 04 Feb 2003
Posts: 725
Location: New Zealand (newly discovered)

PostPosted: Thu Oct 09, 2003 1:03 pm    Post subject: Reply with quote

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 Raspberry!
(no offense to anyone that was mentioned)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Setu_Firestorm
Music Composer




Joined: 26 Mar 2003
Posts: 2566
Location: Holiday. FL

PostPosted: Thu Oct 09, 2003 1:15 pm    Post subject: Reply with quote

Well, in all-else-fails cases, here's Moogle's script for a random map generator.
_________________


Facebook: http://www.facebook.com/georgerpowell
Newgrounds: http://setu-firestorm.newgrounds.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Cube
Dimensional Traveller




Joined: 02 Feb 2003
Posts: 294

PostPosted: Thu Oct 09, 2003 2:43 pm    Post subject: Reply with quote

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 Raspberry!. But anyhow, maybe that's what you want.
Back to top
View user's profile Send private message
planethunter
Lost In Emotion




Joined: 07 Jul 2003
Posts: 258
Location: Éire

PostPosted: Sat Oct 11, 2003 2:42 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat Oct 11, 2003 8:47 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
eldritch
Archmage of Mayhem and Plotscripting




Joined: 18 Sep 2003
Posts: 62
Location: Chicago Area

PostPosted: Mon Oct 13, 2003 8:44 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Mr B




Joined: 20 Mar 2003
Posts: 382

PostPosted: Tue Oct 14, 2003 6:54 am    Post subject: Reply with quote

Yay! More undocumented tidbits... *drool* I've gotta write that down somewhere.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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