Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Shuffling a deck of cards
Shuffling a deck of cards
Apr 27 2008, 2:34 pm
By: Zwo  

Apr 27 2008, 2:34 pm Zwo Post #1



I was wondering if there's an easy way to shuffle (and later reshuffle) a deck of 52 cards. One thing I thought of was preplacing all the "cards" in one area and then randomly pick one card and move it to location 1. Then move a second card to location 2. And so on till all the cards are moved to locations 1 to 52. But I don't trust everyone with their maphacks so this wouldn't be the best way I think.

Any ideas on shuffling the deck using just triggers?



None.

Apr 27 2008, 3:34 pm Falkoner Post #2



http://Falkoner.CoW.GooglePages.com/Switches.html

I believe you are looking for randomization :P



None.

Apr 27 2008, 3:41 pm O)FaRTy1billion[MM] Post #3

👻 👾 👽 💪

Yes, but randomization is one thing. In order to make it shuffled (not getting the same thing twice) is a bit more work.



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Apr 27 2008, 3:53 pm Falkoner Post #4



Oh, c'mon, you can shuffle it and get the same thing twice :P



None.

Apr 27 2008, 3:56 pm LoveLess Post #5

Let me show you how to hump without making love.

I used DCs for my randomization of a monopoly deck of cards. You have a DC that counts from 1 to 52, when it hits 53 or more, put it back at 1. When you call upon a card, check if that card has been drawn (i used switches for this), if it has, add 1 death and repeat the trigger. It's pretty random.

Quote
Condition:
Deaths for ??? is at most 52

Action:
Add 1 Death for ???
Preserve Trigger

Quote
Condition:
Deaths for ??? is at least 53

Action:
Set To 0 Death for ???
Preserve Trigger

Quote
Condition:
Deaths for ??? is exactly x
Switch x is disabled
Switch 255 is enabled (wanting to draw)

Action:
Create unit Card x at 'hand'
Enable Switch x
Disable Switch 255
Preserve Trigger

Quote
Condition:
Deaths for ??? is exactly x
Switch x is enabled
Switch 255 is enabled (wanting to draw)

Action:
Add 1 Death for ???
Preserve Trigger


Post has been edited 1 time(s), last time on Apr 27 2008, 4:06 pm by LoveLess.



None.

Apr 27 2008, 4:38 pm Sarge Post #6



You could do something like this:

Have 52 squares, each with the different unit on it (if your using units to represent each card). Always moving all the units to the right one square, and keep this up the entire game. Then use something independent (like a player bringing a unit sumwhere) to deal the cards from the locatations you want.



None.

Apr 27 2008, 5:28 pm LoveLess Post #7

Let me show you how to hump without making love.

Quote from Sarge
You could do something like this:

Have 52 squares, each with the different unit on it (if your using units to represent each card). Always moving all the units to the right one square, and keep this up the entire game. Then use something independent (like a player bringing a unit sumwhere) to deal the cards from the locatations you want.

Quote from Zwo
But I don't trust everyone with their maphacks so this wouldn't be the best way I think.
Quote from Zwo
Any ideas on shuffling the deck using just triggers?




None.

Apr 27 2008, 5:48 pm rockz Post #8

ᴄʜᴇᴇsᴇ ɪᴛ!

Four suits, 13 bits, decimal 8192, into storage dc

Set up a randomization for 13 cards and 4 suits.

When you pick a card, subtract out the rest of the cards' numbers from the storage dc

if the card is drawable, add a death to say it's drawn, so that you never subtract it out again.

Add the rest of the cards back into the suit.

If you draw a card that has already been drawn, add the deaths back, and start the entire process again.

Now, I have no clue how you're going to represent the cards without showing maphackers what you have. I suppose a text display system could do it, but that would be annoying to code.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Apr 27 2008, 8:18 pm fritfrat Post #9



Just have one area of "available cards" on junkyard AI and one area of "used cards" and just move 1 unit from "available cards" to a intermediate location, copy it, and then move it into "used cards" whenever I wanted to get a card. Reshuffle: move all the units back!

I originally said just put arbiters over locations 1-52, but I think a lot of maphacks can see cloaked units.

Post has been edited 2 time(s), last time on Apr 27 2008, 8:24 pm by fritfrat(U).



None.

Apr 27 2008, 8:41 pm FooFighters Post #10



Quote from name:fritfrat(U)
Just have one area of "available cards" on junkyard AI and one area of "used cards" and just move 1 unit from "available cards" to a intermediate location, copy it, and then move it into "used cards" whenever I wanted to get a card. Reshuffle: move all the units back! I originally said just put arbiters over locations 1-52, but I think a lot of maphacks can see cloaked units.

Quote from Zwo
I was wondering if there's an easy way to shuffle (and later reshuffle) a deck of 52 cards. One thing I thought of was preplacing all the "cards" in one area and then randomly pick one card and move it to location 1. Then move a second card to location 2. And so on till all the cards are moved to locations 1 to 52. But I don't trust everyone with their maphacks so this wouldn't be the best way I think. Any ideas on shuffling the deck using just triggers?

What did he just tell you!!
Besides, randomization is the best method! unlike having randomization just like that, set deaths when a card is selected, and then if it gets the card again, randomize the switches again :D



None.

Apr 27 2008, 9:21 pm Wormer Post #11



This is very interesting question...
Something to think about. I think I have a very unsusual solution, but first I would like to know what are you going to do with the cards? Do you need to keep the deck wtih the specific cards order from top to buttom or just randomly distribute 52 cards between players? You see... the problem is in representation of the deck and it's storage in the "memory" of the map. Could you please describe the whole game you're trying to accomplish? What is the representation of cards in your game? Are they units controlled by different players, like red marine, black marine and so on... or are they just different 52 SC units? Or mabe you representing them by text messages as rockz have said.

Quote
Four suits, 13 bits, decimal 8192, into storage dc

Set up a randomization for 13 cards and 4 suits.

When you pick a card, subtract out the rest of the cards' numbers from the storage dc

if the card is drawable, add a death to say it's drawn, so that you never subtract it out again.

Add the rest of the cards back into the suit.

If you draw a card that has already been drawn, add the deaths back, and start the entire process again.

Now, I have no clue how you're going to represent the cards without showing maphackers what you have. I suppose a text display system could do it, but that would be annoying to code.
I dont understand what you're going to say. Could you please explain me what have you meant.

EDIT:
BTW could those hacks see what units are loaded in a transport? I mean, if that is true you could represent cards with units loaded in transport not to show them to maphackers.

Post has been edited 3 time(s), last time on Apr 27 2008, 9:29 pm by Wormer.



Some.

Apr 27 2008, 9:56 pm FooFighters Post #12



Quote from Wormer
This is very interesting question... Something to think about. I think I have a very unsusual solution, but first I would like to know what are you going to do with the cards? Do you need to keep the deck wtih the specific cards order from top to buttom or just randomly distribute 52 cards between players? You see... the problem is in representation of the deck and it's storage in the "memory" of the map. Could you please describe the whole game you're trying to accomplish? What is the representation of cards in your game? Are they units controlled by different players, like red marine, black marine and so on... or are they just different 52 SC units? Or mabe you representing them by text messages as rockz have said.
Quote
Four suits, 13 bits, decimal 8192, into storage dc Set up a randomization for 13 cards and 4 suits. When you pick a card, subtract out the rest of the cards' numbers from the storage dc if the card is drawable, add a death to say it's drawn, so that you never subtract it out again. Add the rest of the cards back into the suit. If you draw a card that has already been drawn, add the deaths back, and start the entire process again. Now, I have no clue how you're going to represent the cards without showing maphackers what you have. I suppose a text display system could do it, but that would be annoying to code.
I dont understand what you're going to say. Could you please explain me what have you meant. EDIT: BTW could those hacks see what units are loaded in a transport? I mean, if that is true you could represent cards with units loaded in transport not to show them to maphackers.
Oblivion users can still see em



