MArcomage

Free multiplayer on-line fantasy card game

Please log in

Chocodile on 15:19, 9. Apr, 2010
I've noticed an unusually high number of repeating cards: the card played is replaced by the same card. Has anyone else noticed this. It happens more often than random chance, and has been going on for quite a while. At first I thought it was just confirmation bias, but it happens too often for that.
FilipeSilva on 15:22, 9. Apr, 2010
Sometimes I get that ...one game (in the last days) I got the same card played 3 times in a row
Lord Ornlu on 16:05, 9. Apr, 2010
i have the same thing. I received Prince of Thieves 2 times in a row more than just once. And then there was once I had Phoenix 3 times in my hand (not the Rebirth effect, I mean I had it x3 simultaneously). also i counted a couple times where i received the same rare in 3-4 games at the same minute (i played a card and received Great Wall Of China, then moved to the next game and received it there as well and on and on) this happened a second time with Orc Regiment and Frost Unicorn as well, although they are Uncommons
Mojko on 16:29, 9. Apr, 2010
We use this random generator http://php.net/manual/en/function.mt-rand.php

Events you described are improbable, but not impossible.
dindon on 16:38, 9. Apr, 2010
Chocodile wrote:
I've noticed an unusually high number of repeating cards: the card played is replaced by the same card. Has anyone else noticed this. It happens more often than random chance, and has been going on for quite a while. At first I thought it was just confirmation bias, but it happens too often for that.


I'll believe it when I see the data you've collected :P

I really do think it's probably just confirmation bias. We notice when we get the same card twice. When we don't, we don't pay any attention.
DPsycho on 02:38, 11. Apr, 2010
Unless I'm mistaken, the random card draw is influenced (with a reduced chance) when another instance of the card is already on hand, correct? I believe you've said this before. I may be recalling this incorrectly, but I believe it was said that it chooses a card from the deck at random, and then if that card is already on hand, there is a chance that the system will redo its random card draw, that chance being increased by the number of times the card is in hand. Is this true?
Mojko on 07:14, 11. Apr, 2010
Yes, the drawing system takes into account your current hand (even non-standard draws like summoning cards). It works like this:

1 - Random card is chosen (according to card rarity rules).

2 - Number of instances of this card (= N) are counted in your hand (ignoring the currently played card).

3 - with probability 1/(2^{N}) the random card is kept and the drawing is finished. If the card isn't kept, then the whole process is repeated again (Go to 1).

Examples:

Suppose you don't have a card instance of the random card. Then N = 0, and therefore 1/(2^{N}) = 1. This means such card is always kept and drawing process takes only one round.

Suppose you have one card instance of the random card. Then N = 1, and therefore 1/(2^{N}) = 1/2. This means that there is a 50% chance that this card will be kept, so there is 50% chance that this card will be discarded and redrawn.

Suppose you have two card instances of the random card. Then N = 2, and therefore 1/(2^{N}) = 1/4. This means that there is a 25% chance that this card will be kept, so there is 75% chance that this card will be discarded and redrawn.

Suppose you have three card instances of the random card. Then N = 3, and therefore 1/(2^{N}) = 1/8. This means that there is a 12.5% chance that this card will be kept, so there is 87.5% chance that this card will be discarded and redrawn.

Suppose you have four card instances of the random card. Then N = 4, and therefore 1/(2^{N}) = 1/16. This means that there is a 6.25% chance that this card will be kept, so there is 93.75% chance that this card will be discarded and redrawn.

The probability that you will end up with multiple card instances is exponentially decreasing with number of instances. We call this the anti-flood mechanism.

I think I'll add this to FAQ, since I believe I already explained this somewhere.
Progressor on 13:03, 11. Apr, 2010
You did Moj ;-)

Im curious to how this is coded.
Mojko on 14:25, 11. Apr, 2010
Here it is:

private function DrawCard($source, array $hand, $card_pos, $draw_function)
{
while (1)
{
$nextcard = $this->$draw_function($source, $hand[$card_pos]);

// count the number of occurences of the same card on other slots
$match = 0;
for ($i = 1; $i <= 8; $i++)
if (($hand[$i] == $nextcard) and ($card_pos != $i))
$match++; //do not count the card already played

if (mt_rand(1, pow(2, $match)) == 1) return $nextcard; // chance to retain the card decreases exponentially as the number of matches increases
}

}
FilipeSilva on 20:28, 11. Apr, 2010
Mojko wrote:
(...)
2 - Number of instances of this card (= N) are counted in your hand (ignoring the currently played card).
(...)


ok, I think the problem I had was that I thought that the number of instances counted also the currently played card!

Mojko on 08:14, 17. Apr, 2010
To my surprise the drawing mechanism wasn't explained in the game manual. No wonder that multiple players asked about it >_<. It is now in the game manual.
Mojko on 08:17, 19. May, 2012
In recent update multiple cards were fixed, because they didn't use the anti-flood system properly. Now, I revised the code which is responsible for all the random decisions (card drawing, AI...). I found a small mistake. While most of the code use mt_rand() function, which is considered to be reliable, there are parts of the code that use array_rand() function. Array_rand() function uses rand() instead of mt_rand() which is slower and less reliable. I replaced the array_rand() function with array_mt_rand() function which uses mt_rand() function and thus, is reliable.

Here is a list of effected features:

- random starter deck pick for AI
- random deck selection for player
- AI decision making algorithm (when picking one from same value decisions)
- card summoning from specified list of cards

Changes will be applied in the next update.
Mojko on 07:36, 2. Jun, 2012
Looks like I missed some occurrences of array_rand() function in the card effect codes. I fixed it in r1675. Here is some interesting read you should check out:


Please note that, while each key from the source array has a equal chance of being picked, the order in which they are returned is NOT random. In an array with keys from one to 10, where 2 random keys are picked, 0 is picked as the first number 18.8% of the time, and only as second number in 1.1% of the time
Fithz Hood on 07:53, 2. Jun, 2012
so, there are cards that appear more often?
Mojko on 08:04, 2. Jun, 2012
Card summoning is not effected, because it doesn't not use array_rand(). What is effected are mostly cards that have somewhat random effect, when choosing highest facility when there are multiple choices for example. Also some cards that discard cards at random positions were effected as well.