Gambling with Scala pt.1

For some time I was eager to write some sample application that will be using Scala and the Akka actors framework. The main problem was to pick up an example, that would make sense to apply both technologies. The idea for the example came to me all of sudden, when I was sitting with my friends after a soccer game. Usually, when you play a game, you are talking about it right after it ends, but this time it was different. My colleagues were talking about poker !

When I heard their talk, I was enlightened ! I decided to write a sample application similar to the on-line poker sites like

Before I start coding, I will outline my idea for the application:

  1. the application will be written in Scala
  2. it will be implementing the simplest poker flavor – the five-card draw with 24 cards
  3. there will be 4 player limit for each game
  4. it will have an HTML front-end
  5. the Akka actors library will be used
  6. the Play! framework will be used

The architecture design will be as follows:

The application will be divided into two tiers:

  • Tier 1 – will be based on the PLAY! framework and will be responsible for rendering the UI
  • Tier 2 – will be the actual game engine
  • the communication between T1 and T2 will be handled by the Akka actors library

Before starting the development, we must set up the environment. To set up the environment, we need to:

  1. download and install the Typesafe 2.0 stack
  2. download and install the latest JDK6 and add the Java bin directory to the path
  3. you may need also a Scala IDE, I’am personally using the Scala IDE for Eclipse

The development will start from the T1. To create a Play! Framework application one must:

  1. open the console, cd to a suitable location and execute: g8 typesafehub/play-scala
  2. you will be prompted to enter the application name after the sources download is finished, type “poker”
  3. after the process is finished cd to the poker directory and type sbt

The SBT (Simple Build Tool) is a console tool that will help us to manage the project. To start the application, type run. The application will be started and it is accessible under localhost:9000. More options for the sbt play console are available under the help play command.

The real coding will start from pt.2, so stay tuned 😉

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.