Playing with 0.9.93 - How to Shuffle a Deck of Cards + Project File

EatingMyHatEatingMyHat Member Posts: 1,246
edited May 2012 in Working with GS (Mac)
Hi,

Someone asked me if it is possible to shuffle a deck of cards in Game Salad. So since we have writable tables now, I guess the answer is why not?

This project file is nothing fancy, it displays 52 cards (empty at first) and when you click on 'Shuffle' it will shuffle the deck. The cards are marked as , so:
1. A, 1, 2, 3, .... 10, J, Q, K for the card numbers
2. d (diamond), h (heart), s and c for the symbol

The performance is very slow, but I'm sure it can be improved quite a bit (did this one in 10min so don't expect much).

It also demonstrates a loop within a loop, or sort of...

https://www.dropbox.com/s/aygrfzx0sinzwet/Shuffle.gameproj.zip

Hope you'll find it useful. Needless to say, you will need 93 for this one.

Cheers,
GR

Comments

  • StamuStamu Member Posts: 92
    Thanks for sharing. It has been a while since someone posted a free project file. Now I just need to figure out how you did it :)
  • deadlightsdeadlights Member, PRO Posts: 235
    Would be helpful if the file was available from a site that did NOT require registration to download ;)
  • EatingMyHatEatingMyHat Member Posts: 1,246
    edited May 2012
    @deadlights mmm... did not know that... here is a dropbox link: https://www.dropbox.com/s/aygrfzx0sinzwet/Shuffle.gameproj.zip

    also updated the one on top.
    Thanks for sharing. It has been a while since someone posted a free project file. Now I just need to figure out how you did it :)
    Thanks, but actually, tshirtbooth posted quite a few of those recently including a full end to end tutorial on how to build a word game, I'm sure there were others.
  • deadlightsdeadlights Member, PRO Posts: 235
    Awesome! i appreciate it (as I'm sure others do too!)
  • EatingMyHatEatingMyHat Member Posts: 1,246
    edited May 2012
    @tshirtbooth Don't mind? I was hoping for it ;)

    It's actually was not for a game, just a quick test. But now that you made it instant maybe it should be a game.

    I was thinking of optimizing it by moving the logic to the individual cards, but I didn't thought/forgot about the remove row as keeping the selection unique. Very cool solution.

    Update: LOL, just started watching your videos... I guess I should have started with that :)
  • fishZombiefishZombie Member, PRO Posts: 46
    Because of the New Update with Writeable Tables... I give you THIS:
    http://www.crypes.com/work/ShuffleTableTest1.gameproj
    This is actually a 2 part-er.
    1) is the automatic creation and placement of your cards, and assignment of values.
    2) is the Green button on the bottom left. Shuffle button
    the gray boxes show the values in the first row of the Table.
    I'm only using 10 cards to test it, but it's super clean.
    I suggest you create 1000 rows, and keep them empty, because you can now CHANGE values in Tables, not CREATE new rows.

    What I am doing is choosing the first card (row 1), and storing it's value (Column 1), then choosing a Random Row, and storing IT's value(Column 1). Then swapping the two Values (Column 1).
    Then move to the next Row (row 2), and doing the same. I swap each row with a random row.
    This shuffles the numbers pretty good.
    If you really want them shuffled Super-dooper, you can run this loop 3 times. It's super fast.
    No repeating numbers, no missing spaces.
    Remember: Col 1 is the card placement in the deck.
    You can use Col 2,3,4,5,etc for card value, color, Wild/Not, etc.
    The only thing that should change is Col 1 (placement).
    I did not do a Rule for moving the card around on the screen. that's too easy. I just wanted to show shuffling.

    Hope this helps..
    Love the New writable tables. Thanks GS!
  • EatingMyHatEatingMyHat Member Posts: 1,246
    @fishZombie Thanks for sharing!

    Next time you might want to post it to a new thread to get some more exposure.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256

    I suggest you create 1000 rows, and keep them empty, because you can now CHANGE values in Tables, not CREATE new rows.
    You can create new rows now.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Why not just reassign the images as you can call the image in tables using a non repeat number generator?
Sign In or Register to comment.