How to extract a subset of trading cards from a larger set based on arbitrary rules

68 Views Asked by At

I have a set of approximately 20,000 different football (soccer) trading cards (for those interested, this question is based on FIFA Ultimate Team). Each represents a football player and the card has an ability rating between 1 and 99. The higher the rating, the better the player's ability.

A player of this card game purchases 11 cards to form a team to use against the teams of other players. In this game, each team has a "chemistry" rating, between 1 and 100, which is dynamically calculated by the combinations of players in the team. Players are represented by their nationality, club and the league in which their clubs play, so players who play together that share leagues, nationalities or clubs have good chemistry levels, while those who do not, have bad chemistry levels. There are some other rules, but for the purpose of this question we can ignore them for now.

I want to figure out how to generate a team of 11 cards based on arbitrary rules. So for example, I want to be able to use some sort of algorithm or function to say "given the full set of players available, give me a squad with a minimum overall rating of 80 with a minimum 95 chemistry rating." Another example could be "given the full set of players available, give me the highest possible rated squad with a 100 chemistry rating, using only Italian players." The algorithm would then iterate through the entire set and return a squad of 11 based on the stated rules.

From the research I've done, I believe that this is a combinatorial optimisation problem, but I'm an average software engineer and not a mathematician so I'm unsure on how to proceed with this. Ideally, I'd like to take the answer to this and turn it into a library written in PHP or perhaps Python.