mirror of
https://github.com/hanzoai/synth.git
synced 2026-10-30 18:20:12 +00:00
Survo Matrix Filling Game
Game Description
Survo is a matrix filling game with the following rules:
- Given an n*n two-dimensional matrix where some positions are pre-filled with numbers, and the remaining positions are marked with 'X' (represented internally as 0).
- The numbers in the last row and last column represent the sum of all preceding numbers in that row or column.
- Given a set of candidate numbers, these numbers need to be filled into the positions marked with 'X'.
- Each candidate number can only be used once.
- After filling, it must be ensured that the sum of each row and column equals the last element.
Example
There is a 3*3 two-dimensional matrix where the last element of each row and column equals the sum of the other elements in that row and column. The matrix is:
[[1,X,3,6],[1,X,3,6],[1,X,3,6],[3,6,9,18]]
where some elements are replaced with X. There is a set of candidate numbers [2,2,2] that can be filled into the X positions in the matrix to satisfy the corresponding rules. Please fill them in, with each number used only once, and provide the filled matrix.
Core Logic
Game Generation Logic
-
First generate a complete n*n matrix where:
- Randomly fill all positions of the (n-1)*(n-1) submatrix
- Calculate the sum of each row and column, fill into the last row and last column
- Calculate the bottom-right element (n-1, n-1)
-
Randomly select x positions, replace them with 0 (displayed as 'X'), and record the replaced numbers as candidate numbers.
-
Generate game prompts, including matrix description and candidate numbers.
Verification Logic
The verifier checks whether the submitted answer meets the following conditions:
- Whether the matrix dimensions are correct
- Whether the pre-filled elements in the original matrix are preserved
- Whether the filled numbers match the candidate numbers (quantity and values)
- Whether the sum of each row and column is correct
Answer Extraction Logic
Methods for extracting matrix answers from model responses include:
- Extract matrix from Python code blocks
- Extract matrix from general code blocks
- Directly extract possible matrix representations from text
Usage
- Run the game generator:
python -m games.tasks.survo.scripts.survo --num_of_data 100 --n 4 --x 3 --min_num 1 --max_num 9
Parameter explanations:
num_of_data: Number of game data to generaten: Matrix dimensionsx: Number of digits to be filledmin_num: Minimum value of numbers in the matrixmax_num: Maximum value of numbers in the matrix
Game Features
- Each generated game is guaranteed to have a solution
- Randomly selects Chinese or English prompts
- Diversified prompt templates
- Strong fault tolerance when verifying answers