It is currently 16 Apr 2024, 11:44
   
Text Size

Foil rarity fix patch (completed)

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Foil rarity fix patch (completed)

Postby Seravy » 02 Jul 2017, 08:00

-Now supports packs that have nonstandard slot names - "common:anything" will assume it's a common slot, etc
-Now supports DFC slots, official foil rarity not known, so set to same as Time Shifted for now
-Tested Time Shifted slots to work. Rarity is 1/30 foils at the moment (1/15 of foil commons, which are 1/2 of all foils) as I don't know the official ratio - this is probably way too low though as it means 1 foil TS card in 150 packs.
-if no matching rarities can be found (shouldn't happen anymore but in the future, new pack structures might happen), it picks a random slot from the pack at an equal chance as a default.
-As I don't know how foil sheets work, I haven't tested those, but the code for them is unchanged so it should not be affected. Please test.
Attachments
FoilRarityCompleted.txt
(8.72 KiB) Downloaded 274 times
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 02 Jul 2017, 09:14

Nice, I'll take a look at integrating it once I'm back from my vacation! Thanks for your effort, Seravy!

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 13 Jul 2017, 05:37

So, I'm going to take a look at integrating this bigger project. :)
I'd like to have some discussion before I start applying things though - I've been reading up on foil chances on different websites, and I can't come to a definite conclusion as to what the chances should be like, exactly.

On many websites, people claim that "foil rares are only more rare because there are fewer rare/mythic rare cards in the set than there are commons and uncommons", implying that a foil is randomly taken from the entire card pool for the set, and the rarity of the foil is tied to the distribution of foils

Seravy's suggestion is to a custom distribution for chances, utilizing 1/6 for Rare/Mythic, 2/6 for Uncommon, and 3/6 for Common.

Obviously, both variations are not official (and AFAIK there is no official word on how exactly foils are distributed by rarity), and they yield somewhat different results.

The "foil rarity depends only on the number of cards of each rarity in the set" yields somewhat higher amount of uncommons and rares than the "1/6, 2/6, 3/6" approach, which in my testing seems to only give foil rares and mythics once in a blue moon or so. Both approaches make foil rares/mythics noticeably more rare than the currently utilized approach, which gives an equal (33%) chance of each rarity for a foil because the chance is tied to the random selection of the slot, not the card.

So, the big question is:
Which approach would be preferable?

The smaller question tied to the big question is: how do we handle special cards in special slots? Transform cards and VMA Power 9, stuff like that, I mean.

I have a working and formatted version of the patch with both variations on the theme almost completely implemented and tweaked, but we need to decide on whether we are going towards any particular implementation or not.

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 13 Jul 2017, 06:10

Ideally, we should get official information if available.
As far as I heard, each foil rarity tier had its own foil print sheet - and cards were swapped at a predetermined chance for each rarity slot. They were done independently, so you could have a foil rare, a foil uncommon and a foil common in the same pack.


"foil rares are only more rare because there are fewer rare/mythic rare cards in the set than there are commons and uncommons"
This is definitely wrong. Most sets have the exact same amount of rares, commons and uncommons, 51 of each. But there aren't the same amount of foil rares and commons.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 13 Jul 2017, 06:20

Seravy wrote:Most sets have the exact same amount of rares, commons and uncommons, 51 of each. But there aren't the same amount of foil rares and commons.
Hmm, in the recent history of Magic they are using a more varied distribution :/ Amonkhet is 101 commons, 80 uncommons, 53 rares, 15 mythics. Battle for Zendikar uses the same distribution too. Magic 2010 Core Set, a relatively old set, had 101/60/53/15). Which would make it only more complicated if it were tied somehow to the distribution of card rarities in the set, so I don't think it's a viable approach.

But anyway, yeah, I couldn't find any official information anywhere, only speculation and assumptions... :(

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Xitax » 13 Jul 2017, 17:13

Seems to me that the distribution depends entirely on the foil print sheet. They're going to have to distribute all the copies on the sheet so that there's nothing left over at the end, they're not going to want to keep extra useless foils just because. If the sheet has to determine the rarity of foils, the distribution of cards on the sheet is going to mess with the evenness of foils across rarities if the foil print sheet doesn't have the same exact distribution of rares/mythics etc. vs each other as the pack does. Make sense?

So if this is true the calculation would depend on our knowledge base of the sheets, and difficulty of working out how that affects the packs.
Xitax
 
Posts: 918
Joined: 16 May 2010, 17:19
Has thanked: 183 times
Been thanked: 133 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 13 Jul 2017, 18:07

Here's another idea from a friend of mine which sounds interesting:

nefigah wrote:<...> in reality they probably have different sheets. Best guess I can find on the internet (there is no official word about this) is one foil sheet that has each common, uncommon, and basic land on it, and they might use that sheet 4 times, and then one foil sheet that has 2 copies of each rare and 1 copy of each mythic (you can find pictures of this foil sheet uncut on the net) that presumably they would use once. So it'd be 4 times more likely that you'd get a common/uncommon/basic as opposed to a rare, and even if you did get something from the rare sheet it would only have a smallish chance of being mythic (<...> the sheet would have 15 mythics but 84 rares).
- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 13 Jul 2017, 19:42

Don't know about "new" packs (meaning, after 2007 or so) but in old packs, especially before the "foil in common slot", each rarity slot had a chance to contain a foil separately. There was X chance to have a foil rare appear instead of your usual rare, an Y chance to have a foil uncommon appear instead of ONE of your uncommons, and Z chance for one common to be replaced by a foil common. That implies different sheets for each rarity very much how the nonfoils are handled.
There was no chance for two foil commons, or two foil uncommons though - either one was replaced or none.
The chance itself changed over time, first the official ratio was printed as "1 in 100 cards", then it got lowered to 70 and nowadays I think is at 65? So foils from older sets are less frequent.
"foil in common slot" definitely changed this behaviour - you could no longer have two or three foils in a pack.
Specials slots - well the only one back then was Timeshifted - had about as much foils as the rare slot I believe, but I could be wrong. Timeshifted cards did contain "ex-rares" so that would make the most sense.
One more thing I'm not entirely sure about was basic lands. You could get foils of those from packs that didn't have a basic land slot, instead of your usual foil common. But I'm not sure if only large sets or all of them. I think only large sets. The main source was precon decks which guaranteed a foil basic land in each deck. One of a random type, not one the deck actually used as a basic land.

I've read speculations about foil sheets and some even assume there were multiple sheets for each rarity (as otherwise the number does not come out as the amount of space on a sheet), or some sheets contained some cards more often than others.


...either way until we can find reliable information, we should use this patch I believe. It's at least more realistic then having as many foil rares as commons. (and I really hope that isn't what the game became after I stopped playing. That would be sad.)
But the special slots need tweaking, my numbers for those are too low I'm sure of that.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 16 Jul 2017, 10:23

Ok, here's the finished (fully prepared) patch file to integrate the foil rarity modification. It needs some testing and possibly tweaking when it comes to rarity ratio (not sure about the latter, since I couldn't get any definitive, conclusive facts about what the rarity ratios *should* be like, so I'm going with the original proposition suggested by Seravy, which overall seems to relate well to the ideas listed on MTG Gamepedia (for Foil Cards) stating that even a premium (foil) common is more rare than a non-premium (non-foil) rare.

So, the chances we're looking at are 1/6 Rare or Mythic, 2/6 Uncommon, 3/6 Common. Special rarities include 1/15 for special (VMA Power Nine/Timeshifted) cards after rolling 50% for Common, and 1/11 for basic land after rolling 50% for Common.

Please let me know if you'd like any changes in this, as well as give this particular code a try to make sure it works well for you.

This version requires modification of only one file (BoosterGenerator.java) and tries to both streamline and refactor the code a little bit to make things intuitive enough (what goes where), at least to the best of my ability.

- Agetian
Attachments
FoilRarities.tar.gz
(2.67 KiB) Downloaded 279 times
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 16 Jul 2017, 14:53

First of all, the 1/15 for Special is definitely wrong - that makes it 1/30 foils, I think 1/30 packs would be more appropriate (that makes it equal to rares). I simply used the wrong number there, forgetting not every pack has a foil. I do not know the official value of these but I assume it was about the same as rares.

