Friday, March 23, 2007

Haskell Spider Solitare: First Code Drop

OK, here's the first code drop for the spider solitaire implementation in Haskell. Download the zip file here:

http://home.xnet.com/~ansible/haskell/spider_haskell.zip

The code doesn't do much of anything yet, this is mostly setting up some of the data structures, and being able to shuffle the cards. I've started on creating some assertions that can be checked during game play, and that will get more sophisticated over time.

However, there may be better ways to do some of that, and I'm open to suggestions. Like, for example, taking better advantage of the type system.

It would be cool if there was some way to say that this particular kind of list will only ever have ten elements, for example.

Lastly, the moves and move history are just represented as Ints of the row and column. If there's a cleaner way to do that, I'm all ears there too.

Edit: I just tried the code on GHCi v6.4.2 and it doesn't work, not sure why exactly. Was initially developed using GHC 6.6.

No comments: