Jump to content
EleTD.com
Sign in to follow this  
Karawasa

Intro CS - FTW

Recommended Posts

I was able to quickly create the randomization in Chaos mode, thanks to Intro CS. We learned Java in the class, and one assignment required us to randomize a list. Here is the code, I'm sure you can see what I am talking about:

For each (Integer A) from 0 to 59, do (Actions)
    Loop - Actions
        Set Random_Spawn = (Random integer number between 0 and 59)
        Set Temp_Spawn = Spawns[(Integer A)]
        Set Spawns[(Integer A)] = Spawns[Random_Spawn]
        Set Spawns[Random_Spawn] = Temp_Spawn

Share this post


Link to post
Guest mrchak

You could probably even do

For each (Integer A) from 0 to 58, do (Actions) 
...
Set Random_Spawn = (Random integer number between Integer A and 59)
...

which will go through every one and swap it with a random round that comes after it (or itself). Once it gets to 58, it doesn't need to do 59, because its already been swapped most likely.

And if you want to ENSURE no round ends up being itself, then you could say:

For each (Integer A) from 0 to 58, do (Actions) 
...
Set Random_Spawn = (Random integer number between Integer A+1 and 59)
...

Share this post


Link to post
Guest Sancdar

Uh...what do you suggest? Chak's is the standard prand initialization.

Share this post


Link to post
Sign in to follow this  

×
×
  • Create New...