Staredit Network

Staredit Network -> Concepts -> Card Randomization
Report, edit, etc...Posted by IA-Sky on 2006-10-12 at 12:42:34
let say I have a 52 card standard deck

let say 10 of diamonds get drawn now i want triggers to randomize out of 51 possible outcomes excluding the 10 of diamonds, then let say i draw another card now out of 50 possible outcomes... then i draw another card now out of 49 possible outcomes.

Is there an easy way to do this it might be quite a challenge.


More advanced how would we randomize it for example: draw X cards from 52.

In math factorials would be used, 52!/47! = 48x49x50x51x52 chances of drawing 5 cards from a 52 card deck ouch!

NOTE: IM NOT RANDOMIZING 52, ITS MORE OF A SYSTEM TO KEEP TRACK OF WHAT HAS BEEN DRAWNED EXAMPLE IF I DRAWED 1 CARD NOW ITS IS RANDOMIZE OUT OF 51.
Report, edit, etc...Posted by Kamikaze.Kow on 2006-10-12 at 14:14:42
There is a relatively simple way for randomizing a set number that I can think of,

Conditions -
Switch 1 is Set.

Actions -
Modify death count for Player 1: Add 1 to unit "counter".
Preserve Trigger.

Then you would also need a trigger to make sure your counter never goes over 52 cards/however many cards you have at the moment. To determine how many cards you may still choose from you can use another death counter, in descending order from 52 to 0.

Conditions -
Player 1 has suffered exactly 52 deaths of "cardsleft".
Player 1 has suffered exactly 52 deaths of "counter".

Action -
Modify death count for Player 1: Set deaths of unit "counter" to 0.
Preserve Trigger.

The cardsleft unit represents how many cards you can still choose from. When you're drawing cards from the deck, Set switch 1 to off and get the value of counter to correspond with a card in the deck.

I'm not sure how to correspond the cards with the numbers, so good luck on that 1! smile.gif
Report, edit, etc...Posted by IA-Sky on 2006-10-12 at 15:51:35
QUOTE(Kamikaze.Kow @ Oct 12 2006, 11:14 AM)
There is a relatively simple way for randomizing a set number that I can think of,

Conditions -
Switch 1 is Set.

Actions -
Modify death count for Player 1: Add 1 to unit "counter".
Preserve Trigger.

Then you would also need a trigger to make sure your counter never goes over 52 cards/however many cards you have at the moment. To determine how many cards you may still choose from you can use another death counter, in descending order from 52 to 0.

Conditions -
Player 1 has suffered exactly 52 deaths of "cardsleft".
Player 1 has suffered exactly 52 deaths of "counter".

Action -
Modify death count for Player 1: Set deaths of unit "counter" to 0.
Preserve Trigger.

The cardsleft unit represents how many cards you can still choose from. When you're drawing cards from the deck, Set switch 1 to off and get the value of counter to correspond with a card in the deck.

I'm not sure how to correspond the cards with the numbers, so good luck on that 1! smile.gif
[right][snapback]575614[/snapback][/right]


no that can't work it is not random... you would just be getting cards in a numbered order.
Report, edit, etc...Posted by Urmom(U) on 2006-10-12 at 16:00:51
You could have something like he said except instead of just adding 1 constantly, you could randomize switches that subtract/add a random amount of the counter.
Report, edit, etc...Posted by IA-Sky on 2006-10-12 at 16:06:59
ok i got a system so far but its rather vague

let say i have a 4 card deck that I want to randomize


cons:
Drawing a Card = true
acts:
randomize a
randomize b
preserve

outcome #1
cons:
a is set
b is set
deaths of card #1 = 0
acts:
set deaths of card #1 = 1
preserve.

outcome #1b
cons:
a is set
b is set
deaths of card #1 = 1
acts:
randomize a
randomize b
preserve.

do this for the other 3 outcomes....

will work but a lot of rerandomization occurs as you get less and less cards left in deck. would suck a lot if you get a really low on cards left and the rerandomization is so high up.

errr its really vague i hope you understand it

ADDITION:
QUOTE(Urmom(U) @ Oct 12 2006, 01:00 PM)
You could have something like he said except instead of just adding 1 constantly, you could randomize switches that subtract/add a random amount of the counter.
[right][snapback]575653[/snapback][/right]


