# Puzzle Verifier - How to Use ## Overview The `verifier.py` script verifies whether an ASCII representation of a puzzle state is correctly solved. It supports five puzzle types: **bridges**, **undead**, **galaxies**, **pattern**, and **loopy**. ## Supported Puzzle Types | Puzzle Type | Default Argument | Solved Field | Notes | |------------|------------------|--------------|-------| | **bridges** | `5x5deL` | `completed` | Checks structural validity before verification | | **undead** | `4x4` | `solved` | Checks structural validity before verification | | **galaxies** | `4x4` | `completed` | Direct verification | | **pattern** | `5x5` | `completed` | Direct verification | | **loopy** | `5x5t0` | `solved` | Handles dimension validation errors gracefully | ## How It Works The verifier uses a **parse → load → check** pipeline: 1. **Parse**: Converts ASCII text to a structured state dictionary using puzzle-specific parsers 2. **Load**: Loads the state dictionary into the puzzle's C backend 3. **Check**: Queries the puzzle's solved/completed flag to determine if the state is valid ### Verification Process For each puzzle type: 1. **Bridges & Undead**: - First performs structural validity checks (ensures no broken lines, modified clues, etc.) - If structurally invalid, returns "NOT SOLVED" immediately - Otherwise, parses and verifies the state 2. **Galaxies, Pattern, Loopy**: - Directly parses the ASCII state - For loopy, handles dimension validation errors (treats malformed responses as "NOT SOLVED") 3. **Error Handling**: - Dimension validation errors (invalid canvas width/height) are treated as "NOT SOLVED" (model mistakes) - Other parsing errors are re-raised as exceptions ## Usage ### Basic Usage #### From Command Line Argument ```bash # Bridges python verifier.py bridges "3|.|2\n..." # Undead python verifier.py undead "G: 3 V: 1 Z: 6\n\n 2 3 1 1 \n..." # Galaxies python verifier.py galaxies "+-+-+\n|o o|\n+-+-+\n|o o|\n+-+-+\n" # Pattern python verifier.py pattern " 1 2 3\n 4 5 6\n 7 8 9\n" # Loopy python verifier.py loopy " x x x - x \nx x0x |3| x\n..." ``` #### From Standard Input ```bash # Read from file python verifier.py bridges < ascii_state.txt # Pipe from another command echo "3|.|2\n..." | python verifier.py bridges # Multi-line input cat < bridges_solved.txt <