A few weekends ago, I had been reading about Lisp and decided that I should try to write something semi-interesting to cement my knowledge. So I fired up Emacs and started messing around and this is what came out of it.
It’s a simple video poker game like the kind that you play in Vegas. It doesn’t take bets or keep any kind of running score and there’s no support for wild cards, but I figured I’d see if more than 3 people download it before I started adding more features.
My observations from writing this:
- Programming in Lisp is fun. Especially when using Emacs and SLIME. Being able to redefine things on the fly is very powerful.
- Lisp seems to be a pretty good fit for this type of game. There’s a lot of power in lists and recursion was pretty natural for the functions that determine what kind of hand you have.
- There are a few small irritating little differences between Common Lisp and Emacs Lisp. For instance, the
format
function takes different arguments and in Emacs Lisp, I had to uselexical-let
in order to get a closure. This is because Emacs Lisp predates ANSI Common Lisp.
Let the Emacs -vs- VI battle begin!
Nice job though, Lisp is fun.
–greg.
Anyone who wants to start that battle better come prepared with code that implements poker in vi 😉
Pleaaaase add more features! 🙂
Nice way to learn Lisp…I am on this path myself, so maybe I will come with something as cool as this.I hope.
What features would you like to see?
Well, I do play tetris in Vi..
I posted this on EmacsWiki:
http://www.emacswiki.org/cgi-bin/emacs/poker.el
I got it from EmacsWiki, but in order to run it, I needed to add (require ‘cl) to the file, otherwise setf wasn’t defined. Cool program!
Didn’t know the o’reilly book. So thanks for that hint. 🙂