YAHTZEE

Funny how things go sometimes. On Friday I was staring down a 4 day weekend, and really didn’t have a lot planned. I knew I would be at the laptop and wanted to mess around with some code. I started off messing around with Java and the Swing libs. I got the idea that it might be fun to try to write a fat client yahtzee clone. I have no experience with game mechanics and the idea was interesting. So the first thing I did was make a window and then a menu bar and that was fun and all, but I wanted to roll some dice. Next I jumped online to find some dice images which was more difficult than I thought it would be. I finally found some, but I had to crop them from another image.

One thing led to another and I decided that I would slap together an html page with them and whip up a little javascript to roll them. Then I wanted to write a little more to save certain dice per throw and re-roll others. I got that all working and thought it was fun. Then I figured what the hay, maybe I could write it all in JS.

Next thing I know I have a bunch of it working and decided to see it through. Wow, was that interesting. I wrote it all out and got most of it working over a couple of days. However looking at the code I realized I needed to refactor it. I started rewriting all the methods and abstracting things out, and coming up with neat ways to make it all work. Next thing I know, boom, it’s Christmas morning and I am coming up with cool ways to determine Small Straights and processing arrays of integers, etc.

It was one of those projects that the problem set was small enough that a little white hot key smacking was producing results and difficult enough that it kept me interested.

At any rate: http://nathanpowell.org/dice/

Have fun!

About Nathan Powell

I am a middle aged technologist freak-ball.
This entry was posted in computers. Bookmark the permalink.

3 Responses to YAHTZEE

  1. Patrick says:

    Good deal. Your code provides a pretty good tutorial, especially using unnamed functions (actual closures?) to code object-oriented javascript.

  2. Hehe, if I knew you were gonna look at the code, I would have cleaned it up a little more! :)

    It was super fun. You should have seen the first iteration, u.g.l.y :)

  3. Aris says:

    You can download my verion of Yahtzee (free) from my blog (link below). I call it Aris Yamb 2.0
    Give it a try if you like (virus free), thanks.

    http://detonia.blogspot.com/
    P.S. the blog is in greek, BUT the game is in english.