Nurikabe solver

150 views
Skip to first unread message

Mark Engelberg

unread,
Sep 21, 2022, 5:22:31 AM9/21/22
to Picat
For fun, and to learn Picat, I programmed a Nurikabe solver.

To be completely honest, I found the development experience to be a struggle, in the sense that the editor wasn't great, the interactive terminal not terribly useful, the error messages rarely helpful, and not a lot of tools for working out what was going wrong. I spent a lot of time commenting out various sections of code to try to isolate errors, since I couldn't find a better methodology for debugging. However, I am deeply impressed with the elegance and concision of the final code, and the speed of execution.

It solved in under 1 second a puzzle that took about 5 minutes using a comparable model on the SAT solver I usually use (SAT4J using an interface I wrote from Clojure), and to do it in SAT4J I had to implement my own binary numeric representations and addition in order to write a connected component constraint, which you get "for free" in Picat.

Thanks to Hakan for getting me unstuck with my rookie bugs.

This was just for fun, so I don't really need to improve this program further, but I'm always interested in learning how to use a language idiomatically, so comments are certainly welcome.

Neng-Fa Zhou

unread,
Sep 21, 2022, 10:51:37 AM9/21/22
to Mark Engelberg, Picat
Thank you for your feedback. Picat is still a young language, and a lot of work needs to be done in order to make it more user friendly. Syntax error messages should be more informative, and runtime error messages should be issued with a stack trace. It is always a challenge to debug an unsatisfiable model in constraint programming. I, like many other people, often comment out some constraints in order to locate the constraint that makes a model unsatisfiable. This error-and-trial process is often time consuming.

Cheers,
Neng-Fa


--
You received this message because you are subscribed to the Google Groups "Picat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picat-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/picat-lang/963d89f2-b863-402e-93a7-7fd0275da07en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages