
ColorGrid is a programming project developed as part of the first-year curriculum at ENSAE Paris. The game involves a grid-based matching problem with specific rules and constraints. Documentation can be found here : https://arthurdrk.github.io/Color-grid-game/

Consider an n × m
grid, where n ≥ 1
and m ≥ 2
are integers representing the number of rows and columns, respectively. Each cell in the grid has coordinates (i, j)
where i ∈ {0, ..., n-1}
is the row index and j ∈ {0, ..., m-1}
is the column index. Each cell has two attributes:
-
Color
c(i, j)
: An integer in{0, 1, 2, 3, 4}
corresponding to a color:- 0: White (
'w'
) - 1: Red (
'r'
) - 2: Blue (
'b'
) - 3: Green (
'g'
) - 4: Black (
'k'
)
- 0: White (
-
Value
v(i, j)
: A positive integer.
The goal is to select pairs of adjacent cells with the following constraints:
- Cells must be adjacent either horizontally or vertically.
- Black cells cannot be paired.
- White cells can be paired with any other color except black.
- Blue cells can be paired with blue, red, or white cells.
- Red cells can be paired with blue, red, or white cells.
- Green cells can only be paired with green or white cells.
Each cell can only be part of one pair. The objective is to minimize the score calculated as the sum of the absolute differences in values of the paired cells plus the sum of the values of unpaired cells (excluding black cells).
-
Clone the repository:
git clone https://github.com/arthurdrk/Color-grid-game.git cd Color-grid-game
-
In VSCode, use the File menu to open the 'ensae-prog25' folder within the cloned repository.
-
Install the required packages:
pip install -r requirements.txt
-
Run the game.py script:
python code/run_game.py
This project is licensed under the MIT License.