Cycle through a list of numbers without repeating until the end.

TheAJTurnerTheAJTurner Member, PRO Posts: 18

So for my project, I need a simple way to cycle through 1-30 without repeating a single number until all of the numbers have been used. Is there an easy way to do this?

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881

    You want to count up from 1 through 30 and then start over at 1 again?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2016

    There are many videos that explain how to do this. The general idea is to add the numbers to a table (one number per row) and then when a row has been chosen, use the value therein however you like and delete the row. Then repeat the process.

    Google random without repeat gamesalad for tutorials.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @tatiang said:
    There are many videos that explain how to do this. The general idea is to add the numbers to a table (one number per row) and then when a row has been chosen, use the value therein however you like and delete the row. Then repeat the process.

    Google random without repeat gamesalad for tutorials.

    Hmm I should do a video on this.

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    @Lost_Oasis_Games said:

    @tatiang said:
    There are many videos that explain how to do this. The general idea is to add the numbers to a table (one number per row) and then when a row has been chosen, use the value therein however you like and delete the row. Then repeat the process.

    Google random without repeat gamesalad for tutorials.

    Hmm I should do a video on this.

    Already a few vids on this - many with slightly different techniques even.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    You want to count up from 1 through 30 and then start over at 1 again?

    I may do a tutorial on this... lol ;)

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881

    @jamie_c said:

    You want to count up from 1 through 30 and then start over at 1 again?

    I may do a tutorial on this... lol ;)

    The original question seemed straight forward enough to me. But maybe the OP really did want to learn about random w/o replacement. Who knows?!?!

  • TheAJTurnerTheAJTurner Member, PRO Posts: 18

    I didnt phrase the question well my bad guys. What I meant was I need to be able to RANDOMLY cycle through a numbers 1-30 without having any numbers repeat. I don't think I can use the remove cell function because I want to be able to repeat the process over again.

  • mhedgesmhedges Raised on VCS Member Posts: 634
    edited March 2016

    @TheAJTurner , you should have two tables, one with the numbers from 1-30, and the other with the numbers too, but you will remove the rows from this one once the random value is read from it. When it's all done, then you copy the original table back to have your numbers from 1-30 again.

    I actually used this technique in Chibi Invaders to invoke a random alien to fire its laser, but the alien obviously had to be alive, hence the use of the table. There are 32 aliens, and if, say, alien#12 is destroyed, then 31 are left, but the game now "knows" alien #12 is destroyed, since it no longer forms part of the table during the current round.

  • TheAJTurnerTheAJTurner Member, PRO Posts: 18

    Awh thank you mhedges this looks like it will work out great for me!

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @jamie_c said:

    You want to count up from 1 through 30 and then start over at 1 again?

    I may do a tutorial on this... lol ;)

    I don't generally watch tutorials, please forgive my ignorance ;)

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    The original question seemed straight forward enough to me.

    @RThurman, I thought exactly the same thing.

    @Lost_Oasis_Games, I'm sure you're too busy making tutorials to watch any! :)

  • ArmellineArmelline Member, PRO Posts: 5,421
    edited March 2016

    I favour doing this with a text attribute rather than the overhead of tables. Same principles, though.

    Edit: While you guys were arguing over who was going to make a video I snuck in and whipped mine out. Straight from silver-spoonville™!

    Edit2: Totally miss-spelled Table-less. I'll fix it eventually :P

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Lol @Armelline!

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @Armelline said:
    I favour doing this with a text attribute rather than the overhead of tables. Same principles, though.

    Edit: While you guys were arguing over who was going to make a video I snuck in and whipped mine out. Straight from silver-spoonville™!

    Edit2: Totally miss-spelled Table-less. I'll fix it eventually :P

    :p

Sign In or Register to comment.