Skip to main content

Solver for Queens game with reasoning

Project description

Queens Reasoner

Queens Reasoner solves "Queens" game hosted on linkedin with linear programming, with step-by-step reasoning as humans.

Installation

To install Queens Reasoner, first run one of the following:

# Using pip
pip install queens-reasoner

# Using uv
uv pip install queens-reasoner

Then, run this to install browsers for playwright:

install-playwright-browsers

Usage

The Queens Reasoner automatically loads the "Queens" game hosted daily. To call the reasoner, run:

queens-reasoner

The reasoner first loads the game, then solves it, and finally validates the solution on the hosted webpage. Positions of queens are marked by asterisks to the right of color index, while others are marked by "x". In contrast to Queens Solver ("queens-slvr", which solves the game with linear programming), you may see the step-by-step reasoning process with Queens Reasoner. An example output looks like:

2026-05-13 09:43:01,303 [INFO] queens_browser: Page loaded from: https://linkedin.com/games/view/queens/desktop
2026-05-13 09:43:01,515 [INFO] queens_browser: [Play game] button clicked
2026-05-13 09:43:01,548 [INFO] queens_browser: Tutorial screen escaped
2026-05-13 09:43:01,733 [INFO] queens_parser: [queens-board] section found
2026-05-13 09:43:01,739 [INFO] queens_parser: Queens game board parsed
[[1  1  1  4  5  5  5 ]
 [6  6  1  5  5  5  5 ]
 [1  1  1  5  5  5  5 ]
 [2  2  1  5  5  3  5 ]
 [1  1  1  5  3  3  3 ]
 [5  5  5  5  5  3  7 ]
 [5  5  5  5  3  3  3 ]]
2026-05-13 09:43:01,750 [INFO] queens_reasoner::single_color_masking: Color 2 eliminates the possibility of queens on 9 elements
[[1  1  1  4  5  5  5 ]
 [6  6  1  5  5  5  5 ]
 [1x 1x 1  5  5  5  5 ]
 [2  2  1x 5x 5x 3x 5x]
 [1x 1x 1  5  3  3  3 ]
 [5  5  5  5  5  3  7 ]
 [5  5  5  5  3  3  3 ]]
2026-05-13 09:43:01,751 [INFO] queens_reasoner::single_color_masking: Color 4 determines its queen, and eliminates the possibility of queens on 13 elements
[[1x 1x 1x 4* 5x 5x 5x]
 [6  6  1x 5x 5x 5  5 ]
 [1x 1x 1  5x 5  5  5 ]
 [2  2  1x 5x 5x 3x 5x]
 [1x 1x 1  5x 3  3  3 ]
 [5  5  5  5x 5  3  7 ]
 [5  5  5  5x 3  3  3 ]]
2026-05-13 09:43:01,755 [INFO] queens_reasoner::single_color_masking: Color 6 eliminates the possibility of queens on 2 elements
[[1x 1x 1x 4* 5x 5x 5x]
 [6  6  1x 5x 5x 5x 5x]
 [1x 1x 1  5x 5  5  5 ]
 [2  2  1x 5x 5x 3x 5x]
 [1x 1x 1  5x 3  3  3 ]
 [5  5  5  5x 5  3  7 ]
 [5  5  5  5x 3  3  3 ]]
2026-05-13 09:43:01,757 [INFO] queens_reasoner::single_color_masking: Color 7 determines its queen, and eliminates the possibility of queens on 10 elements
[[1x 1x 1x 4* 5x 5x 5x]
 [6  6  1x 5x 5x 5x 5x]
 [1x 1x 1  5x 5  5  5x]
 [2  2  1x 5x 5x 3x 5x]
 [1x 1x 1  5x 3  3x 3x]
 [5x 5x 5x 5x 5x 3x 7*]
 [5  5  5  5x 3  3x 3x]]
2026-05-13 09:43:01,758 [INFO] queens_reasoner::single_color_masking: Color 1 eliminates the possibility of queens on 2 elements
[[1x 1x 1x 4* 5x 5x 5x]
 [6  6  1x 5x 5x 5x 5x]
 [1x 1x 1  5x 5  5  5x]
 [2  2x 1x 5x 5x 3x 5x]
 [1x 1x 1  5x 3  3x 3x]
 [5x 5x 5x 5x 5x 3x 7*]
 [5  5  5x 5x 3  3x 3x]]
2026-05-13 09:43:01,760 [INFO] queens_reasoner::single_color_masking: Color 2 determines its queen, and eliminates the possibility of queens on 2 elements
[[1x 1x 1x 4* 5x 5x 5x]
 [6x 6  1x 5x 5x 5x 5x]
 [1x 1x 1  5x 5  5  5x]
 [2* 2x 1x 5x 5x 3x 5x]
 [1x 1x 1  5x 3  3x 3x]
 [5x 5x 5x 5x 5x 3x 7*]
 [5x 5  5x 5x 3  3x 3x]]
2026-05-13 09:43:01,761 [INFO] queens_reasoner::single_color_masking: Color 3 eliminates the possibility of queens on 1 elements
[[1x 1x 1x 4* 5x 5x 5x]
 [6x 6  1x 5x 5x 5x 5x]
 [1x 1x 1  5x 5x 5  5x]
 [2* 2x 1x 5x 5x 3x 5x]
 [1x 1x 1  5x 3  3x 3x]
 [5x 5x 5x 5x 5x 3x 7*]
 [5x 5  5x 5x 3  3x 3x]]
