Running is therapy

a blog about running, cats, Linux and programming.
  • Home
  • Current Schedule
  • Personal Records
  • Upcoming Races

YAHTZEE

Published by Nathan Powell on December 26, 2006 12:25 am under computers

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!

3 Comments so far

  1. Patrick on December 26th, 2006

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

  2. Nathan Powell on December 26th, 2006

    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 on February 3rd, 2007

    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.

Posting your comment.

  • Search

  • Archives

    • October 2008 (1)
    • September 2008 (4)
    • August 2008 (10)
    • July 2008 (11)
    • June 2008 (14)
    • May 2008 (15)
    • April 2008 (10)
    • March 2008 (16)
    • February 2008 (17)
    • January 2008 (37)
    • December 2007 (21)
    • November 2007 (30)
    • October 2007 (29)
    • September 2007 (22)
    • August 2007 (30)
    • July 2007 (49)
    • June 2007 (32)
    • May 2007 (29)
    • April 2007 (38)
    • March 2007 (26)
    • February 2007 (25)
    • January 2007 (23)
    • December 2006 (10)
    • November 2006 (12)
    • October 2006 (9)
    • September 2006 (9)
    • August 2006 (5)
    • July 2006 (13)
    • June 2006 (9)
    • May 2006 (8)
    • April 2006 (11)
    • March 2006 (12)
    • February 2006 (12)
    • January 2006 (13)
    • December 2005 (15)
    • November 2005 (19)
    • October 2005 (8)
  • Categories

    • blather (62)
    • books (10)
    • computers (177)
    • cooking (1)
    • economics (3)
    • emacs (3)
    • football (1)
    • gaming (1)
    • hiking (5)
    • housekeeping (5)
    • lifehacking (7)
    • music (3)
    • paddling (2)
    • personal (1)
    • politics (21)
    • programming (70)
    • running (231)
    • smoking (40)
    • sysadmin (9)
    • tlc (10)
    • Uncategorized (1)
  • Pages

    • Current Schedule
    • Personal Records
    • Upcoming Races

Copyright © 2008 Running is therapy
WordPress Theme based on Light Theme