a different death counter for every indivual card would be needed to check if its has been drawed or if its still in the deck i think unless you have some other way of doing it...
Report, edit, etc...Posted by Heimdal on 2006-10-12 at 16:24:50
The easiest way to make sure you don't get the same card twice is to have a unit that represents each card. Keep all the units in a certain area (the deck) and remove them when they are drawn. Then all you need is a trigger to randomly pick one. A simple way to do this could be an air unit flying over the deck, set to junkyard dog. Constantly center a location on it, and when you want to draw a card, just move one unit from that location to somewhere else.

Depending on the requirements of your map, I'd recommend using one unit type for each numeric value of a card (ace-king) and then use 4 players to represent the different suits (two of which would be red and two black). Players wouldn't be able to tell the difference between hearts and diamonds or spades and clubs though, so you'd have to be careful about that. One solution to that problem would be to make the hearts and spades allied to the players and the other ones enemies, so that you can actually tell them apart by clicking on them. Not a great solution, but it works.
Report, edit, etc...Posted by IA-Sky on 2006-10-12 at 16:35:24
yeah i guess that would work
Report, edit, etc...Posted by Kamikaze.Kow on 2006-10-12 at 17:21:34
Heimdal's way really is the simplest way to do this. Urmom's way was the "More Complicated" way that I didn't feel like trying to explain. The problem with switches is that if you randomize 5 switches you get 32 different outcomes, if you randomize 6 you get 64 different outcomes, you can't get extremely specific without making things overly complicated.

If I were you I would use Heimdal's way and make sure you kick people if they can see the entire map. (So they can't cheat and see the cards left in the deck.)
Report, edit, etc...Posted by PCFredZ on 2006-10-12 at 21:14:57
Junkyard dog isn't as good because the randomization depends on the locations where the units first start at. You should instead:

1) Randomize the placement of the units that are representing the cards

or

2) Use the units merely as "placeholders" to know which cards have been "drawn" already, then use switches for randomizing a selection

Both processes involve a bit of work. In my opinion, process 2 takes more work, because you need to constantly decrease the range of randomization as the stack of cards decreases in size
Report, edit, etc...Posted by DevliN on 2006-10-12 at 22:39:40
QUOTE(PCFredZ @ Oct 12 2006, 06:14 PM)
Junkyard dog isn't as good because the randomization depends on the locations where the units first start at. You should instead:

1) Randomize the placement of the units that are representing the cards

or

2) Use the units merely as "placeholders" to know which cards have been "drawn" already, then use switches for randomizing a selection

Both processes involve a bit of work. In my opinion, process 2 takes more work, because you need to constantly decrease the range of randomization as the stack of cards decreases in size
[right][snapback]575917[/snapback][/right]

Adding to number 2, the best way would be to use triggers to sleect cards, and then when a certain card is drawn, put its unit in a certain area. Lets say you have 4 cards and 2 randomized switches...
00 = Card 1
01 = Card 2
10 = Card 3
11 = Card 4

When the condition is 00 (both cleared, in other words) and "Player brings exactly 0 'Card 1' to 'the Deck Location,'" deal the player Card and create a unit called Card 1 at the Deck area. Make a second trigger with the conditions of 00 again and "Player brings exactly 1 'Card 1' to 'the Deck Location,'" and the action rerandomizing the switches. Then when another card is drawn, it wont deal Card 1 again. When the deck is reshuffled, remove the units at the "Deck Location."

If you do it with 52 units, it may seem like a hassle, but I don't see any issues with this technique.

EDIT:
And if you don't want to randomize switches, you could do it with death counters. Have a trigger that adds 1 to the death of "Random Card," and preserve. Then have another trigger that resets it when it hits 52. In the conditions of the above triggers, put "1 death of 'Random Card'" as opposed to "00."

I don't have time to elaborate now, but you should get the idea.
Report, edit, etc...Posted by Kamikaze.Kow on 2006-10-12 at 22:48:00
The problem with your method DevliN is that if you're down to 3 of 52 cards, you may end up having to re-randomize to find 1 of the 3 cards left in the deck.
Another issue is that the closest you can get to 52 cards is to have 6 switches, in which case you will have 64 outcomes, what if one of the 12 outcomes continually happens?
Report, edit, etc...Posted by Oo.Kevjak.oO on 2006-10-13 at 01:58:21
Heimdals way is the simplest and best, but has many negatives:
-13-52 units used.
-Units of larger sizes are more likely to be drawn.

