[Deal] [Alesia Software Home Page]

Hackix - a Quick and Dirty Bridge Dealer

Here is a short Perl program: 
$boards = shift;               # how many boards for the session?
srand( time );                 # seed based on wall clock
@c = split( '', '0123' x 13 ); # init: 52 tokens, 13 of each
while( $boards-- ) {
  for $i ( reverse 1..52 ) {
    push( @c, splice( @c, int(rand($i)), 1) ); # shuffle tokens
  }
  print @c, "\n"; # output the deal for one board
}
And here is an example of its output, given the input 10
3200201213233210330013110103122203301200312121303221
1302111323022021303011210213220201132330001102032333
2221321210033133123202020100012333031110201203201313
3030322102101213013332321001233211211013202022310030
1223012130323213213000201122010200110133220101332333
0103321120320132130210003223102313100310021212231332
2313131001233222200011233111032032200301303112201023
1122023231020003303120130203333203120122131012132101
3100121023103320122122000323302120103111312212030333
1323320131330220303210310322011203110212332021120001
The program generates series of a random strings, each containing 13 zeroes, 13 ones, 13 twos, and 13 threes. Each of the possible D (D = 52!/13!/13!/13!/13!) sequences are equally probable, assuming sufficient statistical soundness of the rand function.

We will associate the directions North, East, South and West to the numbers 0, 1, 2, and 3, respectively. We will also associate each of the 52 positions in a string with a card in the bridge deck: A, K, ..., 2. In this way, each string represents a bridge deal.

In essence, we have a dealing program. Of course, the output needs to be massaged in order to represent the deals in a relevant format, but we can leave that to other hackers for the time being.

How good is the Hackix program?


updated 2000-02-06 / jbc