2026-05-13 09:43:01,762 [INFO] queens_reasoner::single_color_masking: Color 6 determines its queen, and eliminates the possibility of queens on 2 elements
[[1x 1x 1x 4* 5x 5x 5x]
 [6x 6* 1x 5x 5x 5x 5x]
 [1x 1x 1x 5x 5x 5  5x]
 [2* 2x 1x 5x 5x 3x 5x]
 [1x 1x 1  5x 3  3x 3x]
 [5x 5x 5x 5x 5x 3x 7*]
 [5x 5x 5x 5x 3  3x 3x]]
2026-05-13 09:43:01,765 [INFO] queens_reasoner::single_color_masking: Color 1 determines its queen, and eliminates the possibility of queens on 1 elements
[[1x 1x 1x 4* 5x 5x 5x]
 [6x 6* 1x 5x 5x 5x 5x]
 [1x 1x 1x 5x 5x 5  5x]
 [2* 2x 1x 5x 5x 3x 5x]
 [1x 1x 1* 5x 3x 3x 3x]
 [5x 5x 5x 5x 5x 3x 7*]
 [5x 5x 5x 5x 3  3x 3x]]
2026-05-13 09:43:01,766 [INFO] queens_reasoner::single_color_masking: Color 3 determines its queen
[[1x 1x 1x 4* 5x 5x 5x]
 [6x 6* 1x 5x 5x 5x 5x]
 [1x 1x 1x 5x 5x 5  5x]
 [2* 2x 1x 5x 5x 3x 5x]
 [1x 1x 1* 5x 3x 3x 3x]
 [5x 5x 5x 5x 5x 3x 7*]
 [5x 5x 5x 5x 3* 3x 3x]]
2026-05-13 09:43:01,767 [INFO] queens_reasoner::single_color_masking: Color 5 determines its queen
[[1x 1x 1x 4* 5x 5x 5x]
 [6x 6* 1x 5x 5x 5x 5x]
 [1x 1x 1x 5x 5x 5* 5x]
 [2* 2x 1x 5x 5x 3x 5x]
 [1x 1x 1* 5x 3x 3x 3x]
 [5x 5x 5x 5x 5x 3x 7*]
 [5x 5x 5x 5x 3* 3x 3x]]
2026-05-13 09:43:02,000 [INFO] queens_validator: Setting [queen] on row 1, column 4
2026-05-13 09:43:02,031 [WARNING] queens_validator: Skip setting [queen] on row 2, column 2, since the tile is not enabled
2026-05-13 09:43:02,084 [WARNING] queens_validator: Skip setting [queen] on row 3, column 6, since the tile is not enabled
2026-05-13 09:43:02,710 [INFO] queens_validator: Setting [queen] on row 4, column 1
2026-05-13 09:43:02,798 [INFO] queens_validator: Setting [queen] on row 5, column 3
2026-05-13 09:43:02,858 [INFO] queens_validator: Setting [queen] on row 6, column 7
2026-05-13 09:43:02,947 [INFO] queens_validator: Setting [queen] on row 7, column 5
2026-05-13 09:43:07,042 [INFO] queens_validator: Validation result: SUCCESS
[[1x 1x 1x 4* 5x 5x 5x]
 [6x 6* 1x 5x 5x 5x 5x]
 [1x 1x 1x 5x 5x 5* 5x]
 [2* 2x 1x 5x 5x 3x 5x]
 [1x 1x 1* 5x 3x 3x 3x]
 [5x 5x 5x 5x 5x 3x 7*]
 [5x 5x 5x 5x 3* 3x 3x]]

Apart from "single_color_masking", there are other reasoners. To see all of them, please run pytest -rP --log-cli-level=INFO for more comprehensive tests on the reasoners.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

queens_reasoner-0.2.2.tar.gz (78.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

queens_reasoner-0.2.2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file queens_reasoner-0.2.2.tar.gz.

File metadata

  • Download URL: queens_reasoner-0.2.2.tar.gz
  • Upload date:
  • Size: 78.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for queens_reasoner-0.2.2.tar.gz
Algorithm Hash digest
SHA256 9fe0a5414a1233b97ab4eb84acba67dd2a41c6d44e9bed702cc61e2a06e66f3b
MD5 36757759be7fed27e091951b830e17cc
BLAKE2b-256 85cded45d8a24b03e2982335c5b194b9edfcbed60288655dec508dd900ab1c7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for queens_reasoner-0.2.2.tar.gz:

Publisher: upload-pypi.yaml on zhuxr11/queens-reasoner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file queens_reasoner-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: queens_reasoner-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for queens_reasoner-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6795aa4e86924f5524591f51f5b1fed25244cdea7654f4d235cf4779b46f80da
MD5 4ff38bf0b259f207496d5b64c935feff
BLAKE2b-256 dc32e07086e022c4494e2c5ff01bcc51971968b1753ae3f1a42f4366a1a5076a

See more details on using hashes here.

Provenance

The following attestation bundles were made for queens_reasoner-0.2.2-py3-none-any.whl:

Publisher: upload-pypi.yaml on zhuxr11/queens-reasoner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page