Random No Repeats with Large Numbers

architectpianistarchitectpianist Member Posts: 21
edited November -1 in Working with GS (Mac)
Hi,
I have 48 cards in a game I'm making. They're split into two groups of 24 for each player, then two groups of 12 for black and white, and two sets of 6 of identical cards.
I need to shuffle the cards and deal them on the board like checkers pieces, zig-zag-style. I looked at tshirtbooth's random no repeats how-to, but it doesn't seem efficient in my case to use 24 attributes and assigning each one random numbers and checking each one for each attribute, etc. etc. etc. It adds up to a lot of rules. So I need a more efficient way to deal random cards with no repeats.
Thanks!

Comments

  • architectpianistarchitectpianist Member Posts: 21
    Okay, I made 24 attributes and put them all to work. Here's what each one says:

    When ALL conditions are valid:
    --self.CardValue = 1
    --game.1 < 2
    ----When ALL conditions are valid:
    ------actor receives event touch is pressed
    --------change image
    --------change attribute "game.1" to "game.1 + 1"

    So the problem now is that some cards do not respond to touch, presumably because their game attribute is higher than one. I thought of assigning CardValue another random number in the "Otherwise" section, but it would need to run through every rule again. Is there a way I can tell the compiler to go back to the beginning of the rules and check with a new random number?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi AP, not tested, but try a different order of Rules:

    When ALL conditions are valid:
    actor receives event touch is pressed
    self.CardValue = 1
    game.1 < 2

    change image
    change attribute "game.1" to "game.1 + 1"

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • architectpianistarchitectpianist Member Posts: 21
    Thanks for your help, gyroscope. :) However, I tried it, and I still have no idea why it doesn't work. I have 34 cards on screen now, and on average between 4 and 11 don't flip. Also, the same patterns tend to repeat in the cards. Why is this, and how can I fix it?
Sign In or Register to comment.