Random value from table, don't repeat cell value, until all shown once
sawkastee
Member Posts: 184
I would like to select a random cell value from a table and not repeat that cell value unless each value has already been shown once. This is what I have so far:
constrain attr
self.image to tableCellValue( game.Table 1 , game.my_style ,1)
rule when touch pressed
change att
game.my_style to random(1,tableRowCount( game.Table 1 ))
Thanks!
constrain attr
self.image to tableCellValue( game.Table 1 , game.my_style ,1)
rule when touch pressed
change att
game.my_style to random(1,tableRowCount( game.Table 1 ))
Thanks!
Comments
1) Shuffle the table rows until they are sufficiently random. Then retrieve the contents of the first row and use it as needed. Then delete the first row. (The second row now becomes the first row.) Then repeat the process.
2) Shuffle the table rows. Then have a counter that takes the first row. Increment the counter by one. (That is counter = counter +1) And take the next row. Then repeat the process. Just go down row by row until it reaches the last row.
3)Randomly find which row to use (as in your touch rule above). Get the contents of the row. Then delete that row. (And repeat)
Thanks!
Wayne
Option #3 is MUCH easier than the other options, though.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Edit: @Tatiang beat me to it! His way is much more efficient. Go with that one.