..reading the file...whoa, you completely changed the whole thing. It's harder to understand for me now.

Let's see some test results.

1000 packs of Time Spiral. Expected amounts are 36 rares, 72 uncommons, 101 Commons, 6 Timeshifted.
43 foil Rares.
86 foil Uncommons.
103 foil Commons.
6 foil Timeshifted.
Close enough, this set is working.

1000 packs of Mercadian Masques. Expecting 36 R, 72 UC, 9 Lands, 107 Commons.
Result is
36 R, 63 UC, 94 commons. Good.

1000 packs of Avycin Restored. Expecting 4 Mythics, 32 Rares, 72 UCs, 9 basic lands, 98 commons.
result : 2 Mythics, 43 Rares, 70 UCs, 103 C, 10 Lands.
Going to roll a few more because the Mythic slot has a small number of cards, needs more data.
10k packs : 47 Mythic, 302 Rare, 669 UC, 937 C, 133 Land.
Looks about right.

10k packs of Dark Ascension.
There is no way I found to filter for dual faced cards, so I have to base my judgement on how it looks like. I think these are wrong. Very wrong. Assuming DFC is a special slot, it should be exorbitantly rare - ~66 cards total in the entire pool of 10k packs, until we fix the ratio. Yet there are 10-30 of each card, the total is several hundreds. In general there seems to be more of them than even the other cards of the same rarity. I saw you used "contains" in the code to process strings, that might be the problem? Every slot in the set has "DFC" in it, the actual slot is just "dfc", others are "common:!dfc".
(I'm surprised "contains" works for "Rare" and "RareMythic" when the latter contains the former. It shouldn't work.)

Finally, let's see a pack with an UncommonRare slot.
None of those I know about have foils by default so I'm enabling it.

1000 packs of Arabian Nights. Should contain 107 commons, 26 rares and 71 Uncommons.

Got 75 Uncommons, 102 Commons, zero rares. "Contains" is definitely malfunctioning on this one, no rares at all. A number of foils equal to the expected rares is missing.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 16 Jul 2017, 15:05

Ah, good point about the DFC and UncommonRare, I'll see if I can adapt your approach of testing for the presence of a slot instead and see if that works better, or try using startsWith instead since the first part of the slot name should contain the actual definition of the slot "rarity" (in fact, can you maybe test it? Just update the isSlotInTemplate code to use your function for figuring out whether the slot is a part of the template instead of using the .contains method to test). The reason it works for "Rare" and "RareMythic" is most likely because they're tested in reverse order, RareMythic (the longer one) first, and only then Rare in case the RareMythic check fails. ;)

About Special: it really depends on the nature of the Special. I assume you're providing a value for Timeshifted, right? Because the Power Nine cards in VMA, which also use Special rarity, are meant to be more rare than a mythic rare if I remember right (but once again, some official data would be good).

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 16 Jul 2017, 16:42

About special slots.
This is my code.
default :
Code: Select all
+           // Time Spiral
+           if (edition!=null) {
+           if (edition.getName().equals("Time Spiral"))
+           {
+            if (rand.nextInt(15)==1) {
+               Foilcard = CardRarity.Special;
+            }
+            }
+            if (template.HasSlot("dfc")) {
+                if (rand.nextInt(15)==1) {
+                   Foilcard = CardRarity.Special;
+                }
+            }
+           }
+           // There might be more, newer sets with special foils I'm not aware of...
+           // otherwise, default is Common or Land
+           break;
+        }
You can list each type separately with its own rarity.
From what I can tell, you didn't list DFC as a special slot, nor did you list VMA (though I also didn't do the latter, I wasn't aware of that set.). Yes, my suggested number is for Timeshifted slots. It will probably work well for DFC too, but not for VMA.

Tested and using my function does seem to work on UncommonRare and RareMythic slots well.

However, DFC does not work because you didn't specify that as an actual special slot. Also, your code seems to include DFC cards in the nonDFC foil slots instead, which is wrong. I have no idea how you got that result, as those slots are nonDFC in the nonfoil sheets and your foils should be using those sheets?

