Author Topic: My request thread  (Read 7317 times)

0 Members and 1 Guest are viewing this topic.

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
20. Random number SEXPs that make use of a random number seed that the user can set. Such that if a mission is called twice, and each time the same random number seed is used, any calls to random number SEXPS (or send random message) give the same result. This would be enormously useful for pseudo randomly generating missions.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
20. Random number SEXPs that make use of a random number seed that the user can set. Such that if a mission is called twice, and each time the same random number seed is used, any calls to random number SEXPS (or send random message) give the same result. This would be enormously useful for pseudo randomly generating missions.

What about setting a variable equal to the rand sexp when the mission starts, and using that variable for each "random" number requirement?

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Use a load of random number variables to store "rand" values? Well okay:

1. The random number seed solution is more elegant and uses less variables and sexp tree nodes (both a limited resource).
2. rand generates different numbers each reload of the mission. Not the functionality I'm requesting.
3. Generate the numbers in the previous mission and pass them? I figured you'd think of this like I did. Works too well since the rands in the previous mission seem to generate the same numbers each time. Replay previous mission also scuppers this idea.

Bottom line, the seeded random number functionality is there in most languages and it's incredibly useful. You can build whole galaxies with the principle. Check out Frontier (Elite 2) or Damacles. At this point it would also be the single biggest improvement that could be made to help my BHX campaign. Okay maybe after the modest sexp tree node limit increase (or dynamic memory allocation for sexp tree nodes).

I realise I'm a pain in the ass but try to humour me. My crazy ass campaign is coming on leaps and bounds and with a little co-operation from the SCP team will soon be done. Once it is, it'll pave the way for others to rip out my "code" and build there own pseudo randomly generated stuff. It's cool. Trust me  :).

Edit: Doesn't FS already use seeded random numbers? I'm guessing the seed is set based on run-time or something. That's usually how it works. So surely this request just involves the implementation of one set-random-seed SEXP?
« Last Edit: February 22, 2006, 03:27:11 pm by IPAndrews »
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Edit: Doesn't FS already use seeded random numbers? I'm guessing the seed is set based on run-time or something. That's usually how it works. So surely this request just involves the implementation of one set-random-seed SEXP?

Actually, I'm pretty sure it's not a random number at all, but rather something calculated from mission time.  Try displaying the results of rand in conjunction with has-time-elapsed and see what you get.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
1. String -> number conversion sexp.

Got bored. Added this. It was only about 2 lines of code :)

Little less certain how easy it's opposite will be to add without actually having a proper string return type. Will investigate when it's not 1:30am :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Proper string return types would be handy for script-eval-string.
-C

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Got bored. Added this. It was only about 2 lines of code :)

What? Really? One of my suggestions made it in? This is a cruel joke right?  :nervous:
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Actually, I'm pretty sure it's not a random number at all, but rather something calculated from mission time.  Try displaying the results of rand in conjunction with has-time-elapsed and see what you get.

Well no random numbers are really random numbers. We all know that  :D. This is just another variation on a theme. A fairly odd one though. Is there some reason it works like this? Some random event somewhere in the standard campaign that is always run at exactly the same time and requires the same random number to be generated? If so why the heck is a random number being used? The more I find out from you guys about the workings of this code the more baffled I get.

Well to be on the safe side - I guess - new rand-seeded and rand-multiple-seeded sexps would be required. If it was me, I'd just modify the default behaviour of the existing sexps because I would bet good money (albeit someone elses money) that behaviour is just wierd programming rather than serving any purpose. A random number seed set on the milliseconds of current time at mission start would be sufficient, and allow it to be modified in order to do cool stuff.  :nod:

See what I did there? I nodded to subliminally influence you to agree with me.  :nod:
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
What? Really? One of my suggestions made it in? This is a cruel joke right?  :nervous:

Nope. It's in CVS already. All it basically does is call the standard library's function for doing the same thing.

Incidentally Goober seems to have snuck in a Key-reset-multiple SEXP when I wasn't looking :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Incidentally Goober seems to have snuck in a Key-reset-multiple SEXP when I wasn't looking :)

So the original key-reset only worked the once? I can't say I ever noticed but it would explain a few things.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
The original key-reset displayed all kinds of odd behaviour. I had a thread on it here :)

EDIT : Added the pics again :)
« Last Edit: February 23, 2006, 06:38:25 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

  

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
I like the subject title. Looks like I'm not the only one who gets stressed with this stuff.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Told you I recognised the symptoms :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline StratComm

  • The POFressor
  • 212
  • Cameron Crazy
    • http://www.geocities.com/cek_83/index.html
Well no random numbers are really random numbers. We all know that  :D. This is just another variation on a theme. A fairly odd one though. Is there some reason it works like this? Some random event somewhere in the standard campaign that is always run at exactly the same time and requires the same random number to be generated? If so why the heck is a random number being used? The more I find out from you guys about the workings of this code the more baffled I get.

Truth be told though, there's no such thing as a truely random number generated by a computer.  You can do things like seed the generator based on the system clock or something like that, but ultimately it's still not random.  In this particular case, it's probably just setting the seed improperly rather than doing anything wrong.

That said, since Rand has been non-random for as long as it has, it becomes a question as to whether it's better to fix the SEXP that's there and risk breaking a campaign that's built with it or to create a new actual-rand sexp that behaves more like you want and doesn't affect backwards-compatability.
who needs a signature? ;)
It's not much of an excuse for a website, but my stuff can be found here

"Holding the last thread on a page comes with an inherent danger, especially when you are edit-happy with your posts.  For you can easily continue editing in points without ever noticing that someone else could have refuted them." ~Me, on my posting behavior

Last edited by StratComm on 08-23-2027 at 08:34 PM

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
That said, since Rand has been non-random for as long as it has, it becomes a question as to whether it's better to fix the SEXP that's there and risk breaking a campaign that's built with it or to create a new actual-rand sexp that behaves more like you want and doesn't affect backwards-compatability.

It is possible to have the best of both worlds here. I cannot think of any way that changing the original sexps to use a seed generated from current time at the start of the mission would affect backward compatability. After all, you're not changing what the sexp is providing, just it's internal workings. Once changed all that's needed is a set-random-seed sexp to override the one generated at start of mission and suddenly you have random numbers which are more random  :yes: and less predictable in general but can generate numbers is a predictable order by overriding the seed  :yes:.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Actually, I'm pretty sure it's not a random number at all, but rather something calculated from mission time.  Try displaying the results of rand in conjunction with has-time-elapsed and see what you get.

Nope. It does generate a random number. It calls the rand_internal function which simply uses the standard C library's rand() function.

 

20. Random number SEXPs that make use of a random number seed that the user can set. Such that if a mission is called twice, and each time the same random number seed is used, any calls to random number SEXPS (or send random message) give the same result. This would be enormously useful for pseudo randomly generating missions.

Done and in CVS.

I haven't looked at random-of yet but Rand and Rand-Multiple now take an optional 3rd argument which allows you to seed the functions. I don't think I've changed anything if the seed isn't present (it should do exactly what it did before if no seed is present).
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
That's fantastic news. You have no idea how useful that will be! Well to be fair, you probably do actually. No more reloading a mission to generate an easier one. This is truly great news. Must go tell Madaboutgames now :).
« Last Edit: February 25, 2006, 11:49:49 am by IPAndrews »
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.