The Daily Click ::. Forums ::. Klik Coding Help ::. question concerning the random function
 

Post Reply  Post Oekaki 
 

Posted By Message

ReiKGT



Registered
  09/08/2007
Points
  46
6th January, 2008 at 18:17:37 -

Is there any way to eliminate a event from the possable randomized events after it is chosen so that way i wont get the same event twice even though it is selected at random?

 
"last one left to die, please turn out the light."
The human child body template used in my avatar was made by Show Kaizer who can be found on rmxp.org forums.

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
9th January, 2008 at 06:38:43 -

If you want events repeatable, just not right after each other, then generate random numbers in a loop until the random number isn't equal to the stored older one:

+ when you want a random event
- call loop "newRandom" -1 times.

+ On loop "newRandom"
- counter newEvent = random(whatever)

+ On loop "newRandom"
+ value("newEvent") != value("oldEvent")
- counter oldEvent = value("newEvent")
- end loop "newRandom"

If you want to generate all actions in a random order, with none repeating, you can loop over an array containing the numbers corresponding to the events you've already called (like the above, but store the newEvent in the next open array index and have a subloop iterate over the array instead of comparing it to a single old one.) You may also be able to use a List object, if they have the ability to see instantly what is in it, and to remove a given value. Hope this helps.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

ReiKGT



Registered
  09/08/2007
Points
  46
10th January, 2008 at 18:37:24 -

Nice, pretty simple now I understand. I needed that for a game im making to help me with spanish.

 
"last one left to die, please turn out the light."
The human child body template used in my avatar was made by Show Kaizer who can be found on rmxp.org forums.
   

Post Reply



 



Advertisement

Worth A Click