None.

Apr 27 2008, 11:49 pm Conspiracy Post #13



Quote from Zwo
But I don't trust everyone with their maphacks so this wouldn't be the best way I think.

Ez-Fix Zwo. Look at the Texas Hold'em map. 2 things happen if you MH. 1. You drop >:D 2. The units are covered up by floating C.C's, so even if you don't crash, you can see them.



None.

Apr 27 2008, 11:54 pm Falkoner Post #14



Lol, yeah, you can cover the units with floating CC's for hacks that block crashing units, and also place a bunch of crashing units in the middle of them, so if anyone tries to cheat they get crashed :P



None.

Apr 28 2008, 12:04 am Brontobyte Post #15



Quote from name:Epoch
Quote from Zwo
But I don't trust everyone with their maphacks so this wouldn't be the best way I think.

Ez-Fix Zwo. Look at the Texas Hold'em map. 2 things happen if you MH. 1. You drop >:D 2. The units are covered up by floating C.C's, so even if you don't crash, you can see them.

That isn't pullet proof. All you have to do is click and drag to select units. Eventually you will have one of them selected. Its not easy and it will be hard to remember them/you would probably get tired of trying to do this. I also edited out the crashing sprites. Its a good idea, but you could still see the units. What if you had the Command Centers owned by the players. If they selected it and tried to find what was under it, it would just show them their Command Center, not what was underneath, I think. Or, you could do the Command Centers for the computer player, and have Protoss Arbiters surrounding the entire area so no matter what, you couldn't see it, and you couldn't click+drag select them. :D



None.

Apr 28 2008, 12:10 am rockz Post #16

ᴄʜᴇᴇsᴇ ɪᴛ!

I'll try to be more clear.

Assign a death counter to each suit: Hearts=Cantina, Spades=Cave, Diamonds=Cave-in, Clubs=Jump Gate
For each of these death counters, there will be a bit assigned to each number
Code
1111111111111
KQJ098765432A

10 is 0, of course, for clarification.

Now, if the card exists in the deck, there will be a 1 there. If it does not exist, there will be a 0 there. Of course, Starcraft can't handle such a 13 digit number in decimal, so you need to change it from binary into decimal, or 2^13, which is 8192, or 8191 counting 0. This means that the following cards have the following decimal numbers associated with them:
Code
K 4096
Q 2048
J 1024
0 512
9 256
8 128
7 64
6 32
5 16
4 8
3 4
2 2
A 1

Now, for a description of how the triggers would work. First you draw a card, and the triggers would randomly decide on one of the four suits (just 2 switches). From there, it decides on a card to be drawn (needs 13, so 4 switches, ignore the last 3 possibilities, since 2^4 is 16 and you only need 13). Now, it checks to see if that card is available by subtracting out the REST of the numbers in the death counter.

Say, you choose a king. That means you will subtract out QJ0987654321, or 4095 from the death counter. If you have 4096 left over, the king is available to draw, so you draw it. When subtracting, you have to take into account the cards which had been previously drawn, and don't subtract them from the death counter. Now permanently subtract the 4096, and add in the 4095 you just took out.

After the king has been drawn, say you now want to draw again, and this time you get a 6 out of the same suit. You have to subtract out KQJ098754321, or 8159. Since you already have drew the king, you'll have to add in 4096, or just not subtract it when you normally would by setting some form of death counter (saying I've already drawn king, don't bother with it). That means you'll actually be subtracting 4063 from the death counter. Now you should have 32 leftover, and you draw the 6. Subtract out the 32, and mark it saying you have now drawn the 6. Next, add back in the remaining 4063.

