views:

2106

answers:

7

I know several games have been coded in Haskell, but being a newbie I don't yet consider myself capable of judging quality of coding (idiomatic style, etc.)

Can anyone recommend the source of a particular game written in Haskell as a learning exercise?

(As a side note, the simpler the game, the better, really. I'd especially be thrilled if there's a well-coded RPG/roguelike.)

Thanks!

+2  A: 

How about Game of Life? http://www.alpheccar.org/en/posts/show/78

This is a RPG, though I don't know about the quality: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/MazesOfMonad-1.0.3

jacob
For some real fun, try implementing Life with quad-based caching to speed things up: http://dotat.at/prog/life/hslife.hs
ephemient
+10  A: 

LambdaHack was written by an experienced Haskeller for teaching purposes, so should be well written.

Ganesh Sittampalam
Gah, it requires GTK.
Dietrich Epp
The code itself is indeed quite beautiful and very instructive. Thank you for this, I'm going through it now!
J Cooper
+3  A: 

There's a few games listed on HackageDB: packages by category # Game, and a few more on the wiki. Personally, the ones presenting more mathematical programming challenges are more interesting...

Digging through a random selection of Hackage packages, I'd say that what's currently there actually does have pretty good style, and a fair number even use advanced techniques and new features of Haskell'.

If you're looking for exemplary code of any kind: I'm always pretty happy reading GHC's library source code.

ephemient
Nothing against well-written code of any kind, of course! However, I have an ulterior motive here, which is not currently being able to wrap my head around programming a game in a purely functional style. So reading examples of how to do this right also greatly interest me.
J Cooper
+1  A: 

Being something I wrote myself I can't comment on whether it was well-written, but a while ago I wrote the beginnings of a MUD driver called Custard; I'd say that counts as an RPG. It's written in Haskell and uses mostly monadic style since that works really well for constructing MUDs. Since it uses one big state monad I've made heavy use of data-accessor; being familiar with that package will help in understanding the code.

Martijn
+3  A: 

I think the first-person shooter Frag is pretty cool, and the code is very interesting to look at. It's not always beautiful, but I've learned quite a bit from it, since it deals with so many of the "real" issues that my Haskell programming so far has avoided. It's also the largest example of an FRP (Functional Reactive Programming) based application that I've looked at. They use the Yampa library as a DSL to model game entities, gluing it all together with Arrows.

Mr. Putty
+1  A: 

I'm nowhere near experienced-enough to say if the code here is "exemplary," but my favorite Haskell game right now is the side-scrolling shooter, Monadius. It requires GLUT.

rtperson
+1  A: 

You may be interested in Raincat, a 2D puzzle game written by a group of students at Carnegie Mellon. The game's source is available from their website.

Greg Bacon