Surface Craps

Disclaimer:  InterKnowlogy is not in the business of writing gambling or casino games.  This application was only written for research, with no intention of using it in a real gaming situation.

VIDEO

Here at InterKnowlogy, we have a program called RECESS (Research and Experimental Coding to Enhance Software Skills) – where we get to spend Wednesday afternoons working on whatever we want, to further our skill set, maybe in a technology area we don’t touch on our everyday projects.  crapsbasic_61F83FBC

We’ve been writing apps for the Microsoft Surface table for a while, and I decided it would be cool to write a Craps game. One of the main ideas of the Surface table is to encourage multiple people to use an application simultaneously while sitting around the table.  What better way to do that than to place bets, “roll” dice, and win “money”?

Before we get too far, check out the video of the game in action.

Now I’ll get into some of the cool design and implementation aspects of the application.

Tag Recognition

Obviously, you need to place bets to play craps.  At a real craps table, you place bets with your chips on CrapsChipsAndDice_6A87B0D4the table, so in Surface Craps you do the same. We use a stack of chips taped together just so they’re easier to hold, and we use “object tags” stuck onto the bottom of the stack to uniquely identify you as a player.  The Surface has cameras inside the case that recognize the object tag patterns and wake us up in event handlers with information about the tag that was placed.  When your chip stack touches the table in a “bettable area” the bet is recorded, and a visual indication of your bet is added to the table.  Up to 4 players can play at the same time, each having their unique stack of chips and placing bets on the table simultaneously.

Bettable Areas

I came up with a UserControl that I call a BettableArea that allows me to know if a tag (stack of chips) is placed somewhere on the table that allows bets (as opposed to dead space around the table, etc).  This control’s content is a Path that defines the actual region that’s bettable (to allow for funny shapes) and also has 4 properties that are filled with the location where the virtual chips should be placed for each player in that region.  The screenshot below shows the BettableArea controls with their opacity turned up to show them at design time – notice the curved and angled paths used to follow the actual betting zones.

 

CrapsBettableAreas_19F20BA2 A quick aside: on a real craps table, the dealers will place the chips for a player at a spot on a bettable area that’s related to where they are standing around the table.  (if you’re at the right corner of the table, your bets will be at the right corner of the bettable area).  When a bet is placed on my Surface Craps table, the visual chips representing your bet show up at one CrapsPlaceOddsSmall_7DE08B0Fof the 4 spots defined in the BettableArea control depending on which player you are.

Many craps players know that the “Place Odds” bet behind the Pass Line is the best bet in all of Vegas.  So, YES, Surface Craps does support placing odds behind the pass line bet, and even enforces the fact that you can’t do it until a point has been established!

 

 

Ratchet Gesture

CrapsRachetBet_658D70F4After you place your initial bet with your chips, we had to come up with an easy way to change the amount you’re betting.  I came up with something I call the “Ratchet” gesture.  You place your chips back down on the table over the existing virtual chips and I show a couple arrows on each side with the bet amount.  While holding the chips down, you turn them left or right (say as if you’re unscrewing a bolt).  As you turn, the bet amount is adjusted up or down depending on the direction of the turn.

3D Dice

I also used this application as a way to learn WPF 3D.  Cubes are about the easiest object to make since they’re CrapsDiceMidSpin_5C5135B3square, and thus only require 2 triangles on each face.  They material is semi-translucent to be able to see through the dice faces to the back of the opposing face.  I use WPF animations to rotate the dice along 2 of the 3 axis when the user flicks the dice to “roll them”.  The dice spin at a rate consistent with the force of the flick detected by the Surface cameras.

Rules / Payout Engine

I came up with a pretty straight forward architecture to allow me to process bets and payouts after each role.  There is a BetLogicBase abstract class from which I derive a specific bet logic class for each type of bet (pass line, field, hardway, etc).  They all implement the virtual ProcessRollResult( ) method, applying their specific logic for that type of bet, and determine what they should do with the bet they’re attached to: payout (win), remove chips (lose), or nothing.  This design makes it super easy to generically process the bets after each roll.  I just loop through all the BettableAreas and call ProcessRollResult( ) on any bets in that area.

On-Table Help

Instead of On-line help, I came up with “On-Table Help”.  If you’re wondering how the hell to play cCrapsTableHelp_68067CE5raps, or can’t remember what the rules are for a particular bet, you just touch the faint question mark button next to that area, and up pops a ScatterViewItem with the information you’re looking for.  Among other things, it tells whether it’s a single roll bet, or multi-roll, and what the payout table is.

Acrylic Dice

Finally and definitely one of the coolest features of the game are the acrylic dice.  We only just got these dice in the last month, so until then you only play Surface Craps by flicking the virtual dice on the table.  We got these dice that are transparent, and have nearly transparent byte tags on them.  My understanding is that the IR sensitivity of the dots in the stickers on the dice is set so that the Surface cameras will recognize them.  VERY COOL! CrapsAcrylicDice_3B3E3FC5

So I recently went about implementing the ability to roll those physical dice on the table, and have it recognize which face they land on.  I show a visual of the correct face of the dice under each physical die, and process results just as if the user had flicked the virtual dice.

Whew – long winded I know, but I’m super stoked on how this game came out.  Take a look at the video if you haven’t already, and let me know what you think.  Any ideas for other options or functionality in the game?

Thanks to Kevin Kennedy for the graphic design of the UI – he’s one of the InterKnowlogy graphic design studs.  Another thanks to Joe Seymour who helped me with the betting/payout engine.

 

 

Disclaimer:  InterKnowlogy is not in the business of writing gambling or casino games.  This application was only written for research, with no intention of using it in a real gaming situation.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>