pick your brain

PeeCeePeeCee Member Posts: 107
edited November -1 in Working with GS (Mac)
Hi guys.

I've got something to do that appears to be easy but im not picking it out yet. so i thought i'd get you guys to throw something at me to see if any lights turn on upstairs.

Allow me to kindly give you a tale scenario for this occasion.

i have 2 people
person 1 has to choose a number between 1-5, he then gives that number to person 2 who then has to randomly pick from 1-20 lollies he has in the bag using the number person1 gave him.

so example, person 1 (picked number 3) , then person 2 has to pick 3 lollies from the 20 lollies he has. the queston is how to make person 2 always choose random lollies from the number he has.

sorry if ive not explained my scenario well.
appreciate your help

Comments

  • old_kipperold_kipper Member Posts: 1,420
    First actor has a random of 1 to 5 is easy. Just set a rule with change attribute inside that puts a number using random(1,5) into a game attribute, then fires a boolean game or scene attribute that is the signal to start the second actor choosing.

    The second actor is more complex as you are asking it to choose from a pool of decreasingly available numbers. When the boolean is fired it will have a rule that is triggered and will then use the first actor's number that was randomly generated as a counter to make the choices, (or you could use the rule that when the first actor's number is greater than zero, to make choices until the number is zero and reduce the number each time a choice is made).

    The trick part is to have the pool picked from as it declines as I have said before. You can do this by either storing the just chosen numbers and picking again if it comes up a second time, or reduce the pool each time by closing the gap in the choices made by the taken numbers. To do the later each number would have to sit in rule set that renumbers itself to reduce the stack to a sequence. You can take the top number and drop it each time into the gap, or have a diminishing ladder. This gets a bit tricky and though I've done it I would recommend the re-choose method.

    At the end of each cycle you will need to reset the system with a falsify of the boolean and/or zeroing of the first actor's random, as well as creating rules that reset the second actor's state.

    I hope this helps.

    kipper
Sign In or Register to comment.