I made a map with 52 cards once where I had a long strip of terrain running along the top. There was a location "A" at one end and a location "B" at the other end, triggers ordered all units to move from "A" to "B" and then teleported them back when they reached that point. A third location "C" (in the middle) Was where the card was drawn from. (Simply a move trigger here) this system also suffers from the unit sizes flaw however.
Report, edit, etc...Posted by Zeratul_101 on 2006-10-13 at 02:05:36
i have EXACTLY what you need. mind you, you're doing the processes in reverse order, but it should work like a charm. i've just developed it for my XCMD map(still in construction). its getting late for me, so i'll share it with you tomorrow.
Report, edit, etc...Posted by Ahli on 2006-10-13 at 04:39:44
why don't u make the 52 cards with signals and powerups/units?
then make a location for everyone and spin them around.
if u now take a card with random, it's a little bit random, (u should use many switches, cause u have many cards)

i already made this on a map and it worked.

but it's only an easy solution, there are better solutions, but more complex i bet happy.gif

+easy
-need much locations, (have an idea where u only need 1 xD, flying unit over every card detects the card slots, but that slows down the card mixing, too)
+no double cards
-need many switches to randomize the cards really
Report, edit, etc...Posted by Zeratul_101 on 2006-10-13 at 12:01:25
before i go off explaining the system. i need to know if you have 52 switches or death counts to spare. plus a few more switch for randomization.
Report, edit, etc...Posted by Element-Nature on 2006-10-13 at 12:14:12
Even if he doesnt, i would like to hear it zeratual
Report, edit, etc...Posted by Heimdal on 2006-10-13 at 12:53:13
I really don't think any elegant solution to this would involve switches, because the number of choices you need to randomize between is always changing.

A cycling death counter is another good idea though.
Report, edit, etc...Posted by Element-Nature on 2006-10-13 at 13:17:04
Cycling death counter sounds pretty sexy... although, zeratual101 really knows what hes talking about when it comes to triggers... He's coming up to lethal illusion pretty soon if he keeps it up. Maybe even better! I only say that because iv seen the thread for his new map and the systems look incredibly awesome.
Report, edit, etc...Posted by Doodle77(MM) on 2006-10-13 at 16:37:48
QUOTE(DevliN @ Oct 12 2006, 10:39 PM)
Adding to number 2, the best way would be to use triggers to sleect cards, and then when a certain card is drawn, put its unit in a certain area. Lets say you have 4 cards and 2 randomized switches...
00 = Card 1
01 = Card 2
10 = Card 3
11 = Card 4

When the condition is 00 (both cleared, in other words) and "Player brings exactly 0 'Card 1' to 'the Deck Location,'" deal the player Card and create a unit called Card 1 at the Deck area. Make a second trigger with the conditions of 00 again and "Player brings exactly 1 'Card 1' to 'the Deck Location,'" and the action rerandomizing the switches. Then when another card is drawn, it wont deal Card 1 again. When the deck is reshuffled, remove the units at the "Deck Location."

If you do it with 52 units, it may seem like a hassle, but I don't see any issues with this technique.

EDIT:
And if you don't want to randomize switches, you could do it with death counters. Have a trigger that adds 1 to the death of "Random Card," and preserve. Then have another trigger that resets it when it hits 52. In the conditions of the above triggers, put "1 death of 'Random Card'" as opposed to "00."

I don't have time to elaborate now, but you should get the idea.
[right][snapback]575991[/snapback][/right]

to elaborate on this,

if SwitchX is set, randomize, preserveTrigger
"Player brings exactly 0 'Card 1' to 'the Deck Location,'" deal the player Card and create a unit called Card 1 at the Deck area, clear SwitchX.
and it loops, since no condition was furfilled, and so SwitchX was still set.
Report, edit, etc...Posted by Element-Nature on 2006-10-13 at 16:48:57
Seems pretty good happy.gif
It also gave me an idea id like to try happy.gif
Report, edit, etc...Posted by Zeratul_101 on 2006-10-18 at 14:58:15
QUOTE(Heimdal @ Oct 13 2006, 10:52 AM)
I really don't think any elegant solution to this would involve switches, because the number of choices you need to randomize between is always changing.

A cycling death counter is another good idea though.
[right][snapback]576151[/snapback][/right]


the 52 switches won't be for randomizing. i'm at school, i'll type all the info up when i get home.

ADDITION:
i don't quite feel like getting into the original programming inspiration for this, so i'll just tell you the basics.

the 52 switches each represent a card. 'cleared' means the card is still in the deck. 'set' means the card has been dealt. a counter set to 52 is required. the counter represents how many cards are in the deck. as a switch is set, the counter is subtracted by 1. there will also be a 'draw card' counter. it counts how many cards to not hand out before. its purpose will be more evident later on. there are some limitations to keep in mind, the counter must be less than the 'total cards' counter.

i'll post an example using only five cards:

