RoboSnap

Have you ever wanted to watch your computer battle itself in a energetic game of Snap? I can’t say that I have, but as part of my Master of Computing studies I’m doing Advanced Programming in Java and this has resulted in me undertaking such an experience. Before you ask what RoboSnap has got to do with the meatier issues of Information Technology, the goal of this assignment was to implement a number of programming features including multithreading. So my simple idea of creating a Snap game to meet the requirements turned into a 764 line Tour de Force. Some food poisoning in Istanbul, one gracious extension and a week of sleep deprivation brings me to this; please welcome RoboSnap.



(Written with Java SE 6. Works in JRE 1.6. Not tested in other JRE versions.)
(HTML written for Mozilla compatible browser such as Firefox 3)

RoboSnap simulates a number of players playing a regular game of “Snap”. The object is to gain all the cards by “Snapping” when duplicate face value cards are placed in succession on the card pile. If no one player is able to gain all the cards then a draw is called.

Basic description:

  • Each player is dealt an equal portion of the deck
  • Each player shows its name, card count and status (such as the card it’s playing)
  • Each player is its own thread
  • Individual players can be paused (suspended)
    • If a player has cards then gameplay will also pause in time
    • If a player has no cards then the game will carry on uneffected
  • The card pile displays the top two cards
  • In normal play, players take turns but when duplicate cards appear it’s first-in-best-dressed as to who wins the card pile.
  • Unticking “Synchronized” runs a less regimented gameplay where players are merely “told” that it’s there turn
    • This mode works mostly fine but is prone to unusual results due to the nature of things
  • The game as a whole can be suspended and resumed
  • The speed of the game can be adjusted by repeatedly clicking on “Speed Up” or “Slow Down”
  • Stopping the game ends it completely, “Start” will start a brand new game

RoboSnap features:

  • Extensive (possibly over the top) multithreading
  • Scalable player numbers
  • Object Oriented design
  • Can be further developed to allow human gameplay

I found programming this Applet a rewarding, tiring and sometimes frustrating experience. This was the first real piece of code I’ve written in a long time and there were a lot of new concepts to deal with, such as multithreading. I found Java to be powerful, in terms of what can be done with it, yet pernickety at times, although I found that the documentation and tutorials from Sun Microsystems were immensely helpful and very comprehensive. Hopefully some of the lessons I learned in this project will spill over into my last, major assessment, making my life easier.

Download the Source Code
. Download All Files. Comments form and why it’s not here. Snap Applet Specifications.

1 Response to “RoboSnap”


  1. 1 hua

    test

Leave a Reply