generate non-repeat random table cell value until done

DoguzDoguz Member Posts: 500
Does anyone know where a tutorial is to create this? I know it's a simple one, but I just can't make it simple.

Just one column of text values - say 5. Draw them out in random until complete - no repeat.

Best Answers

  • gyroscopegyroscope I am here.Posts: 6,598
    edited April 2013 Accepted Answer

    Hi @Doguz and here's yet another way...

    Basically, it's to copy the table, random row, delete that row, random row from rows-1, delete, etc., that way there's the guarantee of no repeats; and seeing as it's a copy of the table it's non-destructive. Hope you find it useful. :-)

    P.S there's some redundant attributes, I think, so just ignore those not used... (of course!)
  • gyroscopegyroscope I am here.Posts: 6,598
    Accepted Answer
    Love it. Thanks Gyro
    Glad it helps. :-) It's very odd, but someone has deleted my post as well as the game file, for some reason....

    Here it is again (I'm sure you've got your copy, @Doguz so for anyone else who might need it...)

Answers

  • DoguzDoguz Member Posts: 500
    FOUND IT. GS life was a lot easier when this guy was around. @tshirtbooth

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Try this thread it's a much better method. http://forums.gamesalad.com/discussion/comment/391503
  • DoguzDoguz Member Posts: 500
    Love it. Thanks Gyro
  • ericzingelerericzingeler Member Posts: 334
    edited April 2013
    Here's another template somewhat like gyro's, but a bit more automagic. No seperate reset function is required.

    https://dl.dropboxusercontent.com/u/27937751/gs/modules/RandomWithoutReplace_v1.0.gameproj.zip
  • DoguzDoguz Member Posts: 500
    Thanks @ericzingeler but your solution does in fact repeat. A few instances I found repeated letters in a row. Also I am after a solution that ends after all cells have been used. Thanks for posted anyway, Always good to see a number of ways to do things.

    And @fryingbaconstudios I took a look at that and maybe the code is nicer to pickout the random, but Gyros solution is the one I'm after. It pulls out a used cell so it wont be shown again.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @Doguz, the way I do this in quiz apps I've built for other people is to randomize the table rows (or columns if you prefer) and then just start with the last row, get the data from it and delete that row after it has been used. As long as your code is always getting data from the row with number equal to tableRowCount(tableName), it will refresh the data correctly. You can use my randomize demo if you like: http://forums.gamesalad.com/discussion/53553/demo-randomize-table-rows.

    And you would just have a rule that says when tableRowCount(tableName)=1, get the data and then change scene/end the game after that.
  • DoguzDoguz Member Posts: 500
    @gyroscope Whenever I select Yes to the Did this answer the question. IT DELETES YOUR POST. WHY???
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited April 2013

    @Doguz How very strange.... I've no idea why that should happen... gotta be a Vanilla Forums bug for certain.... don't know if @SaladStraightShooter could confirm this and get it fixed, thanks....(that'd be appreciated, if so) :-)

    In the meantime, I'll upload the file yet again.... but this time, don't worry about clicking Yes, see how long it stays!!!! :-))
Sign In or Register to comment.