p1 - deaths - zergling = how many cards to put out this trigger run(will always be one) ~~~ (may also be replaced with a switch)
p1 - deaths - marine = how many cards left in deck
p1 - deaths - ghost = draw card


*randomize draw card
__________________
Conditions:
switch 1 is cleared
p1 has suffered at least 1 deaths of zergling
p1 has suffered at most 0 deaths of ghost

Actions:
preserve
set switch
*output
subtract 1 death from zergling
subtract 1 death from marine
_____________________
Conditions:
switch 1 is cleared
p1 has suffered at least 1 deaths of ghost

Actions:
preserve
subtract 1 death from ghost
___________________________
*repeat for all five cards, simply changing the switch and adjusting output as necessary.


note: all this does is prevent you from drawing out the same card. randomizing the 'draw card' counter and dispalying output will be up to you.


think about this for a few minutes or even make a test map if you really need to. if you don't get it, i'll exlpain it in more detail.
Report, edit, etc...Posted by Heimdal on 2006-10-18 at 16:04:30
1) You don't get an even distribution of cards
2) What happens if all the cards before the "draw card" have been dealt? I guess you would go through another trigger run but then you have the possibility (however remote) that you will never draw that last card.
Report, edit, etc...Posted by Zeratul_101 on 2006-10-18 at 16:40:48
1) i'm not quite sure what you mean by that

2) the draw card counter is only subtracted whne it skips over a card that is still in the deck. when it skips over a card not in the deck, nothing happens. this is why you need a switch, to show whether the card is still in the deck or not. the counter is used relatively, it doesn't draw the 7th card out of the deck, it draws the 7th card out of the cards still remaining in the deck.
Report, edit, etc...Posted by Thermo on 2006-10-18 at 17:47:49
A somewhat simple combination of the counter way and Heimdal's way could be simple done with 1 player and 2 locations not used by anyone. Have location A which is the cards(units) that still can be played. All the units in that location are sent to junkyard ai so they should aimless wander around this area. Now have 8 random switches that determine how many units are moved to location B before choosing 1 unit from location A. If you run out of units at A move all the units at B back and continue moving units.
Once a selection has been made move all the units at B and A back to A and set them on their way again.

This might get long if you only have two units remaining and you roll a 63, so put a limiter on it by checking if there is only 32, 16, 8, 4, 2, 1 units left to reduce the amount of uneccicary moves between A and B made.
Report, edit, etc...Posted by spinesheath on 2006-10-20 at 21:45:34
If possible, stick to a representation of cards by units for this. This usually is no problem in card game maps.

Using the junk yard doch script already gives you nice results, especially if you junkyard both the "cards" and the air unit that "carries" the location. Of course you could also use non-moving units as cards, then you can't junkyard them.

(btw, the units are only a representation for your "engine", the process is like this: Select a random unit from the remaining deck, place it somewhere, check it's type and do something with that, move the unit into the "drawn cards cage")

If you are not satisfied with junkyard dogging (it might just as well take some time to get the next card if there are only few left), you will have to work out another way of randomizing. There are thousands of possibilities for that, ranging from simple and ugly switch randomization over looping counters and location based movement scripts to beautiful looping real-unit-counters with variable maxima.

So I expect that there is some user-time in your map; the players decide when to draw the first card and so on. I will explain a looping real-unit-counter for this settings:

Location "LDeck" holds 52 different units owned by comp 1

Location "LDrawn" will hold the drawn cards

Location "LCurrent" is where the current map will be put before it is moved to LDrawn

Location "LCounter" holds 52 burrowed lings owned by comp 1

Location "LStorage" is a helper for LCounter


Condition:
comp 1 brings 0 Zerglings to LCounter

Action:
Give All Zerglings by comp 2 at LCounter to comp 1

......................................................
Condition:
Always

Action:
Give 1 Zergling at LCounter by comp 1 t o comp 2

......................................................
Condition:
"want to draw a card"

Action:
"move the x-th unit at LDeck to LCurrent"
- where x is the number of zerglings owned by comp 1 at LCounter -
move 1 Zergling from LCounter to LStorage

(figure out an efficient set of triggers for this yourself...)

......................................................
Condition:
comp 1 brings "Card" to LCurrent

Action:
move "Card" to LDrawn
do something

(each Card has to be done with one trigger...)

.......................................................


This should be enough to give you a good idea of how to realize this concept. With the use of hypers it is randomized fast enough. (if you need to draw several cards "at once" (= one right after the other) you'll have to add some switch-randomizeations, though)
Next Page (1)