Assuming the foils follow the same pattern as nonfoils, there shouldn't be DFC foils when you roll "Rare" or "Common", but should be if you roll "Special - DFC". Very much how, DFC Mythics don't follow the rules of mythic rares either - said pack generated 5 times more of a DFC mythic than a nonDFC mythic in nonfoil cards.

I believe this is where your approach seems to be wrong - you match cards by rarity instead of slot type. Those are not always interchangeable, which is why I made sure I'm picking a slot actually present in the pack, and generate a card using the sheet of that specific slot.

I'm not very experienced with this pack though, you might want to consult better sources. Foils might not follow the same distribution as nonFoils regarding DFC cards.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 16 Jul 2017, 16:44

Ok, looks like grabbing all cards from the set by rarity approach that I added would not work very well in conjunction with special slots that specifically exclude cards by other conditions (such as DFC), so for the time being I went back to reformatting and optimizing your original code.

I'm attaching the formatted/optimized version, I need you to test and improve some things though:

- I used a regular expression split with three characters at the same time (space, :, -) to avoid a long chain of calls for splitting things. Please make sure this still works.
- Please modify the chance for the Special slot for Timeshifted (Time Spiral) cards as you described above.
- Please account at least for the Vintage Masters Special rarity, as described here ( http://magic.wizards.com/en/articles/ar ... 14-05-12-0 ) - but note that currently Forge only generates those as foils (no non-foil special cards are ever generated), so their chance as foils for the time being should be exactly as specified for the non-foil version, 1 card in 53 packs or so (since this is essentially the only way these cards are currently ever generated). Once the engine is updated to generate non-foil and foil VMA special rarity cards separately, this can be changed to make the foils even more rare than that.
- Please run the same tests as you did above, as well as the test on VMA and potentially also a test on some modern set with complicated enough declaration of slots (for instance, Conspiracy - code CNS).

Basically, my intent with this code (before it gets integrated) is to make it work as expected for all sets, not only for the older sets / the sets that you're specifically aware of (since Forge is meant to function with the entire Magic history).

P.S. I'm not sure if there's any specific rarity associated with DFC as well. If anyone knows something about it, please respond.

- Agetian
Attachments
FoilRarityFormatted_v2.txt
(8.49 KiB) Downloaded 249 times
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Re: Foil rarity fix patch (completed)

Postby Seravy » 16 Jul 2017, 16:47

Looked at the Vintage Masters page on the wiki.

"Each Vintage Masters booster pack contains 15 randomly selected cards: 10 commons, 3 uncommons, 1 rare or mythic rare and 1 card that is either one of the Power Nine or a premium foil version of any card in the set "

So basically, in that set, the special slot and the foil slot are the same - The nonfoil P9 cards act as a subset of cards that can appear in the foil slot. Meaning it can't be done using the current code and has to be special cased, as a nonfoil card is in a foil card slot.
Seravy
 
Posts: 363
Joined: 26 Oct 2016, 21:23
Has thanked: 5 times
Been thanked: 27 times

Re: Foil rarity fix patch (completed)

Postby Agetian » 16 Jul 2017, 17:41

Seravy wrote:Looked at the Vintage Masters page on the wiki.

"Each Vintage Masters booster pack contains 15 randomly selected cards: 10 commons, 3 uncommons, 1 rare or mythic rare and 1 card that is either one of the Power Nine or a premium foil version of any card in the set "

So basically, in that set, the special slot and the foil slot are the same - The nonfoil P9 cards act as a subset of cards that can appear in the foil slot. Meaning it can't be done using the current code and has to be special cased, as a nonfoil card is in a foil card slot.
Yep, which is exactly why right now Forge will only generate those special cards if they are foils (in fact, it is already specified as an exceptional case somewhere in the code, since the edition file specifies "0 Special"). Making this work correctly such that there are both non-foil and foil P9s is a problem in its own right, solving it while reworking foil slots and stuff might be good too.

- Agetian
Agetian
Programmer
 
Posts: 3471
Joined: 14 Mar 2011, 05:58
Has thanked: 676 times
Been thanked: 561 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 42 guests


Who is online

In total there are 42 users online :: 0 registered, 0 hidden and 42 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 42 guests

Login Form