Spaces:
Sleeping
Sleeping
File size: 2,754 Bytes
67acd34 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | # Building the RLP (Reinforcement Learning Puzzles) Library
This document provides instructions for building the rlp puzzle library, which is required for the verifier API.
## Prerequisites
Install the required system packages:
```bash
# On Debian/Ubuntu
apt-get update
apt-get install -y cmake build-essential pkg-config libgtk-3-dev imagemagick
```
## Building the Library
1. Navigate to the rlp submodule directory:
```bash
cd submodules/rlp
```
2. Create the library output directory:
```bash
mkdir -p rlp/lib
```
3. Run cmake to configure the build:
```bash
cd rlp/lib
cmake ../../puzzles
```
4. Build the libraries (this will also generate icons if ImageMagick is installed):
```bash
make -j4
```
5. Verify the build was successful by checking for .so files:
```bash
ls *.so
# Should show: libbridges.so, libgalaxies.so, libloopy.so, libpattern.so, libundead.so, etc.
```
6. Verify icons were generated:
```bash
ls icons/*.png | head -5
# Should show PNG files like bridges-96d24.png, etc.
```
## Quick One-Liner
For a fresh build from the repository root:
```bash
cd submodules/rlp && mkdir -p rlp/lib && cd rlp/lib && cmake ../../puzzles && make -j4
```
## Troubleshooting
### Missing pkg-config
```
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
```
Solution: `apt-get install -y pkg-config`
### Missing GTK
```
Could not find gtk+-3.0
```
Solution: `apt-get install -y libgtk-3-dev`
### Icons not generated
```
Puzzle icons cannot be rebuilt (did not find ImageMagick)
```
Solution: `apt-get install -y imagemagick`
Then rebuild:
```bash
cd rlp/lib && rm -rf * && cmake ../../puzzles && make -j4
```
### Segfaults when running verifier
This usually happens when:
1. Icons are missing - rebuild with ImageMagick installed
2. Too many puzzle instances created - the verifier code caches instances to avoid this
## Supported Puzzle Types
The verifier supports these puzzle types from the rlp library:
- **bridges** - Connect islands with bridges
- **undead** - Place ghosts, vampires, and zombies
- **galaxies** - Divide grid into rotationally symmetric regions
- **pattern** - Fill grid based on row/column clues (nonogram)
- **loopy** - Draw a single loop through the grid
## Using the Verifier
After building, you can use the verifier from Python:
```python
import sys
sys.path.insert(0, 'submodules/rlp')
from rlp.puzzle import Puzzle
from verifier import verify_ascii_state
# Create puzzle instance
puzzle = Puzzle('bridges', arg='5x5deL', headless=True)
puzzle.new_game()
# Verify an ASCII solution
result = verify_ascii_state(puzzle, ascii_solution, problem_ascii=original_problem)
print(result) # "SOLVED" or "NOT SOLVED"
```
See `submodules/rlp/VERIFIER_README.md` for detailed API documentation.
|