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 28 2008, 1:01 am rockz Post #21

ᴄʜᴇᴇsᴇ ɪᴛ!

Because an anti-hack ruins the game also (usually by dropping the hacker). Instead, just nullify the hack by doing things via triggers. It will be a while until a hack will come out that sees death counts (that are important).



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

Apr 28 2008, 1:12 am Demented Shaman Post #22



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
Selecting units doesn't do you any good, which I doubt you can do. The CC's are tightly packed and they're owned by P1, the only unit's you'll be able to select are your own units. You still won't be able to tell who owns the unit even if you do select it.



None.

Apr 28 2008, 8:47 am LoveLess Post #23

Let me show you how to hump without making love.

Quote from LoveLess
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
What be wrong with this method?



None.

Apr 28 2008, 9:28 am Wormer Post #24



Quote from Brontobyte
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.
Nope, you can still select other player's units under the floating CC regardless of what player owns the CC.

Quote from rockz
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).
I see.

Quote from rockz
Now, it checks to see if that card is available by subtracting out the REST of the numbers in the death counter.
Actually you don't need to subtract the whole REST of the numbers. You have to subtract only the powers of two corresponding to higher digits than the digit you want to check, because all powers of two corresponding to lower digits overall won't give you the power of two you're cheking.

Say, you choose a king. That means you could immideately check if the counter is at least 4096 because the other powers of two wont give you 4096 even combined alltogether.

That way you dont need to specifically check if the card was drawn before. The presence or absence of the power of two supplies you with all necessary information. You just subtracting the power of two if it presents in the number. If not, you're going to the next digit and so on till you reach the power of two which presence you are going to check. You dont even need to remember specifically what powers of two were subtracted to return them, you're just remembering the whole subtracted sum (by constantly adding powers of two subtracted on each step to the temporary death counter) and adding the whole sum to the number after the work is done.

Quote from rockz
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...
You're randomizing what card exactly should be drawn and if there is no such card you have to rerandomize. In other words, your outcomes are the exact cards to be drawn. You can use another tactics of drawing cards. I suggest randomizing the ordinal number of the card from the top of the counter to be drawn. This will always guarantee that one card would be always drawn from the deck.


There is another way of representing the deck (as a set not as the list) of cards via locations. You need 52 locations each representing one card. Then you need a unit representing the deck and player's hands. For exaple I will use the command center (CC). Let's assume neutral (Player 12) CC represents the deck. All 52 locations are initially stacked on the neutral CC. When you want to draw the card you just moving the location representing that exactly card from the neutral CC to the player's CC (representing that player's hand).

You can also represent cards by stacked burrowed zerg units, distinguishing cards by the number of stacked units (one unit = K, two units = Q and so on). If that burrowed units are owned by another player there is no way to select them all at once (even if hacker is able to see them) and hence no way to understand what the card it is.

Quote from rockz
... 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.
Never say never. There is an interesting way to represent and randomize a list in starcaft. For easy understanding let's assume you have 52 different units which are representing the order of the cards (I mean posiotions from first to the fifty second, or in other words "indicies" of an "array"). Cards are represented as locations. To understand what is the position of the card in the "array" you are checking what unit is on that card's location. Initially all cards are preplaced in ascending order from the first unit to the last. To shuffle cards you're using an interesting method of radnomization. You're randomizeing a switch. If it is set you're exchanging the first location with the second. After that is done you're randomizeing the switch once again. If it is set this time you're exchangeing the second location with the third. You're continueing the process till the last card. The fifty second card would be exchanged with the first one. Alas! The deck is shuffled :) This is a universal way of making and random shuffling permutations in SC.

I am not talking about equiprobability of each outcome. It is not equiprobable, at least because the number of permutations is not the exact degree of two (as far as it is not trivial premutation consisting of two elements) and I am convinced there is no methond of equiprobable randomization which doesn't use rerandomization when the number of outcomes is not the precise power of two.



Some.

Apr 28 2008, 11:01 am Brontobyte Post #25



Quote from name:devilesk
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
Selecting units doesn't do you any good, which I doubt you can do. The CC's are tightly packed and they're owned by P1, the only unit's you'll be able to select are your own units. You still won't be able to tell who owns the unit even if you do select it.

Heres what I did, even with your crashing units. I brought my screen to the top right corner of the game and inputed the black sheep wall cheat. (Map hack) Then I clicked and dragged to find out where the units were. I didn't pay too much attention to where things were but I could tell what was what. I could only see the units that I owned, without Map hack. If you have the crashing sprites over top of the persons hand, wouldn't that crash the player that owned that hand? If you remove them, or they only show their image once and disappear, couldn't you just turn your Map hack on after a certain time. I know you of all people would of thought of ways around this, or as much as possible, so feel free to be specific.

Quote from Wormer
Quote from Brontobyte
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.
Nope, you can still select other player's units under the floating CC regardless of what player owns the CC.

What about having Arbiters their? Then no matter what map hack, clicking and dragging, with command centers, you wouldn't be able to select the units, only your own.

Post has been edited 1 time(s), last time on Apr 28 2008, 11:06 am by Brontobyte. Reason: Added Quotes



None.

Apr 28 2008, 12:25 pm rockz Post #26

ᴄʜᴇᴇsᴇ ɪᴛ!

