Need help with random number.

AlkaPPAlkaPP Member, PRO Posts: 194

Hi all,

Can someone show me how to assign a random number to actors without repeating the same number?

For example, number random from 1-10 without repeating then assign them to 10 actors so each actor has a unique random number.

I know it is confusing, but please help. An alternative way to get the same result would be great too.

Thanks,

Alan,

Comments

  • AlkaPPAlkaPP Member, PRO Posts: 194

    Thanks @8bitninja, i've seen that one. It is not exactly what I'm looking for. I'm trying to random 1-10 without repeating it.

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

    You've seen that one? It was a Google Search with 4,060 results. I can assure you that at least one of those results is the correct answer to your question. The first result (a tshirtbooth YouTube video) is in fact a demonstration of a way to select a random number without repeating it but generally the accepted method for doing this now is to use a table as follows:

    Create a table with a unique value in each row (column 1):
    1 2 3 4 5 6 7 8 9 10

    Repeat until the table is empty:

    1. Change attribute game.randomRow (integer) to random(1,tableRowCount(tableName))
    2. [do whatever you need with the value in TableCellValue(tableName,game.randomRow,1)]
    3. Delete Table Row at index game.randomRow
Sign In or Register to comment.