EA FC 24 Automated SBC Solving ⚽ ![Open In Colab](https://github.com/camo/f5e0d0538a9c2972b5d413e0ace04cecd8efd828d133133933dfffec282a4e1b/68747470733a2f2f636f6c61622e72657365617263682e676f6f676c652e636f6d2f6173736574732f636f6c61622d62616467652e737667)
This project utilizes integer programming to solve squad building challenges (SBCs). The optimization problem is solved using Google CP-SAT solver. This approach offers extensive customization capabilities, alongside the ability to determine solution optimality.
The goal is to obtain the squad with the minimum total cost.
-
To download the club dataset, use the extension (version >= 1.1.0.3).
-
The inputs to the different constraints can be found in the
input.py
. Configure the appropriate inputs for each SBC constraint ininput.py
(L43-77
andL28-30
) and then navigate tooptimize.py (L581-615)
and uncomment the relevant line based on the SBC requirements. Also don't forget to set theformation
ininput.py
! -
For example, if the requirement is
Same League Count: Max 5
orMax 5 Players from the Same League
then setMAX_NUM_LEAGUE = 5
(L53
ininput.py
) and then uncommentmodel = create_max_league_constraint(df, model, player, map_idx, players_grouped, num_cnts)
(L589
inoptimize.py
). -
If the requirement is
Nations: Max 2
then setNUM_UNIQUE_COUNTRY = [2, "Max"]
(L62
ininput.py
) and then uncommentmodel = create_unique_country_constraint(df, model, player, map_idx, players_grouped, num_cnts)
(L598
inoptimize.py
). -
If you are prioritizing duplicates by setting (
L28-L30
) ininput.py
thenmodel = prioritize_duplicates(df, model, player)
inoptimize.py
(L615
) should be uncommented. -
If for instance, the SBC wants
at least 3 players from Real Madrid and Arsenal combined
andat least 2 players from Bayern Munich
, then setCLUB = [["Real Madrid", "Arsenal"], ["FC Bayern"]]
andNUM_CLUB = [3, 2]
(L43-44
ininput.py
) and then uncommentmodel = create_club_constraint(df, model, player, map_idx, players_grouped, num_cnts)
(L581
inoptimize.py
). -
If the SBC requires at least
6 Rare
and8 Gold
then setRARITY_2 = ["Rare", "Gold"]
andNUM_RARITY_2 = [6, 8]
ininput.py (L71-72)
and then uncommentmodel = create_rarity_2_constraint(df, model, player, map_idx, players_grouped, num_cnts)
(L603
inoptimize.py
). -
Constraints such as
Chemistry
(optimize.py
,L620
) orFIX_PLAYERS
(optimize.py
,L623
) do not require explicit activation. If there is no need forChemistry
, set it to0
ininput.py (L79)
. Similarly, if no players need fixing, leaveFIX_PLAYERS
empty ininput.py (L12)
. -
The
objective
is set inoptimize.py
(L626
). The nature of theobjective
can be changed ininput.py
(L20-21
). Currently the objective is tominimize
thetotal cost
. -
Additional parameters in
input.py
should be reviewed for more information. -
In
main.py
, specify the name of theclub dataset
inL57
. The dataset is preprocessed inpreprocess_data_2
withinmain.py
. Additional filters can be added in a manner similar to the existing ones. -
Currently the inputs are set to solve this SBC challenge. The final list of players is written into the file
output.xlsx
. To execute the program, simply runpy main.py
after installing the required dependencies.
Run pip3 install -r requirements.txt
to install the required dependencies.
-
Python 3.9
-
pandas and openpyxl
Thank you GregoryWullimann
for making the model creation process insanely faster.
Thank you Jacobi from EasySBC
for helping with the squad_rating_constraint
.
Thank you GeekFiro
for testing the solver and providing valuable feedback and discussions.
Thank you fifagamer#1515
and Frederik
for providing your club datasets (Real_Madrid_FC_24.csv
and Frederik FC_24.csv
) and your feedback.
Thank you ckalgos
for creating the extension to download club dataset.
Thank you to everyone who have opened issues on the repo and provided their feedback.
Thank you to all the folks who commented on the reddit post.
Thank you FutDB for providing the API which allowed me to test the solver originally on 10k players (input.csv
)