Post MTG Forge Related Programming Questions Here
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
13 posts
• Page 1 of 1
Post MTG Forge Related Programming Questions Here
by tafkad » 14 Jan 2013, 17:54
Hi -
First again great work, been a while since I checked in and wanted to get up to date. I have a question that has been on my mind for over a year now. I have tested Forge in sealed and draft mode quite extensively and it may be me but I find there is a huge problem in the randomization algorithm not just with card selection but more in game play. I have tested for this purpose much in that the AI completely deck stacks and there appears to be little to no randomization. When playing against decks the AI consistently draws the same cards (a slightly different order but the same cards) so much so that even when playing against the same deck multiple times (30+) I see the same pattern over 90% of the time and this just does not seem an accurate representation of gameplay. This may be written into the game to make it more of a challenge but at the same time if so it also takes away from the real world experience of random card flopping. I keep hoping I am wrong but the more I test it the more it appears to be, the first 12-14 cards of the AI stack almost always have the same key cards, some tests have shown the first 2 plays exactly the same every time for more the 20+ hands (I do not mean Lands played). I have never seen top deck skills like this in mtg in over 15+ years. Well something to consider anyways, still one of the best implementations I have seen over the years, regards.
First again great work, been a while since I checked in and wanted to get up to date. I have a question that has been on my mind for over a year now. I have tested Forge in sealed and draft mode quite extensively and it may be me but I find there is a huge problem in the randomization algorithm not just with card selection but more in game play. I have tested for this purpose much in that the AI completely deck stacks and there appears to be little to no randomization. When playing against decks the AI consistently draws the same cards (a slightly different order but the same cards) so much so that even when playing against the same deck multiple times (30+) I see the same pattern over 90% of the time and this just does not seem an accurate representation of gameplay. This may be written into the game to make it more of a challenge but at the same time if so it also takes away from the real world experience of random card flopping. I keep hoping I am wrong but the more I test it the more it appears to be, the first 12-14 cards of the AI stack almost always have the same key cards, some tests have shown the first 2 plays exactly the same every time for more the 20+ hands (I do not mean Lands played). I have never seen top deck skills like this in mtg in over 15+ years. Well something to consider anyways, still one of the best implementations I have seen over the years, regards.
Re: Post MTG Forge Related Programming Questions Here
by Max mtg » 14 Jan 2013, 20:01
Did you mean to say "card-dealing randomizer" is not random at all?
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: Post MTG Forge Related Programming Questions Here
by silly freak » 14 Jan 2013, 21:06
Hi!
As you tested the same deck several times, I assume that you play constructed or Quest. There are several decks that are trimmed so that the AI can use it well, and several cards the AI can't use well. What this means is that there are likely many 4-offs in these decks, and that you won't see some of the cards even if the AI draws them.
For these reasons, I think that your observations are mostly biased by your test cases. If you're not convinced, I suggest building or finding a deck with only 1-offs and see whether the AI continues to play the same way game after game; I personally doubt it.
Still, maybe someone in the know can confirm that deck order for AI is completely random
As you tested the same deck several times, I assume that you play constructed or Quest. There are several decks that are trimmed so that the AI can use it well, and several cards the AI can't use well. What this means is that there are likely many 4-offs in these decks, and that you won't see some of the cards even if the AI draws them.
For these reasons, I think that your observations are mostly biased by your test cases. If you're not convinced, I suggest building or finding a deck with only 1-offs and see whether the AI continues to play the same way game after game; I personally doubt it.
Still, maybe someone in the know can confirm that deck order for AI is completely random

