Ambrosia Garden Archive
    • Random actions


      Before I start the whole trial and error experimentation thing, does anybody know off hand, through greater knowledge of either coding or math, how the probability curve works with multiple random actions?

      For example, if you wanted and event with 10 possible actions (Call Events A-J), each one given an equal 10% chance of occuring, would you do this:

      Random 1: 10% = Call Event A
      otherwise = Random 2
      Random 2: 10% = Call Event B
      otherwise = Random 3
      Random 3: 10% = Call Event C
      otherwise = Random 4
      ...all the way to...
      Random 9: 10% = Call Event I
      otherwise = Call Event J

      Or would this favor Event J over the others? Or would it be better to leave Event J in its own random action, with the "otherwise" restarting the cycle, so the whole process would loop until a 10% action is called? Or would an entirely different percentage be needed?

      Thanks,
      Myshkyn

      ------------------
      (url="http://"http://home.earthlink.net/~isthaq/darktides")Dark Tides: Renegade Heroes(/url)

    • Straytoaster made a random script, to make a die roll. I can't remember where he posted it though.

      ------------------
      Just pimpin' my (url="http://"http://homepage.mac.com/dampeoples/iblog/index.html")scandalous stories(/url), (url="http://"http://homepage.mac.com/dampeoples/Sterling/index.html")stuff(/url), and (url="http://"http://homepage.mac.com/dampeoples/artlinks/stuff.html")art tutorial links(/url)

    • I think it should work, but probably best if you tiled the events. I've found a "rule" with the engine that it's the most stable if only one possibility can happen in an event with a conditional that has an answer to BOTH (true) and (else do). If you have a conditional that says "do nothing" under (else do), then you can have more than one conditional, as long as the engine has the ability to answer ONLY one. So you'd have not one event, but 10 tiled events. But this is for stability.

      ------------------
      -- Debra
      Danillitphil Productions
      (url="http://"http://www.danillitphil.com/graphics/index.html")www.danillitphil.com(/url)

    • Quote

      Originally posted by myshkyn:
      **Before I start the whole trial and error experimentation thing, does anybody know off hand, through greater knowledge of either coding or math, how the probability curve works with multiple random actions?

      For example, if you wanted and event with 10 possible actions (Call Events A-J), each one given an equal 10% chance of occuring, would you do this:

      Random 1: 10% = Call Event A
      otherwise = Random 2
      Random 2: 10% = Call Event B
      otherwise = Random 3
      Random 3: 10% = Call Event C
      otherwise = Random 4
      ...all the way to...
      Random 9: 10% = Call Event I
      otherwise = Call Event J

      Or would this favor Event J over the others? Or would it be better to leave Event J in its own random action, with the "otherwise" restarting the cycle, so the whole process would loop until a 10% action is called? Or would an entirely different percentage be needed?

      Thanks,
      Myshkyn

      **

      I believe that this would run fine. Coldstone would run each random action seperate of the others 1 at a time down the list.

      ------------------
      Thanks,
      GrahamVH
      graham@warcraftcentral.com
      Coldstone Developer (url="http://"http://www.warcraftcentral.net/legends/main.html")http://www.warcraftc...gends/main.html(/url)

    • Wouldn't he need a way to end the event if the engine chooses one though?

      ------------------
      -- Debra
      Danillitphil Productions
      (url="http://"http://www.danillitphil.com/graphics/index.html")www.danillitphil.com(/url)

    • Quote

      Originally posted by Debra:
      **Wouldn't he need a way to end the event if the engine chooses one though?

      **

      "Call Event X" is presumably a branch out of the nested if statement, and each event that can be called will have to have its own end sequence (which may be a branch or redirect to some other event).

      From someone with more general programming knowledge than Coldstone-specific knowledge:
      Why are you using what is essentially a nested if statement when you could use a case statement? Pseudocode:

      generate random number x (1 to 10, inclusive)
      case statement starts
      case x=1, call event A
      case x=2, call event B
      ...
      case x=3, call event J
      end case statement

      That should be more efficient, both code-wise and processor-wise, since you only generate a random number once.

      ------------------
      Yelled at the almost-dead monsters:
      Hey! Come back here with my experience points!

    • Yeah, that's what I meant by tiled, but you said it better.

      ------------------
      -- Debra
      Danillitphil Productions
      (url="http://"http://www.danillitphil.com/graphics/index.html")www.danillitphil.com(/url)

    • Thanks for the input so far.

      In the CGE Random Action event, you can only have two cases. The entire event is:

      Chance to execute = XX%
      If execute then do x
      If not then do y

      So if you want multiple possibilities, you have to create a daisy chain of Random Actions, one leading to the other. In such a chain, a successful execution ends the event itself, because the chain only has one action on the left side of the event, the rest being in the bulk of the chain, which is on the right.

      I want ten possibilities, each with an equal chance of happening. But by creating a chain, I am entering areas governed by math and/or programming knowledge that I do not have. Generating a random number would be great, but how does one do that in Coldstone?

      ------------------
      (url="http://"http://home.earthlink.net/~isthaq/darktides")Dark Tides: Renegade Heroes(/url)

    • Quote

      Originally posted by myshkyn:
      **Before I start the whole trial and error experimentation thing, does anybody know off hand, through greater knowledge of either coding or math, how the probability curve works with multiple random actions?

      For example, if you wanted and event with 10 possible actions (Call Events A-J), each one given an equal 10% chance of occuring, would you do this:

      Random 1: 10% = Call Event A
      otherwise = Random 2
      Random 2: 10% = Call Event B
      otherwise = Random 3
      Random 3: 10% = Call Event C
      otherwise = Random 4
      ...all the way to...
      Random 9: 10% = Call Event I
      otherwise = Call Event J

      Or would this favor Event J over the others? Or would it be better to leave Event J in its own random action, with the "otherwise" restarting the cycle, so the whole process would loop until a 10% action is called? Or would an entirely different percentage be needed?

      Thanks,
      Myshkyn

      **

      With this method, event J has a 38.7% of triggerring. A has the proper chance, 10%. (of course) It goes down until I, which only has a 4.3% of triggering, then shoots up at J. Axe's case statement is less processor intensive (if you'll be calling this a lot), and has the right probabilities.

      ------------------
      Sometimes it would stop raining long enough for the stars to come out. And then it was nice. - Forrest Gump
      Check out my (url="http://"http://www.livejournal.com/users/~celchu")blog.(/url)

    • if you fix the probabilities you can have it seem to have 10% when it actually has 10% for A, then 11.11% for B, then 12.5% for C and so on

      ------------------
      "There are no turtles anywhere" Ponder Stibbons
      (url="http://"http://www.krytencrc.cjb.net")Kryten's Headquarters(/url)
      (url="http://"http://www.silvernetwork.net/kryten/mcheese.htmll")All your Cheese are belong to us(/url)

    • Whoa... It seems this is being complicated a bit... All these percents... (which CS doesn't use with its random feature). Here's my summary (for those that are wondering, it is in Java syntax, not too hard to follow, though I skipped most of the key language points like how to set a variable and used only the end-of-line marker (;), the comments (//), and the if-else formatting):

      Set gb_random-num to Random with value 10; //produces a number from 1 to 10;
      If (gb_random-num = 1){do Action A;} else{do nothing;}
      If (gb_random-num = 2){do Action B;} else{do nothing;}
      If (gb_random-num = 3){do Action C;} else{do nothing;}
      If (gb_random-num = 4){do Action D;} else{do nothing;}
      If (gb_random-num = 5){do Action E;} else{do nothing;}
      If (gb_random-num = 6){do Action F;} else{do nothing;}
      If (gb_random-num = 7){do Action G;} else{do nothing;}
      If (gb_random-num = 8){do Action H;} else{do nothing;}
      If (gb_random-num = 9){do Action I;} else{do nothing;}
      If (gb_random-num = 10){do Action J;} else{do nothing;}
      

      That should do it. In pure simple Java-Stone. 😄 (If anyone has trouble readin Java-Stone I can transpose into Coldstonish, though the differences aren't that great...).

      EDIT: wouldn't let me post my message... I had to post a plain message (no symbols, etc. and then edit in the code... :

      ------------------
      Cha0s
      (url="http://"http://www.world-of-cha0s.hostrocket.com")The Homepage of Cha0s(/url)

      (This message has been edited by CI-Ia0s (edited 01-06-2004).)

    • Java-Stone?

      What's that?

      ------------------
      "There are no turtles anywhere" Ponder Stibbons
      (url="http://"http://www.krytencrc.cjb.net")Kryten's Headquarters(/url)
      (url="http://"http://www.silvernetwork.net/kryten/mcheese.htmll")All your Cheese are belong to us(/url)

    • Excellent. I never noticed the random option under the change globals action. Thanks Cl-laos and everyone else for the help.

      Myshkyn

      ------------------
      (url="http://"http://home.earthlink.net/~isthaq/darktides")Dark Tides: Renegade Heroes(/url)

    • Oh my heavens, what a gift, Chaos! I never noticed it either. Thank you so much!!! 🙂

      ------------------
      -- Debra
      Danillitphil Productions
      (url="http://"http://www.danillitphil.com/graphics/index.html")www.danillitphil.com(/url)

    • Quote

      Originally posted by Debra:
      **Oh my heavens, what a gift, Chaos! I never noticed it either. Thank you so much!!!:) **

      Has anyone figured out how to limit the random feature here (in Change Globals) to a set Maximum? Will the operation value set the max? or is it limited to some preset value? Or the last value used? See what I mean?

      ------------------
      -Albadar-
      - - - - - - - - - -
      Just trying...

    • Yeah. He is the method.

      1. Create your global eg gb_random
      2. Create an event
      3. Add a Change Global action that sets gb_random to Random
      4. Set the Operational value to you max value
      5. Add the rest of you event

      If you set the operational value to 2 for example, CS will come up with 3 numbers (0,1,2) If you only want it to come up with either 1 or 2 then set the operational value to 1. Then add another Change Global action straight after your first one and make it Add 1.

      CS then picks either 0 or 1 at random. When it picks 0 it then adds 1 to make 1 in the next action, and if it picks 1 you get 2. Simple

      ------------------
      Pilky
      (url="http://"http://www.mcubedsw.com")M cubed homepage(/url)
      (url="http://"http://www.coldstonerc.cjb.net")Coldstone Resource Centre(/url)
      Cheesiest film line of all time "Flash I love you but we only have 14 hours to save the earth" from Flash Gorden

    • Quote

      Originally posted by CI-Ia0s:
      **

      Set gb_random-num to Random with value 10; //produces a number from 1 to 10;
      If (gb_random-num = 1){do Action A;} else{do nothing;}
      If (gb_random-num = 2){do Action B;} else{do nothing;}
      If (gb_random-num = 3){do Action C;} else{do nothing;}
      If (gb_random-num = 4){do Action D;} else{do nothing;}
      If (gb_random-num = 5){do Action E;} else{do nothing;}
      If (gb_random-num = 6){do Action F;} else{do nothing;}
      If (gb_random-num = 7){do Action G;} else{do nothing;}
      If (gb_random-num = 8){do Action H;} else{do nothing;}
      If (gb_random-num = 9){do Action I;} else{do nothing;}
      If (gb_random-num = 10){do Action J;} else{do nothing;}
      

      **

      This works like a charm. I just implemented it in my own game, when the Player has to sleep. How much stamina he regains depends on the amount of money he has to dish out for a room as well as the random numbers. In other words, I have more than one event using the same global. The engine also rolls a 0 as a number. Once I discovered that, I placed a conditional to give stamina with a 0. I added a change globals to SET gb_sleep_random to 0 at the very bottom of the event. I like to place in the extra precaution, just in case the engine doesn't understand.

      ------------------
      -- Debra
      Danillitphil Productions
      (url="http://"http://www.danillitphil.com/graphics/index.html")www.danillitphil.com(/url)