# NihonJijo Procon Tools and Solver

Quick repo guide for the KOSEN Procon 36 "En" pairing puzzle.

## Project Layout
- `solver/v1/`: C solver (beam search baseline)
- `visualizer/`: Tkinter GUI to step through ops
- `procon_tool.py`: puzzle generator / server / viewer
- `puzzles/`, `Puzzle_*.json`, `Solution_*.json`: example inputs/outputs

## Solver v1 (C)

Build:
```sh
cmake -S solver/v1 -B solver/v1/build
cmake --build solver/v1/build
```

Run:
```sh
solver/v1/build/procon_solver_v1 --input Puzzle_8By8.json --output Solution_8by8.json
```

CLI usage (from `solver/v1/main.c`):
```text
procon_solver_v1 --input <puzzle.json> [--output ops.json] [--width N] [--depth N] [--nlimit N]
  --width   Beam width (default 200)
  --depth   Max search depth (default 25)
  --nlimit  Max rotation size considered (default 4)
  --output  Write ops JSON to file (default: stdout)
```

## Puzzle Tool (Python)

Generate a puzzle and scramble ops:
```sh
python procon_tool.py generate --size 8 --moves 10 --output puzzle.json --ops-out ops.json
```

Serve a puzzle over HTTP (contest JSON at `/`, ops at `/ops` if provided):
```sh
python procon_tool.py serve -i puzzle.json --ops-input ops.json --port 8000
```

View a puzzle grid in the console:
```sh
python procon_tool.py view -i puzzle.json
```

Other useful options:
- `--scramble-dir {cw,ccw}` to change scramble direction
- `--seed N` and `--starts-at UNIX` for reproducibility and timestamps

## Visualizer (Python + Tkinter)

Run the GUI visualizer:
```sh
python visualizer/main.py puzzle.json ops.json
```

The UI highlights adjacent pairs in green and lets you step forward/backward through ops.