Quote from Wormer
Never say never.
Except I said without using units. If you use 52 units, you can randomize their order using just about any method of randomization, and it will act exactly like a deck, and be easier to trigger. Without units, it's much more difficult. I suppose you might set 52 death counters, and set them from 1 to 52 at random, somehow.



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

Apr 28 2008, 12:54 pm Wormer Post #27



Quote
Except I said without using units. If you use 52 units, you can randomize their order using just about any method of randomization, and it will act exactly like a deck, and be easier to trigger. Without units, it's much more difficult. I suppose you might set 52 death counters, and set them from 1 to 52 at random, somehow.
Oh well. Good idea. You could have predefined distribution of numbers from 1 to 52 between death counters (for example in ascending order) and then randomly exchange values between them like I do with locations to get random premutation of the initial sequence.



Some.

Apr 28 2008, 2:03 pm TheKeyToKilling Post #28



Randomize Switches...

For the outcomes of unused cards have it say
Switch is set (randomized switches)
Switch is set (used or not switches)
Then draw card
Clear switch (used or not switches)

For the outcomes of used cards have it say
Switch is set (randomized switches)
Switch is cleared (used or not switches)
Then repeat randomization selection process switch

This would unfortunately be over 100 triggers, but it would work.

If you do it this way make sure you preserve the triggers.



None.

Apr 28 2008, 2:06 pm rockz Post #29

ᴄʜᴇᴇsᴇ ɪᴛ!

Quote from Wormer
Oh well. Good idea. You could have predefined distribution of numbers from 1 to 52 between death counters (for example in ascending order) and then randomly exchange values between them like I do with locations to get random premutation of the initial sequence.
Except That doesn't represent a truly random sequence of events. Wouldn't that mean it is far more likely that whatever you have set as 1, be near the top?



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

Apr 28 2008, 3:45 pm Zwo Post #30



I wanted to make a texas hold'em game. Having up to 5 units representing cards in the middle, and if you want to see your hand you walk on a beacon and a text will tell you what cards you have in your hand.
I've never seen a texas hold'em map before and the mapdatabase on this site doesn't have it, so i'm not sure if I should start it before I had the chance to play it. My mapping skills aren't too great so the map I'd make would probably be a lot worse than the one that already exists.
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.
Floating command centers look horrible, don't you think? For me it would make the map feel noobish.

Quote from rockz
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.
I'll keep that one in mind. I think it'll take me some time to trigger such a thing since I can't think of a direct way of triggering that right now.

I think some sort of countdown deathcounter in combination with some switches is random enough, but i'll think about it.



None.

Apr 28 2008, 4:55 pm Wormer Post #31



Quote
Except That doesn't represent a truly random sequence of events. Wouldn't that mean it is far more likely that whatever you have set as 1, be near the top?
Why does it not represent truly random sequence? It is truly random, but outcomes are not equiprobable. However perciseness is quite good. There is no far more likely outcomes, just some of them are a little bit more likely than the others. I cant say what exactly probabilities are. It is hard to say what numbers will have to be more likely set at a definite position. It is not easy thing to do in general case. You see, there are n! premutations... So it is hard mathematical problem to count probabilities for all of them when using this method. I wonder if one can do it?



Some.

Apr 28 2008, 7:01 pm Demented Shaman Post #32



Quote from Zwo
I wanted to make a texas hold'em game. Having up to 5 units representing cards in the middle, and if you want to see your hand you walk on a beacon and a text will tell you what cards you have in your hand.
I've never seen a texas hold'em map before and the mapdatabase on this site doesn't have it, so i'm not sure if I should start it before I had the chance to play it. My mapping skills aren't too great so the map I'd make would probably be a lot worse than the one that already exists.
I made a Texas Hold'em map.
http://www.staredit.net/topic/32/



None.

Apr 28 2008, 7:06 pm Money Post #33



Quote from rockz
Because an anti-hack ruins the game also (usually by dropping the hacker). Instead, just nullify the hack by doing things via triggers. It will be a while until a hack will come out that sees death counts (that are important).

This probably wouldn't help very much, the dc's would change randomly and rapidly.



None.

Apr 28 2008, 7:22 pm Demented Shaman Post #34



Quote from Money
Quote from rockz
Because an anti-hack ruins the game also (usually by dropping the hacker). Instead, just nullify the hack by doing things via triggers. It will be a while until a hack will come out that sees death counts (that are important).

This probably wouldn't help very much, the dc's would change randomly and rapidly.
Furthermore, aren't there those stay alive hacks where even if you end the game for them they can stay in the game indefinitely? If so they could still cause a problem and annoy people and stuff. I think waiting through the mere 45 second drop screen isn't that much of an inconvenience if a hacker is being removed from the game.



None.

Apr 28 2008, 9:26 pm rockz Post #35

ᴄʜᴇᴇsᴇ ɪᴛ!

If the hacker drops, he has succeeded. In some cases, it is imperative that you have a certain number of players. If you don't have that number, the game sucks, and the hacker wins anyway. Not to mention, he just wasted 5 minutes of your life.



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

Apr 29 2008, 9:19 pm Atlos Post #36



Quote from LoveLess
Quote from LoveLess
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
What be wrong with this method?
It wouldn't work because you could draw the same card twice.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:05 am]
Moose -- ya
[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
Please log in to shout.


Members Online: NudeRaider, Roy, TheHappy115