Boardgame sorting algorithm to fit your collection perfectly in an organizer respecting a given parameter. The intended use was to sort a boardgame collection vertically in an IKEA Kallax by weight with every cube fitting perfectly.
-
Install the dependencies with
python -m pip install -r requirements.txt. -
Create a .csv (with Excel, Calc or others) with the name of your board games in the first column, the given parameter in the second column and the length of the game in the third column. See template.csv for a template.
Note: the decimal marker must be a dot. The first row of the file is ignored.
-
Comments out with ~
-
Change the variables at the top of main.py according to your setup. a. WIDTH: This should be the space you have in your organizer. The default is 336mm which is a standard Kallax. b. WIDTH_TOLERANCE_MIN, WIDTH_TOLERANCE_MAX: The minimum and maximum space left in a cube. By experience, 1-2mm is perfect, but it heavily depends on the way you took your measurements. c. CATEGORY_WIDTHS: Per-category width overrides. The
halfcategory uses 320mm by default. d. PATH_TO_COLLECTION: Path to your .csv file. -
Run
python main.py. The program writes the CP-SAT result to result.txt. Use--pathto select another CSV and--max-timeto change the solver time limit per category.
The solver first minimizes the number of games that cannot be placed, then their total width, then deviation from difficulty order. Every cube except the final used cube must satisfy the configured tolerance. Increasing --max-time can improve results for large collections.
I also included a way to transfer your BGG collection directly to this software format. Comments or private comments support Length:, Category:, and Weight: properties. A Weight: XXXX value overrides BoardGameGeek's average weight. The sorter warns when any game's effective weight is zero.
- Download your collection from BGG, and select "all".
- Change the parameters of bgg2collection.py: a. PARAM: The evaluated parameter column in bgg. b. LENGTH_COLUMN: comment or privatecomment c. LENGTH_NAME: What you used to mark the length in bgg. d. path: Path to the collection downloaded from bgg.