Minesweeper with Constraints

This version of minesweeper written in Oz has a "digital assistant" that uses constraint propagation to help you play, by automatically uncovering squares that it can prove don't have mines, and marking mines where it can prove they exist. All in 600 lines of code.

Constraint programming is good reason to learn Oz. Actually, I'll probably learn Alice instead, because I prefer static typing. I really like Alice's explicit laziness with implicit forcing. Plus it has logic variables, dynamic loading, persistence, GUI support, and a repl (read-eval-print loop). I'm starting to get tingles in my stomach just thinking about it. I used to feel that way about Java, back around 1996 and 1997.

Posted on October 28, 2003 06:28 PM
More languages articles

Comments

Since your job has you using OO languages, when choosing languages such as Haskell and Alice instead of Oz for home work/study do you find yourself missing objects?

Posted by: Ralph Richard Cook at October 29, 2003 11:17 AM

Yes, I do find myself missing objects. I'm not sure yet whether that's simply because I'm in the habit of using objects to solve all problems (while HOFs or plain old modules might be a better fit), or because objects really are exactly what I need.

I'm currently learning about haskell's existential types, which I hope will solve some of the limitations I've been running into when trying to do OO-style code with type classes...

Posted by: kim at October 29, 2003 02:27 PM

Both the FP and OO approaches have their place. In comparisons to the two approaches you'll often see a grid, with data types on one axis (square, circle, triangle) and operations on the other (draw, get area, rotate). If your application winds up adding more data types a lot, OO is better since it doesn't affect the other classes. If your application adds more operations a lot then FP with algebraic data types can be better since it won't affect the other functions. For a compare and contrast, including ways to mix the two a good paper is at
http://pauillac.inria.fr/~xleroy/talks/icfp99.ps.gz . Of course, parameterized classes and their ilk is what drove me to CLOS's multimethods.

Posted by: Ralph Richard Cook at October 29, 2003 04:51 PM
Post a comment









Remember info?




Prove you're human. Type "human":