Writing Puzzles
Learn how to write and add puzzles to Curta.
Introduction
To write a puzzle, inherit IPuzzle
and implement its 3 functions:
Text Example: Sorted List
Consider some puzzle where the solution is to take an unsorted list of randomly generated numbers and sort it. In other words:
generate
returns a bitpackeduint256
of 32 random numbers .verify
iterates through 8-bit words of_solution
and verifies that they are sorted, and each number in_start
is contained in_solution
.
Code Example: Collatz
Consider some puzzle where the solution is to apply the operation from the Collatz Conjecture a random number of times to a randomly generated integer. The code below implements this:
Adding a puzzle to Curta
To add a puzzle to Curta, you must first obtain an unused Authorship Token.
After obtaining an Authorship Token and deploying your puzzle contract, you can use it like a ticket to add a puzzle by calling addPuzzle(IPuzzle,uint256)
on the Curta contract:
Customizing art
Authors can customize 5 colors on their puzzle's Flag NFTs art:
Each color is represented with 24 bits, and the colors for a puzzle's Flag is stored as a single bitpacked uint256
with the following offsets:
To set this onchain, call setPuzzleColors(uint32,uint256)
on the Curta contract: