This directory provides two ways to generate Q&A data for the 3D reconstruction game:
main.py: standard mode, which usually generates one QA pair for one game state.multi_gen.py: multi-question mode, which first generates game states and then generates all 6 question templates for each state.
An example game image:
pip install -r requirements.txtDependencies include:
- Python 3.6+
- NumPy >= 1.19.0
- Matplotlib >= 3.3.0
- tqdm >= 4.65.0
- The game is played in a
3x3x3voxel grid. - Coordinates
(x, y, z)range from 1 to 3, where(1,1,1)is the front-left-bottom cell. - Each position can contain at most one voxel.
- All voxels must stay face-connected.
- New voxels can only be added adjacent to the current structure.
- Projection rules:
- Front view (
Y-Z) is observed from the negative X direction. - Side view (
X-Z) is observed from the positive Y direction. - A projection cell is
1if any voxel exists along that line of sight; otherwise it is0.
- Front view (
- The goal is to match the target projections within the remaining voxel budget.
The game uses two difficulty notions:
Easycount: count voxels in the current structureposition: determine whether a position contains a voxel
Mediumprojection: judge how the current projections match the target projectionsaction_outcome: predict the projection after adding specified voxels
Hardstrategy_optimization: find the minimum number of extra voxels neededtransition_path: choose the correct voxel-adding sequence
Easy: 3-5 voxelsMedium: 6-10 voxelsHard: 11-15 voxels
--level-ratios uses x:y:z format for Easy:Medium:Hard. At most one value can be omitted and will be filled automatically.
python main.py [arguments]Available arguments:
--total N: generateNquestions, default100--qa-types TYPE1 TYPE2 ...: choose fromcount,position,projection,action_outcome,strategy_optimization,transition_path--type-ratios RATIOS: question-type ratios such as0.2:0.2:0.2:0.2:0.1:0.1--level-ratios RATIOS: structure-difficulty ratios such as0.2:0.2:0.6--output PATH: output directory, defaultreconstruction_dataset
Examples:
python main.py --total 100
python main.py --total 100 --qa-types count position projection
python main.py --total 100 --type-ratios 0.2:0.2:0.2:0.2:0.1:0.1 --level-ratios 0.2:0.2:0.6python multi_gen.py [arguments]This mode first generates game states, then generates all 6 question templates for each state. That means:
- the QA-to-image/state ratio is roughly
6:1 - total QA pairs =
total_states × 6
Available arguments:
--total-states N: generateNgame states, default100--level-ratios RATIOS: structure-difficulty ratios such as0.2:0.2:0.6--output PATH: output directory, defaultreconstruction_dataset
Examples:
python multi_gen.py --total-states 50
python multi_gen.py --total-states 20 --level-ratios 0.2:0.2:0.6Outputs are written to the directory specified by --output; if omitted, the default is reconstruction_dataset/:
reconstruction_dataset/
├── data.json
├── images/
│ └── reconstruction_*.png
└── states/
└── reconstruction_*.json
reconstruction_dataset/
├── data.json
├── images/
│ └── reconstruction_state_*.png
└── states/
└── reconstruction_state_*.json
Each dataset entry contains:
data_idqa_typequestion_idquestion_descriptionimagestateplot_levelqa_levelquestionansweranalysisoptionsfor multiple-choice questions only
{
"voxel_positions": [[1, 1, 1], [1, 2, 1], [2, 2, 1]],
"target_yz_projection": [
[1, 1, 0],
[0, 1, 0],
[1, 0, 0]
],
"target_xz_projection": [
[1, 1, 0],
[1, 0, 0],
[0, 0, 1]
],
"remaining_voxels": 2
}voxel_positions: voxel coordinates in the current structuretarget_yz_projection: target front-view projection matrixtarget_xz_projection: target side-view projection matrixremaining_voxels: how many voxels can still be added
main.pysupports custom question-type ratios, whilemulti_gen.pyalways generates all 6 question types for each state.- Question-type ratios should sum to 1.
- Difficulty ratios should sum to 1.
- For a quick preview, see
reconstruction_dataset_example/.