You can keep doing this, and if you get a card that has already been drawn, just start over again. This means that by the end of the deck, you'll be waiting around for the card to be drawn, but it's done entirely through triggers, and as there is no way to randomize a list in starcraft, I think this might be the best way to do it without actually using units in the map.

If you want to do it easier, and actually have the equivalent of a deck of cards, you can use a set of units, and randomize them in any way you choose in the above method or the way other people were saying (junkyard dog comes to mind, also a flying unit moving over a group of units).



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Apr 28 2008, 12:27 am Sarge Post #17



Quote from LoveLess
Quote from Sarge
You could do something like this:

Have 52 squares, each with the different unit on it (if your using units to represent each card). Always moving all the units to the right one square, and keep this up the entire game. Then use something independent (like a player bringing a unit sumwhere) to deal the cards from the locatations you want.

Quote from Zwo
But I don't trust everyone with their maphacks so this wouldn't be the best way I think.
Quote from Zwo
Any ideas on shuffling the deck using just triggers?

With 52 units changing places 13 times a second, you think even if you had mh you could tell what card was removed?
You dont even have to take the unit out, set a switch or a dc depending on what unit is there when u pick the card.



None.

Apr 28 2008, 12:29 am rockz Post #18

ᴄʜᴇᴇsᴇ ɪᴛ!

You can also put command centers on top of this to cover it up from hackers, like devilesk did in his map.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Apr 28 2008, 12:30 am Demented Shaman Post #19



Quote from rockz
You can also put command centers on top of this to cover it up from hackers, like devilesk did in his map.
I also put crashing sprites in, or at least tried to. Also, if you cover it with units use P1, because I think it then has priority over the other units owned by all players other than yourself when shown on the minimap.



None.

Apr 28 2008, 12:37 am Money Post #20



Quote from Brontobyte
Quote from name:Epoch
Quote from Zwo
But I don't trust everyone with their maphacks so this wouldn't be the best way I think.

Ez-Fix Zwo. Look at the Texas Hold'em map. 2 things happen if you MH. 1. You drop >:D 2. The units are covered up by floating C.C's, so even if you don't crash, you can see them.

That isn't pullet proof. All you have to do is click and drag to select units. Eventually you will have one of them selected. Its not easy and it will be hard to remember them/you would probably get tired of trying to do this. I also edited out the crashing sprites. Its a good idea, but you could still see the units. What if you had the Command Centers owned by the players. If they selected it and tried to find what was under it, it would just show them their Command Center, not what was underneath, I think. Or, you could do the Command Centers for the computer player, and have Protoss Arbiters surrounding the entire area so no matter what, you couldn't see it, and you couldn't click+drag select them. :D

How secure do you really need it? It depends on whether or not the game is player vs player. If a hacker could ruin the gaming experience for another player, more effort should be put into anti-hacks. If a hacker could just cheat and continuously win, is it worth it to stop that?



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[05:23 am]
zsnakezz -- yes
[2024-5-12. : 8:51 pm]
l)ark_ssj9kevin -- Are you excited for Homeworld 3?
[2024-5-12. : 8:44 pm]
l)ark_ssj9kevin -- Hi Brusilov
[2024-5-12. : 4:35 pm]
O)FaRTy1billion[MM] -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
my server that was hosting it died
[2024-5-10. : 8:46 pm]
NudeRaider -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
https://armoha.github.io/eud-book/
[2024-5-10. : 8:36 am]
Brusilov -- Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
[2024-5-09. : 11:31 pm]
Vrael -- :wob:
[2024-5-09. : 8:42 pm]
Ultraviolet -- :wob:
[2024-5-08. : 10:09 pm]
Ultraviolet -- let's fucking go on a madmen rage bruh
[2024-5-08. : 10:01 pm]
Vrael -- Alright fucks its time for cake and violence
Please log in to shout.


Members Online: Tableguy, DiearAnother