___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: Post MTG Forge Related Programming Questions Here
by timmermac » 14 Jan 2013, 22:14
I play almost exclusively quest mode, and I can say that for the most part the computer opponents don't play the deck the same way every single game. I'm fairly sure the draws aren't identical. There'll be times when the computer will get extraordinarily lucky, and there will be times when the computer gets completely mana-hosed.
"I just woke up, haven't had coffee, let alone a pee in 7 days, and I find out you stole my ass and made a ...mini-me! Carter, I should be irked currently, yes?" - Jack O'Neill
Re: Post MTG Forge Related Programming Questions Here
by tafkad » 15 Jan 2013, 04:59
Hi-
Thanks for the responses. First off I play only Draft and Sealed - so these decks have a lot of one-of cards (thought the AI tends to have more multiples of rare and uncommon cards then I ever get in sealed). I am including some more info on this issue in the form of a couple pictures. in them I am playing a R/G Rise of the Eldrazi Sealed deck.
In the first picture look at the log and the field to understand what is going on. Six turns in a row I used Splinter Twin to summon an Ondu Giant and grabbed a land and 6 turns in a row the next card I draw is a land. I have noticed that over 90% of the time I use any type of land fetch to thin out land the next card I draw is land (consider Drawing Evolving Wilds and playing, sacking and fetching to remove 2 land in a turn). in this case there was 6 land left of 26 cards so sure maybe a land next (remember though it happened 6 times in a row). On the next turn I fetched a land and the next card I draw is Growth Spasm (land fetch) which I used then summon a Giant and what do you know after thinning 4 land in a row next draw...wait for it... Land
In the 2nd photo look at the log on the right then at what phase I am in, you will see in the log I just summoned and exiled a Giant to fetch 1 of the last 2 lands in the deck, then as you can see I am in my draw phase and what did I draw from my 20 cards.... Land - the last one
If you compare the two pictures you can count the number of land I have and see the difference (17 in the first - 21 in the 2nd) Then look at the Graveyards and compare (4 then 7) the 3 cards in the grave are Evolving Wilds, Growth Spasm, Snake Umbra (the umbra was in play). I think I was at around 5 or 6 land when I cast Splinter Twin so I could get Ulamog out asap, the plan worked and I played out my hand but then it just kept giving land.
I am seeing this type of deck stacking consistently. The AI stacking I spoke of is where the AI has a 1 or 2 of a card and it comes up as first played 10 times in a row followed by almost identical game play for the first 10 turns. If this was not noticeable I would not have said anything but it is very noticeable to me.
In fact I just checked the log - On my Turn (13) I cast Splinter Twin and after that all the way to my turn (29) I only drew Growth spasm and all land and each draw was after thinning a land out of the deck at the end of the AI turn. That means 8 turns in a row remove a land draw a land except the one turn I draw growth spasm which I played to fetch a land, then Giant to fetch another then draw land.
I have noticed this type of thing for the last couple years and hope that someday it becomes more random. Happy flopping to all and best regards to the developers.
Thanks for the responses. First off I play only Draft and Sealed - so these decks have a lot of one-of cards (thought the AI tends to have more multiples of rare and uncommon cards then I ever get in sealed). I am including some more info on this issue in the form of a couple pictures. in them I am playing a R/G Rise of the Eldrazi Sealed deck.
In the first picture look at the log and the field to understand what is going on. Six turns in a row I used Splinter Twin to summon an Ondu Giant and grabbed a land and 6 turns in a row the next card I draw is a land. I have noticed that over 90% of the time I use any type of land fetch to thin out land the next card I draw is land (consider Drawing Evolving Wilds and playing, sacking and fetching to remove 2 land in a turn). in this case there was 6 land left of 26 cards so sure maybe a land next (remember though it happened 6 times in a row). On the next turn I fetched a land and the next card I draw is Growth Spasm (land fetch) which I used then summon a Giant and what do you know after thinning 4 land in a row next draw...wait for it... Land
In the 2nd photo look at the log on the right then at what phase I am in, you will see in the log I just summoned and exiled a Giant to fetch 1 of the last 2 lands in the deck, then as you can see I am in my draw phase and what did I draw from my 20 cards.... Land - the last one
If you compare the two pictures you can count the number of land I have and see the difference (17 in the first - 21 in the 2nd) Then look at the Graveyards and compare (4 then 7) the 3 cards in the grave are Evolving Wilds, Growth Spasm, Snake Umbra (the umbra was in play). I think I was at around 5 or 6 land when I cast Splinter Twin so I could get Ulamog out asap, the plan worked and I played out my hand but then it just kept giving land.
I am seeing this type of deck stacking consistently. The AI stacking I spoke of is where the AI has a 1 or 2 of a card and it comes up as first played 10 times in a row followed by almost identical game play for the first 10 turns. If this was not noticeable I would not have said anything but it is very noticeable to me.
In fact I just checked the log - On my Turn (13) I cast Splinter Twin and after that all the way to my turn (29) I only drew Growth spasm and all land and each draw was after thinning a land out of the deck at the end of the AI turn. That means 8 turns in a row remove a land draw a land except the one turn I draw growth spasm which I played to fetch a land, then Giant to fetch another then draw land.
I have noticed this type of thing for the last couple years and hope that someday it becomes more random. Happy flopping to all and best regards to the developers.
Re: Post MTG Forge Related Programming Questions Here
by tafkad » 15 Jan 2013, 05:51
Also to be clear -
I am not saying the draw and play is exactly the same in each game just amazingly similar - and I am not using quest mode which is why I have noticed this
Build any sealed deck or draft deck, and play a game (say the first of 7 opponents and the 2 or 3 games to complete the round) and then replay it as many times as you can stand and after about 20 or so times you should notice what I am seeing (that or my computer hates me)
As an example - I just started a game with the same sealed deck from above and looked at the AI starting hand and it contained 2 of his 3 Artisan of Kozilek - then I restarted the round 10 times in a row and looked and 10 times in a row 1 or 2 of that card is in hand or in the top 5 cards with the 1 or 2 in hand over 50% of the them - another card in hand Wildheart Invoker (2 in the deck) when the Artisan is not - It is not exactness but similar patterns that repeat
This is not an absolute but rather a % leaning toward stacking and less random that it should be
If there is only 1 or 2 copies of a card in a 40 card deck I don't expect to see it played first turn even 2 or 3 games in a row but I do see this a lot
As for the land issues I just showed above that for sure is against the odds by far and a sign of stacking
It does make it much more challenging though as the AI needs all the help it can get because when it's back is against the wall it makes incorrect decisions at times that lead to it's demise or I find I can also bluff it into not taking the kill shot
On a side note I think Eldrazi draft and sealed is one of the really tough and fun sets for drafts and sealed (I have drafted/sealed everything and then some)
I am not saying the draw and play is exactly the same in each game just amazingly similar - and I am not using quest mode which is why I have noticed this
Build any sealed deck or draft deck, and play a game (say the first of 7 opponents and the 2 or 3 games to complete the round) and then replay it as many times as you can stand and after about 20 or so times you should notice what I am seeing (that or my computer hates me)
As an example - I just started a game with the same sealed deck from above and looked at the AI starting hand and it contained 2 of his 3 Artisan of Kozilek - then I restarted the round 10 times in a row and looked and 10 times in a row 1 or 2 of that card is in hand or in the top 5 cards with the 1 or 2 in hand over 50% of the them - another card in hand Wildheart Invoker (2 in the deck) when the Artisan is not - It is not exactness but similar patterns that repeat
This is not an absolute but rather a % leaning toward stacking and less random that it should be
If there is only 1 or 2 copies of a card in a 40 card deck I don't expect to see it played first turn even 2 or 3 games in a row but I do see this a lot
As for the land issues I just showed above that for sure is against the odds by far and a sign of stacking
It does make it much more challenging though as the AI needs all the help it can get because when it's back is against the wall it makes incorrect decisions at times that lead to it's demise or I find I can also bluff it into not taking the kill shot
On a side note I think Eldrazi draft and sealed is one of the really tough and fun sets for drafts and sealed (I have drafted/sealed everything and then some)
Re: Post MTG Forge Related Programming Questions Here
by Hellfish » 15 Jan 2013, 06:17
There is an option for land stacking you might want to disable if it isn't already. This could also affect the order of other cards.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
-
Hellfish - Programmer
- Posts: 1297
- Joined: 07 Jun 2009, 10:41
- Location: South of the Pumphouse
- Has thanked: 110 times
- Been thanked: 169 times
Re: Post MTG Forge Related Programming Questions Here
by tafkad » 15 Jan 2013, 06:45
Option is not enabled - I was also under the impression this option does not work in the way I showed above where I was able to go from about 6 lands to 21 lands and draw only one other non land card (all with constant fetch and shuffle) - as it says "Minimizes mana lock in AI hands, giving a slight advantage to the computer" and I have never felt that the AI needed this advantage as it rarely gets mana hosed (I'd say like less then 5% of the time)Hellfish wrote:There is an option for land stacking you might want to disable if it isn't already. This could also affect the order of other cards.
Re: Post MTG Forge Related Programming Questions Here
by tafkad » 16 Jan 2013, 00:21
I have put together a series of observations for you to consider using a Full Card Pool Draft and Sealed Draft (I only play draft and sealed and you can play as many times with these decks as one chooses) In the following examples I will try to illustrate these recurring patterns that seem to beat the odds on a regular basis - these examples contain hardly any duplicate cards in the decks (though suprisingly in the full card pool draft one AI deck had 2 of the same common Syphon Soul)silly freak wrote:Hi!
As you tested the same deck several times, I assume that you play constructed or Quest. There are several decks that are trimmed so that the AI can use it well, and several cards the AI can't use well. What this means is that there are likely many 4-offs in these decks, and that you won't see some of the cards even if the AI draws them.
For these reasons, I think that your observations are mostly biased by your test cases. If you're not convinced, I suggest building or finding a deck with only 1-offs and see whether the AI continues to play the same way game after game; I personally doubt it.
Still, maybe someone in the know can confirm that deck order for AI is completely random
Example one - Rise Draft - pattern with single Bear Umbra (among others)
in this series AI gets the 1 Bear Umbra out 5 times within the first 5 turns. The one Wildheart Invoker in play 3 games early. Pelakka Wurm is in the AI hand and will come out soon due to a growth spasm in hand and was played in 2 games previous (one Wurm in deck 3 out of 5 games in play early). Meanwhile 5 games in a row I can't get any land out with two games seeing an early Crusher (annihilate 2) that makes me Sack land the only 2 games I even got past 5 land (had to choose land in order to build up enough chump blockers to stack block)
In this series the feel was not one of random events but of control and stacking
I will create a separate post for the next example to help keep them clear
Re: Post MTG Forge Related Programming Questions Here
by tafkad » 16 Jan 2013, 01:22
This next series is a great set of shots that definitely shows patters of repeat. They are all with one deck for me (a R/G full card pool draft) and after I got done I was surprised how many similar hands are shown for me, as well as the stuff I will discuss with the AI.
AI Solar Tide -
Solar Tide cast in 3 games in a row on turn 6 there was 1 in the AI deck - something I want to also point out, when the AI played solar tide it did not show anywhere which option was chosen and I did not know which power creatures were going to die. This had an impact on game play choices for me as I had a Spike Drone in play to sack but did not know if it was going to live or die so could not make the correct choice (if power 2 or less are chosen then I sack the drone to move the counter to a power 3 or greater card, or not sack it if power 3 or greater are chosen to die)
AI Gaze of Justice -
I played against this deck 7 times in a row, One Gaze of Justice in AI deck in hand 5 of 7 starts - also 4 games in a row saw Kinsbaile Skirmisher 2nd turn
Xantid Swarm -
I kept getting this card either in my opening hand or within 1-3 draws in all of about 10 games
If you compare the cards I have in my hand and in play throughout this series of pictures you may notice the patterns of similarity with cards I have early in the game
There was a lot of cards in my deck I saw once or twice and a few key cards I saw in nearly every game very early, which is important for in the course of a long game yes you are bound to see cards repeatedly but my observations are of the early game in almost all examples
The patterns remind me of rolling 2 six sided dice multiple times and looking at the average because again we are not talking exact repetition of hands but very similar patterns of gameplay early that over the course of many games starts to defy the odds quite a bit
Other than that this is still one of if not the best implementations of the game I have had the pleasure of exploring
AI Solar Tide -
Solar Tide cast in 3 games in a row on turn 6 there was 1 in the AI deck - something I want to also point out, when the AI played solar tide it did not show anywhere which option was chosen and I did not know which power creatures were going to die. This had an impact on game play choices for me as I had a Spike Drone in play to sack but did not know if it was going to live or die so could not make the correct choice (if power 2 or less are chosen then I sack the drone to move the counter to a power 3 or greater card, or not sack it if power 3 or greater are chosen to die)
AI Gaze of Justice -
I played against this deck 7 times in a row, One Gaze of Justice in AI deck in hand 5 of 7 starts - also 4 games in a row saw Kinsbaile Skirmisher 2nd turn
Xantid Swarm -
I kept getting this card either in my opening hand or within 1-3 draws in all of about 10 games
If you compare the cards I have in my hand and in play throughout this series of pictures you may notice the patterns of similarity with cards I have early in the game
There was a lot of cards in my deck I saw once or twice and a few key cards I saw in nearly every game very early, which is important for in the course of a long game yes you are bound to see cards repeatedly but my observations are of the early game in almost all examples
The patterns remind me of rolling 2 six sided dice multiple times and looking at the average because again we are not talking exact repetition of hands but very similar patterns of gameplay early that over the course of many games starts to defy the odds quite a bit
Other than that this is still one of if not the best implementations of the game I have had the pleasure of exploring
Re: Post MTG Forge Related Programming Questions Here
by friarsol » 16 Jan 2013, 02:14
tafkad
I think the main issue here is probability and some confirmation bias. Limited decks are only built at 40 cards, so it feels like there is lots of repeats, when it just has more to do with a limited form of chance. There's a 20% chance that a one of card appears in the first 8 cards in a deck. Our card shuffler is using Javas built in shuffle based on http://en.wikipedia.org/wiki/Fisher%E2% ... es_shuffle of course this is Pseudorandom, so there are patterns, there's nothing we can do about that, but it's really nothing to "fix". I've been playing card based games for 15 years now, and people always complain about the shuffler.
I think the main issue here is probability and some confirmation bias. Limited decks are only built at 40 cards, so it feels like there is lots of repeats, when it just has more to do with a limited form of chance. There's a 20% chance that a one of card appears in the first 8 cards in a deck. Our card shuffler is using Javas built in shuffle based on http://en.wikipedia.org/wiki/Fisher%E2% ... es_shuffle of course this is Pseudorandom, so there are patterns, there's nothing we can do about that, but it's really nothing to "fix". I've been playing card based games for 15 years now, and people always complain about the shuffler.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Post MTG Forge Related Programming Questions Here
by moomarc » 16 Jan 2013, 05:34
Just out of interest, here's the code that handles the shuffling:
- Code: Select all
public final void shuffle() {
final List<Card> list = Lists.newArrayList(this.getCardsIn(ZoneType.Library));
if (list.size() <= 1) {
return;
}
// overdone but wanted to make sure it was really random
final Random random = MyRandom.getRandom();
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
int s = list.size();
for (int i = 0; i < s; i++) {
list.add(random.nextInt(s - 1), list.remove(random.nextInt(s)));
}
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
Collections.shuffle(list, random);
this.getZone(ZoneType.Library).setCards(list); ...
-Marc
-
moomarc - Pixel Commander
- Posts: 2091
- Joined: 04 Jun 2010, 15:22
- Location: Johannesburg, South Africa
- Has thanked: 371 times
- Been thanked: 372 times
Re: Post MTG Forge Related Programming Questions Here
by tafkad » 16 Jan 2013, 06:00
Hey thanks guys, it helps to know these things and that it can't be fixed beyond what it is. I understand the % side of things totally. I just see the patterns repeat in multiple games against the same deck. Even with the 20% I feel when I see a card 4-6 or more times within the first 3 turns with the same decks that it is beating the %'s it gets to the point where it feels like I can predict what is going to happen with greater certainty than any games with real cards. Seems like a 20% chance of a one of card being in the top 8 means in 10 games it should not happen a majority of the time (3 or 4 of 10 I might not notice) but I am seeing this happen on the high % side to where it is noticeable (like 6-8+ of 10)
Thanks again for all the replies, I feel the last 2 for sure answered my original question and my curiosity on this topic. I need to post some more bugs in the snapshot section soon. Keep up the great work, regards.
Thanks again for all the replies, I feel the last 2 for sure answered my original question and my curiosity on this topic. I need to post some more bugs in the snapshot section soon. Keep up the great work, regards.
13 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 34 guests