Watching card manipulation by Dan and Dave Buck including those on their site like the demo video of the Akira flourish got me thinking quite a bit about card shuffling. After seeing some of the false shuffles and other manipulations and having read about games where the shuffling algorithm was only pseudo-random, I wanted to make sure that the card shuffling for my game was at least adequate enough to make the game work. If you’re not familiar with Dave and Dan, check out this video advertisement for their set of DVDs over at Theory 11.
Wikipedia has a good article discussing shuffling cards and computer algorithms for shuffling.
An example shuffle algorithm in Javascript would be this implementation of Durstenfeld’s algorithm, a modern version of Fisher-Yates that looks like this:
function array_shuffle (aArray) { var i, j, mTemp; for (i = aArray.length; i;) { // mTemp, j initialized here for shorter code. j = parseInt (Math.random () * i); mTemp = aArray [--i]; aArray [i] = aArray [j]; aArray [j] = mTemp; } } |
For the random number generation, I prefer this, but I haven’t exercised it in order to see if it makes a difference, though seeing parseInt in the above makes me wonder about its presence.
j = 1 + Math.floor(Math.random() * i); |
As for the cards in the game, they are represented in the Javascript as objects and can be either people or actions. People cards are members of one or the other faction or a third group of loosely-aligned Romans who may be swayed to one side or the other. They have attributes including the side they belong to, whether their side may be changed, their name and current rank. Action cards represent the cards that are used during play. Actions include ranks and positions that may be assigned to People and events like riots, assassinations, and plagues. Action cards often have negative or side-effects, sometimes costing the player who uses it as much as his opponent. Other cards require votes from the Senate such as Exile or the appointment of Generals.
There are a variety of collections that I’ll refer to as decks. There are two decks of people, one for each player. Event decks include one hand for each player, the drawing deck and the discard deck. Additionally, there may be individual cards in play that belong to no particular deck.
I considered a number of names for the game including Optimates et Populares, but that doesn’t roll off the tongue. The working title that I came up with is