# Discount Gambling

## Card Craps Source Code

Posted in card craps by stephenhow on September 5, 2010

The card craps players at Viejas definitely lean towards Don’t Pass now, even when I’m not at the table 🙂 The astute players understand that the game is unlike dice craps, and the rolls aren’t quite independent of each other. Yesterday a Don’t player I’ve never seen before started to lecture me on this point before I could tell him I agreed. Then a young couple came and started playing DP and laying odds, like they knew what was going on. When the regulars are playing, at least half the table plays Don’t.

Anyways, I decided to clean up and post my Java source code for card craps, including the CSM model, the roll window, etc. You can download my source code, inspect the models, experiment with the parameters, and verify my results (+1.5% of the flat bet @ 10x Dont’ Pass odds using 3-roll count for the current Viejas shuffler; -3.6% for 10x odds Pass Line player!). I’m posting the source code to show how simple the CSM effect is on the craps game. I.e., given a simple but accurate model of the CSM, the Don’t Pass edge follows:

package net.discountgambling.cardcraps;

import java.util.Vector;
import java.util.Random;

/**
*
* @author show
*/

public class CSM {
// params approximate the ShuffleMaster 126 model Constant Shuffle Machine
static final int NUM_SLOTS = 40;
static final int DICE_SETS = 52;
static final int MIN_BUFFER_DEPTH = 4;  // minimum cards in chute
protected Vector[] slot = new Vector[NUM_SLOTS];    // card slots in "wheel"
protected Vector chute = new Vector();  // cards are dealt from chute
protected Random random = new Random();

public CSM() {
for (int i=0; i<NUM_SLOTS; i++) {
slot[i] = new Vector();
}
for (int i=0; i<DICE_SETS; i++) {
for (int d=1; d<=6; d++) {
shuffleCard(d);
}
}
}

// shuffle roll back into CSM
public void shuffleRoll(Roll roll) {
shuffleCard(roll.getDie1());
shuffleCard(roll.getDie2());
}

public Roll dealRoll() {
return new Roll(dealCard(), dealCard());
}

// deal card from chute
protected int dealCard() {
// drop a slot if chute is running out of cards
while (chute.size() < MIN_BUFFER_DEPTH) {
// select a random slot of cards from the "wheel"
Vector randomSlot = slot[random.nextInt(NUM_SLOTS)];
// drop slot of cards into the chute
randomSlot.clear();
}
return (Integer) chute.remove(0);
}

// shuffle card into random position of random slot
protected void shuffleCard(int card) {
Vector randomSlot = slot[random.nextInt(NUM_SLOTS)];
if (randomSlot.isEmpty()) {
} else {
int randomPosition = random.nextInt(randomSlot.size());
}
}
}