dealer/0040755000076400001440000000000010056357700011171 5ustar henkusersdealer/c4.c0100644000076400001440000001001210055167647011642 0ustar henkusers/* This code has been submitted by Danil Suits , Mar 10, 1999. It implements the cccc() and quality() functions. Both quality and cccc use the algorithms described in _The Bridge World_, October 1982, with the single exception that the values are multiplied by 100 (so that we can use integers for them). Thus, a minimum opening bid is about 1200, rather than 12.00 as expressed in the text. In the original algorithm, everything was done with fractions. Floating point rounding being what it is, I've decided to implement this instead as integer math, until the last step. As it happens, it is currently more convenient to use integers for the return value from these functions as well So for the moment, Rescale is basically a no-op. */ #include #include "tree.h" #include "dealer.h" #include "c4.h" #define C4_TYPE int C4_TYPE Rescale (int nValue) { return nValue; } C4_TYPE cccc (int seat) { return Rescale (eval_cccc (seat)); } C4_TYPE quality (int seat, int suit) { return Rescale (suit_quality (seat, suit)); } #undef C4_TYPE int eval_cccc (int seat) { int eval = 0; int ShapePoints = 0; /* For each suit.... */ int suit; for (suit = SUIT_CLUB; suit <= SUIT_SPADE; ++suit) { int Length = hs[seat].hs_length[suit]; int HasAce = HAS_CARD2 (suit, RK_ACE); int HasKing = HAS_CARD2 (suit, RK_KING); int HasQueen = HAS_CARD2 (suit, RK_QUEEN); int HasJack = HAS_CARD2 (suit, RK_JACK); int HasTen = HAS_CARD2 (suit, RK_TEN); int HasNine = HAS_CARD2 (suit, RK_NINE); int HigherHonors = 0; if (Length < 3) { ShapePoints += (3 - Length) * 100; } if (HasAce) { eval += 300; HigherHonors++; } if (HasKing) { eval += 200; if (Length == 1) eval -= 150; HigherHonors++; } if (HasQueen) { eval += 100; if (Length == 1) eval -= 75; if (Length == 2) eval -= 25; if (HigherHonors == 0) eval -= 25; HigherHonors++; } if (HasJack) { if (HigherHonors == 2) eval += 50; if (HigherHonors == 1) eval += 25; HigherHonors++; } if (HasTen) { if (HigherHonors == 2) eval += 25; if ((HigherHonors == 1) && HasNine) eval += 25; } eval += suit_quality (seat, suit); } /* end for (suit;...) */ if (ShapePoints == 0) eval -= 50; else eval += ShapePoints - 100; assert ((eval % 5) == 0); return Rescale (eval); } int suit_quality (int seat, int suit) { int Quality = 0; int Length = hs[seat].hs_length[suit]; int HasAce = HAS_CARD2 (suit, RK_ACE); int HasKing = HAS_CARD2 (suit, RK_KING); int HasQueen = HAS_CARD2 (suit, RK_QUEEN); int HasJack = HAS_CARD2 (suit, RK_JACK); int HasTen = HAS_CARD2 (suit, RK_TEN); int HasNine = HAS_CARD2 (suit, RK_NINE); int HasEight = HAS_CARD2 (suit, RK_EIGHT); int HigherHonors = 0; int SuitFactor = Length * 10; /*ACE*/ if (HasAce) { Quality += 4 * SuitFactor; HigherHonors++; } /*KING*/ if (HasKing) { Quality += 3 * SuitFactor; HigherHonors++; } /*QUEEN*/ if (HasQueen) { Quality += 2 * SuitFactor; HigherHonors++; } /*JACK*/ if (HasJack) { Quality += 1 * SuitFactor; HigherHonors++; } if (Length > 6) { int ReplaceCount = 3; if (HasQueen) ReplaceCount -= 2; if (HasJack) ReplaceCount -= 1; if (ReplaceCount > (Length - 6)) ReplaceCount = Length - 6; Quality += ReplaceCount * SuitFactor; } else /* this.Length <= 6 */ { if (HasTen) { if ((HigherHonors > 1) || HasJack) Quality += SuitFactor; else Quality += SuitFactor / 2; } if (HasNine) { if ((HigherHonors == 2) || HasTen || HasEight) Quality += SuitFactor / 2; } } assert ((Quality % 5) == 0); return Quality; } dealer/c4.h0100644000076400001440000000063210055167525011651 0ustar henkusers#ifndef PNQ_CARD #define PNQ_CARD #ifdef __cplusplus extern "C" { #endif #define HAS_CARD2(s,r) HAS_CARD(curdeal, seat, (card) MAKECARD(s,r)) #ifdef __cplusplus } /* -- extern "C" */ #endif /* This macro is just an implementation detail - in c++ it would be an inline function. */ int suit_quality( int , int ) ; int quality (int, int); int eval_cccc( int ) ; int cccc (int); #endif /* PNQ_CARD */ dealer/Pre_Processors/0040755000076400001440000000000010002574545014140 5ustar henkusersdealer/Pre_Processors/dpp0100755000076400001440000000130110002574545014641 0ustar henkusers#!/usr/bin/perl -I. use Dist; use strict; use Carp; sub preshape { my @results; my $shapes = shift; my @shapes = split(/(\s+[-+]\s+)/, $shapes); my $s = Dist->new; unshift @shapes, ' + ' unless $shapes =~ /^\s+([-+])/; while(@shapes) { my $expanded; my $sexp = shift @shapes; my $sign; $sexp =~ /\s+([-+])/ or die "BUG analysing $shapes"; push @results, $sign = " $1 "; $s->shape(shift @shapes); $expanded = join $sign, $s->to_dealer; push @results, $expanded; } shift @results; return join '', @results; } while(<>) { s/(shape\s*\{\s*\w+\s*,)([^\}]+)/"$1".&preshape($2)/ge; s/shape\s*\{([^\}]+)\}/shape($1)/g; s/\#.*$//; print; } dealer/Pre_Processors/Dist.pm0100644000076400001440000002441110002574545015400 0ustar henkusers############################################################ ## Dist.pm package, v1.2, (c) 1997 Franois DELLACHERIE ## ## Feel free to distribute as long as you keep ## the names of all contributors to this piece of perl in ## this header. ## If you encounter bugs, mail me at ## sr007-2@dial.oleane.com ############################################################ package Dist; use strict; use Carp; my $DefaultLanguage = 'English'; my $Language = $DefaultLanguage; my %SuitLanguage = (French => 'pckt', English => 'shdc'); my $Suits = $SuitLanguage{$DefaultLanguage}; # default mode my %Permut = (1 => [ qw /0/ ], 2 => [ qw /01 10/ ], 3 => [ qw /012 021 102 120 201 210/ ], 4 => [ qw /0123 0132 0213 0231 0312 0321 1023 1032 1230 1203 1320 1302 2013 2031 2130 2103 2301 2310 3012 3021 3120 3102 3201 3210/ ]); { my @dev_results; sub _recursively_develops { my $one_suit_length; my ($joker,$shape,$count,$depth,$nb_suits,$min,$max,@ranges) = @_; $depth || (@dev_results = ()) ; for $one_suit_length (split('', $ranges[$depth])){ my $mycount; my $myshape; $mycount = $count + ($one_suit_length eq 'x' ? 0 : $one_suit_length); next if $mycount > $max; $myshape = $shape.$one_suit_length; if($depth + 1 == $nb_suits) { next unless ($joker || $mycount >= $min); push(@dev_results, $myshape); } else {&_recursively_develops($joker,$myshape,$mycount,$depth+1,$nb_suits,$min,$max,@ranges)} } @dev_results; } } sub _permute_one_shape { # permute one shape w/ the permutation (01...n)->($permutation) my ($shape, $permutation) = @_; my $len = length($shape); $len == length($permutation) || carp "** Warning **: trying to permute $shape w/ $permutation : wrong length ?"; my $permuted = ' ' x $len; while($len--){substr($permuted, substr($permutation, $len, 1), 1) = substr($shape, $len, 1)} return($permuted); } sub _permute_shapes { # permute an array of shapes w/ all the possible permutations my %shapes; my @shapes = @_; my $shape; for $shape (@shapes) { for (@{$Permut{length($shape)}}) { $shapes{_permute_one_shape($shape, $_)}++; } } return(keys %shapes); } sub _expand_shape { # low-level parsing : no permutations made in this function ! my $nb_suits = 0; my $joker; my $max_in_one_suit = 9; # not considering hands w/ a very very long suit !! my @ranges; my ($regular_shape, $min, $max) = @_; $max && ($max_in_one_suit = ($max < 10 ? $max : 9)); while($regular_shape) { my $range; (($_) = $regular_shape =~ /^(\d[-+]*|\[[-\d]+\]|x)/) || confess "Could not parse beginning of $regular_shape"; $regular_shape = $'; $range = $_; /x/ and $joker = 'yes'; # 'x' is what we call a joker s/(\d)\+/[$1-9]/ unless /^\[/; # \d+ means 'at least \d cards in that suit' s/(\d)\-/[0-$1]/ unless /^\[/; # \d+ means 'at most \d cards in that suit' s/^\[/\[^/; # the garbage that follows in order to develop /^\[/ and do { # the perl-like range into a string containing $range = '0123456789'; # all the length-in-one-suit possibilities $range =~ s/$_//g; }; $nb_suits++; push(@ranges, $range); } return( &_recursively_develops($joker,'',0,0,$nb_suits,$min,$max,@ranges) ); } sub _count_shape { # Counting the number of known cards in a shape my $shape = shift; my $count; for(split ('', $shape)) {$count += $_ if /\d/} $count > 13 && confess "Rock Bottom !! I got >13 cards here in shape $shape !!"; # should not happen ? return $count; } sub _reduce { # permute a set of shapes w/ a given permutation, replacing the joker by the # known number of cards (e.g: there remains only one joker in a shape), # and finally eliminates the duplicatas w/ a jivaro reduction... my ($shape_ref, $permutation) = @_; my %jivaro; my $replace_the_joker_by_; for (@$shape_ref){ my $permuted = ''; $replace_the_joker_by_ = 13 - _count_shape($_); (tr /x// == 1 || ($replace_the_joker_by_ == 0)) && $replace_the_joker_by_ < 10 && (s/x/$replace_the_joker_by_/g); $permutation && ($permuted = _permute_one_shape($_, $permutation)); $jivaro{$permuted || $_}++; } @$shape_ref = keys %jivaro; } sub _reduce_by_ordering_suits { my %jivaro; for (@_) { $jivaro{join '', sort {$b cmp $a} split('', $_)}++; } return keys %jivaro; } sub _extract_permutation_from_shape { # returns the permutation to apply on the results if one # uses a shape like (example in french...) 5c4t(xx)... my $shape = shift; my $permutation = ''; if($shape =~ /[$Suits]/i){ $shape =~ s/[^$Suits]//gi; $shape =~ lc($shape); ($permutation = $Suits) =~ s/[$shape]//gi; eval "(\$permutation = \$shape.\$permutation) =~ tr/$Suits/0123/;"; } return $permutation; } sub _parse_shape { # parses a 'regular expression' of a shape, returning 'staveren's-dealer # -compatible' shapes my $shape_exp = shift; my $shape = $shape_exp; my $logical = ''; my $suit_order_permutation; my @results_wo_logical; my @results; ($shape =~ /:/) and ( ($shape, $logical) = ($shape =~ m/^(.+):(.+)/) ); $suit_order_permutation = _extract_permutation_from_shape($shape); # treating expressions like 5s4c(31)... $logical =~ s/\s*,\s*/ ~ /g; # ',' stands for 'and' in a regshape...replace by ~ for hack-value $shape =~ s/[$Suits]//gi; # Removes the (if present) suit permutation signs $shape =~ s/\s+//g; # Remove useless \s if($shape =~ m/^\((.*)\)$/) { # Complete permutation on the 4 suits my $shape = $1; return (map {"any $_"} &_reduce_by_ordering_suits(&_expand_shape($shape, 13, 13)) ) unless ($logical) ; @results_wo_logical = _permute_shapes (&_expand_shape($shape, 13, 13)); } elsif($shape =~ /^(.+)\((.+)\)$/) { # Partial permutation my ($fixed, $float) = ($1, $2); my $fx; for $fx (&_expand_shape($fixed, 0, 13)) { my ($min, $max) = (0, 0); $max = 13 - _count_shape($fx); $min = $max unless ($fx =~ /x/); push(@results_wo_logical, map {$fx.$_} _permute_shapes(&_expand_shape($float, $min, $max))) ; } } elsif ($shape !~ /[()]/) { # w/o any permutation at all @results_wo_logical = &_expand_shape($shape, 13, 13); } else { # There must be something wrong... confess "Couldn't understand this shape : $shape"; } _reduce(\@results_wo_logical, $suit_order_permutation); if($logical) { @results = (); for(@results_wo_logical){ my $i; if( /x/ ){ for $i(0..3) { my $s = substr($Suits, $i, 1); $logical =~ /$s/i and substr($_, $i, 1) eq 'x' and substr($_, $i, 1) = '='; } } push(@results, s/=/0+/g ? &_expand_shape($_, 13, 13) : $_); } $logical =~ s/([$Suits])/sprintf "substr(\$_,%d,1)",index($Suits,$1)/gie; $logical =~ s/ ~ / and /; return grep {eval "no strict;$logical"} &_reduce(\@results); } return @results_wo_logical; } sub _staveren_expand { my $shape_list = shift; my $shape; my @stav_results; my $majors = substr($Suits, 0, 2); my $minors = substr($Suits, 2, 2); my ($diamond, $club) = split '', $minors; my ($spade, $heart) = split '', $majors; $shape_list =~ /([^|\#]*m[^|\#]*m[^|\#]*)/ and confess "$1: Multiple not implemented ! (use permuations instead)"; $shape_list =~ /([^|\#]*[$minors][^|\#:]*m[^|\#]*)/ and confess "$1: Multiple not implemented ! (use permuations instead)"; $shape_list =~ /([^|\#]*m[^|\#:]*[$minors][^|\#]*)/ and confess "$1: Multiple not implemented ! (use permuations instead)"; $shape_list =~ /([^|\#]*[$majors][^:|\#]*M[^|\#]*)/ and confess "$1: Multiple not implemented ! (use permuations instead)"; $shape_list =~ /([^|\#]*M[^|\#:]*[$majors][^|\#]*)/ and confess "$1: Multiple not implemented ! (use permuations instead)"; $shape_list =~ /([^|\#]*M[^|\#]*M[^|\#]*)/ and confess "$1: Multiple not implemented ! (use permuations instead)"; $shape_list =~ s/([^|\#]*)m([^|\#]*)/$1$diamond$2|$1$club$2/g; $shape_list =~ s/([^|\#]*)M([^|\#]*)/$1$spade$2|$1$heart$2/g; for $shape (split /[|\#]+/, $shape_list) { push(@stav_results, &_parse_shape($shape)); } return join ' + ', &_reduce( \@stav_results ); } ################################################################################### ############################################ Methods ############################## ################################################################################### sub language { my $self = shift; ref $self && confess "You can use ->language method ONLY on the whole class !"; @_ > 1 && confess "Usage: Class->language(LANG)"; if(@_) { my $lang = shift; my $suits = $SuitLanguage{$lang} or confess "Language $lang not implemented"; $Suits = $suits; $Language = $lang; } return $Language; } sub shape { my $self = shift; (ref $self && @_ < 2) || confess "Usage: Object->shape(SHAPE)"; $self->{SHAPE} = shift if @_; return $self->{SHAPE}; } sub zone { my $self = shift; (ref $self && @_ < 2) || confess "Usage: Object->zone(ZONE)"; $self->{ZONE} = shift if @_; return $self->{ZONE}; } sub to_dealer { my $self = shift; ref $self || confess "Usage: Object->to_dealer()"; @_ && carp "Ignoring Args:: @_ in to_dealer, no options implemented yet !"; return &_staveren_expand($self->shape); } sub new { my $self = shift; ref $self && confess "Cannot call method new on object"; my $dist_ref = {}; $dist_ref->{SHAPE} = undef; $dist_ref->{ZONE} = undef; return bless $dist_ref, $self; } 1; ########################################### ############################ Comments ##### ########################################### # # This is part of a big bridge-package I'm developping and I cannot release yet. # It allows to specify complex types of shapes for a bridge hand, and convert them # into shapes compatible with Hans van Staveren's Dealer program. # # Methods: # Dist->new : creates a Dist-object # Dist->language('English'|'French') : sets the language for suits (shdc or pckt) # Obj->shape('shape') : creates a shape # Obj->to_dealer : produces a list of shape suitable for 'dealer' # Obj->zone : used for another package dealer/Pre_Processors/README.dpp0100644000076400001440000001773710002574545015616 0ustar henkusers### DPP README ### 1/ What is dpp ? ---------------- dpp stands for dealer-pre-processor. Its main purpose it to preprocess input files for Hans van Staveren's great dealer program. 2/ How is it written ? ---------------------- dpp is written in Perl-object. In fact, it was a small part of a package that I will probably never finish to write (a package that should do automatic checking of bidding conventions...). It contains two file: o the executable file 'dpp', o the package 'Dist.pm'. 3/ What do I need to make it work ? ----------------------------------- a/ You need Perl (and anyway, even if you don't plan to use dpp, you probably need perl, with or without knowing it !), b/ You may need to change the first line of dpp, depending on where your perl interpreter is located, and where you plan to install the package file 'Dist.pm'. c/ You need to read this... 4/ What can I do with it ? -------------------------- The greatest idea of Hans van Staveren was his 'shape' function (please reread his manual). The 'shape' function speed is the same for any number of args in it. Unfortunately, there's no convenient way to express ideas like "a balanced shape with 4 in a major". With the regular dealer, you have to write : shape(north,2443 + 2434 + 3424 + 3442 + 3433 + 4243 + 4423 + 4234 + 4432 + 4324 + 4342 + 4333) or, if you are clever : shape(north, any 4432 + any 4333 - 3343 - 3334 - 2344 - 3244) With dpp, you will just write : shape{north, 4M(3+3+2+)} nice isn't it ?? 5/ Differences with the original syntax of shape : -------------------------------------------------- Perl is great. (Repeat after me...) The only thing it misses regarding text-parsing is the hability to handle sexp (in a more general case, I don't recommend having sex-p with a computer ;-). The bad news is that I had to change the parenthesis () into braces {}, because I wanted to use () for other purposes inside the shape-func. The only other difference is that shape doesn't recognize the word 'any' anymore. (I confess I may have kept the old syntax and invent a new word like dist{}. If people complain about this, I may change it... I just wanted to keep HVS-soul alive in my files...) The new general syntax is : shape{COMPASS, shp1 + shp2 + ... + shpM - shm1 - ... - shmN} See below for the atomic (shp or shm) shapes... 6/ Features : ------------- when you see a shape after a '-->' signs, it's the result of a shape after being dp-processed... (a) regular shapes : 7xxx, 4432, 4xx5 have the same meaning as in original dealer. (b) the 'at least' operator : whenever you put a '+' after a suit-length, it means 'at least'. Example: shape{north, 5+xx5+} : at least 5/5 in the blacks, -->shape(north,5xx5 + 5xx6 + 6xx5 + 5xx7 + 6xx6 + 7xx5 + 5008 + 6007 + 7006 + 8005) (c) the 'at most' operator : same as the 'at least', just use a '-' : Example: shape{north, 2-xxx} : at most 2 spades, -->shape(north,0xxx + 1xxx + 2xxx) (d) the 'range' operator : the range operator operates on a single suit. It comes with [], like in Perl. Example: shape{north, x[3-5]x[13]} : (3 to 5) hearts, and one or 3 clubs -->shape(north,x3x1 + x4x1 + x3x3 + x5x1 + x4x3 + x5x3) Note that shape{north, 3-xxx} is equivalent to shape{north,[0-3]xxx} You can write compound ranges if you want : shape{north, [013-68]xxx} means: 0,1,3,4,5,6 or 8 spades. (e) the 'permutation' operator : the permutation operator will appears as () like in the WBF rules of specifying shapes. Example : shape{north, (4432)} : any 4432 hand. -->shape(north,any 4432) what's best is that the () operator can operate on restricted groups of cards : Example: shape{north, 5s(431)} : 5 spades, the others suits being (431). -->shape(north,5134 + 5314 + 5143 + 5341 + 5413 + 5431) What you have to do is : o specify the suit names (s,h,d,c in english) in the left part of the shape, in any order, o and enclose the rest of the permutation into () in the right part. A (complicated) example : shape{north, 4+c3+d(2+2+)} : at least 5 clubs, at least 3 diamonds, and no short major. -->shape(north,3334 + 4234 + 2434 + 3244 + 2344 + 2254 + 3235 + 2335 + 2245 + 2236) (f) the 'Major' operator : has to be used together with the () operator. 'M' stands for 'a major' The 'M' operator can only be used in the left part (never put a M inside the parens) Examples : shape{north, 5M(xxx)} -->shape(north,x5xx + 5xxx) shape{north, 5+M3+c(31)} -->shape(north,1534 + 3514 + 1633 + 3613 + 5134 + 5314 + 6133 + 6313) (g) the 'minor' operator : same as the 'Major' operator, but in lowercase 'm'. Example : shape{north, 5M5m(xx)} -->shape(north,x5x5 + 5xx5 + x55x + 5x5x) (h) the 'conditional' operator : you've got the possibility of specifying complex conditions to be verified that cannot be simply expressed by other operators. In order to do that, you use the ':' operator, just after the atomic-shape specification : shape{north, shp1:condition1,condition2,...} The conditions use the letters (s,h,d,c) as variables for the suit lengths, and the usual C-operators (*,+,-,/,>,<,==,!,?, and so on) Note that the ',' stands for the 'and-logical' operator. You can use 'or' for the 'or-logical' operator. Example: shape{north, 4+s4+h(xx):d>c,h+s==10} -->shape(north,6421 + 6430 + 5521 + 5530 + 4621 + 4630) 7/ Some other examples : ------------------------ a balanced hand : (3+3+3+2+) a french 1H opening : x5+xx:h>s,h>=d,h>=c a michaels (spade+minor) : 5+s5+m(xx) my No_trump opening : hn = hcp(north) n1NT = (hn > 14 and hn < 18 and shape{north, 5m(332) + 5m2s(42)} ) or (hn > 13 and hn < 17 and shape{north, 6m(322)} ) or (hn > 15 and hn < 18 and shape{north, 5M(332)} ) or (hn > 15 and hn < 19 and shape{north, (4432) + (4333)} ) 8/ How to use dpp : ------------------- a/ Unix world : dpp my_input_file | dealer b/ Windows/DOS world : I don't know. I've never used windows/DOS in my life :-). I guess 2 possibilities : (i) 'dpp my_input_file > dppfile' followed by 'dealer dppfile' (ii) Include the dpp code inside the dealer code. Maybe somebody can do that on the next dealer distribution, and add a '-dpp' option to dealer. I won't do it, since I cannot check if that works properly. c/ you can also try some shapes by typing 'dpp' on the command line, and enter shape{} one by one to see how it transforms them. 9/ Languages : -------------- The suit specifications can be made in french or english. The default mode is english. To change the mode, you can do 2 things: (i) add a Dist->language('French'); in dpp (after the Dist->new) (ii) Change the DefaultLanguage value in Dist.pm If somebody wants to add other languages, it's possible... 10/ Bugs and further developments : ---------------------------------- If you : - notice bugs or, - don't understand a peculiar behaviour of dpp (but please reread this README first), - have suggestions for further developments, you can e-mail me at sr007-2@dial.oleane.com On the other hand, if you : - don't understand the *code*, - cannot install perl on your machine, there is unfortunately nothing that I can do for you. Quoting Hans van Staveren : << This program is hereby put in the public domain. Do with it whatever you want, but I would like you not to redistribute it in modified form without mentioning the fact of modification. I will accept bug reports and modification requests, without any obligation of course, but fixing bugs someone else put in is beyond me. When you report bugs please mention the version number in the source files, and preferably send context diffs if you changed anything. I might put in your fixes, and ask Henk to distribute a new version someday. >> Have Fun ! Franois DELLACHERIE sr007-2@dial.oleane.com Paris, FRANCE dealer/Makefile0100644000076400001440000000231210002574543012621 0ustar henkusers# $Header: /home/henk/CVS/dealer/Makefile,v 1.15 1999/08/05 19:57:44 henk Exp $ CC = gcc CFLAGS = -Wall -pedantic -O2 -I. -DNDEBUG -c FLEX = flex YACC = yacc PROGRAM = dealer TARFILE = ${PROGRAM}.tar GZIPFILE = ${PROGRAM}.tar.gz SRC = dealer.c pbn.c c4.c getopt.c pointcount.c LSRC = scan.l YSRC = defs.y HDR = dealer.h tree.h OBJ = dealer.o defs.o pbn.o c4.o getopt.o pointcount.o LOBJ = scan.c YOBJ = defs.c dealer: ${OBJ} ${LOBJ} ${YOBJ} ${MAKE} -C Random lib $(CC) -o $@ ${OBJ} -L./Random -lgnurand clean: rm -f ${OBJ} ${LOBJ} ${YOBJ} ${MAKE} -C Examples clean ${MAKE} -C Random clean tarclean: clean ${YOBJ} rm -f dealer rm -f ${TARFILE} ${GZIPFILE} tarfile: tarclean cd .. ; \ tar cvf ${TARFILE} ${PROGRAM} --exclude CVS --exclude ${TARFILE}; \ mv ${TARFILE} ${PROGRAM} gzip -f ${TARFILE} test: dealer ${MAKE} -C Examples test # # Lex # .l.c: ${FLEX} -t $< >$@ # # Yacc # .y.c: ${YACC} $< mv -f y.tab.c $@ # # C-code # .c.o: ${CC} ${CFLAGS} -o $@ $< # # File dependencies # scan.c: scan.l defs.c: scan.c defs.y dealer.o: tree.h scan.l dealer.h defs.c scan.c pbn.o: tree.h scan.l dealer.h defs.o: tree.h c4.o: c4.c c4.h getopt.o: getopt.h pointcount.o: pointcount.h dealer/MSDOS/0040755000076400001440000000000010002574545012055 5ustar henkusersdealer/MSDOS/VC++6_project_files.zip0100644000076400001440000001052210002574545016232 0ustar henkusersPKfq&&{5M dealer.optsWJ|iKKBs!jNH$%ىv Pֻծm:nx' thbg/Zcˣ8mx:s~{~boWi_Y Yo%#uR N%%cZ$y+CЎ`;Bl/vQC@BACG<OB^BǠ Ӂm7(Bi(?B砗o.2PAC0t }#(4]ơW h3&9y}"TnC 4 `bYq(m:[)zw1U KˮYG[sF썳_cq:YLō?c֦c1&%#ݍm{Rs :[Sr^CPžb%^],4"1    >|#.bl+E qKzi-c$?$uXu6`'mЎȥ,   xҡAl_X\R    P(Gۗz߿b:3}/z=^`1I4'G<h[Xl3'6:ꬌ97F&b ߰W",~=k(sCC&.eUTsaM+75+[tm]s+WnYy7h G9\>w윜+%ǝ;/3XiYjhUu+U75떍j<:ف   xR/Al_nz)s|Z>ܱeY]5 ]I,5 3%R\1SqGS&/\) vH]9_o"r^}UX]ǔ(kk $59@Hwu.q7Ys葮ZpE#\j%hLuNgIjaF^!qc#wlWqS]Z&5L:bTZꪞt$AAA_B0 c.J-  xP /O۔w2KU-c˼/{2$8t2 VʜXq>o,@Z,JqE8#egd,G׿!nK?FӧϞ ށloMƺ~ÛףuBoYGX~Zsr^k޺qoJ\A/_Dzyu\/eO¸ ,7!CWb_o/kUܔڔ eP vàu˂T zcInAGJ W$uB? ܲ#~n,FʐtnAj(!Z=o1_Cg"fBQ' D-5!r}tDCrw B$z=~<}*fU1 J՝l{aSb7?nUOZz0}&^j(:p@bxLY!LS??~{ a?2.#1\I1pniC݇W:X߹8;!Ԥ9V㔄d̘ծ+ md9lMh{uS = >cchC_(nAHs1V~4~ @) PD`~U$rb1qeCF@0sMIÔ 3X"Ͱ `-MEF#lFc`nY##inぺcD3 F5=6[Eђd.e*:v':LbO02A9xѩGuR#):$ N2;ٌu{I 5w85T*ÖpٰyU1ZTǑ"jtܥAZ{4DȔ\_ KMOm'cۃ% h4&B*6LVA>aWu7DBRJ&QuvjŖSNZkӯehw@fۣXlڑbG0䡸^:mnN+#M&ɘÍ[3G-J(l6 4Z_yQΟ 'pǔ`٩ᔡF8qyZzBRzʟMޓ 릧pp/K$ 3I;Y, XeG x[n]g>AV2 ˆneI ~ځz2͙d(nƤ׾teԳƦ0V<D?n҃uһ[Š!l`VK_c"u[Lg5Ψ ¢H6\TFblIҮD *.شӝ澰X۫QND'9 "Si&rGcs^:>#dx/I&(UrRجW)P;5kr$yZ\l0xFGqƯ3@C@Q]bkYhQGv8 1*":/"J?}t4'w RY,0aI17,~8 ޢ*5k3h6Z}EXn&7 x|Ce0MaiZ)t+!,'S\r_a{uWm3Ʉ=g}8c3p50{y=uLUvWKOPKgp&\ dealer.dswAO@$iZꁔ&DJ,R.4ص,'=y(4o&3p/$ dGU3 6Q%!5]#d:lɴ5puO(^$bCQ" QBY FLlXL&ߨ\L+RsvgTmU+A~x:}o[0 ךvs3>7PKfq&&{5M dealer.optPKgp&9<k  u dealer.dspPKgp&\  dealer.dswPKdealer/MSDOS/README0100644000076400001440000000207110002574545012732 0ustar henkusers This directory contains bits and pieces needed to compile the program under MSVC 5.x and 6.x, submitted by Paul Baxter. I have not tested this stuff, as I don't have access to a machine with MSVC. Henk Uijterwaal ----------------------------------------------------------------------------- Files in this area. Makefile-MSDOS A makefile for MSDOS, replace the makefile in the top level directory by this one to compile under MSDOS cygtest.bat Shell-scripts to run the program under DOS. ddostest.bat dostest.bat readme_mods.txt A file describing the changes for MSVC, by Paul Baxter. VC++5_project_files.zip MSVC project files for VC++ version 5. VC++6_project_files.zip MSVC project files for VC++ version 6. Unzip the file for the version of VC++ that you are using, in order to create: * dealer.dsp * dealer.dsw * dealer.opt dealer/MSDOS/cygtest.bat0100644000076400001440000000047710002574544014233 0ustar henkusers @echo off rem This file assumes that the main executable is one dir higher echo Test Results log echo . echo Creating test log file for RELEASE? CYGWIN code echo Ideally this will be part of a redirected output file echo . echo This may take a while! echo . for %%A in (Descr*.*) do ..\dealer %%A dealer/MSDOS/dostest.bat0100644000076400001440000000047410002574544014233 0ustar henkusers @echo off rem This file assumes that the main executable is one dir higher echo Test Results log echo . echo Creating test log file for RELEASE DOS code echo Ideally this will be part of a redirected output file echo . echo This may take a while! echo . for %%A in (Descr*.*) do ..\mdealer %%A dealer/MSDOS/ddostest.bat0100644000076400001440000000047310002574544014376 0ustar henkusers @echo off rem This file assumes that the main executable is one dir higher echo Test Results log echo . echo Creating test log file for DEBUG DOS code echo Ideally this will be part of a redirected output file echo . echo This may take a while! echo . for %%A in (Descr*.*) do ..\mddealer %%A dealer/MSDOS/readme_mods.txt0100644000076400001440000000522610002574545015077 0ustar henkusersFrom: Paul Baxter email: paje@globalnet.co.uk PURPOSE Put together a few batch files for the various versions I have. dealer.exe - cygwin release version Use cygwin.bat mdealer.exe - MSDOS release version Use dostest.bat mddealer.exe - MSDOS debug version Use ddostest.bat Copy any of the Descr.* example files into this (MSDOS) directory. The batch files will run through each Descr.* file in turn. I thought this would be a crude initial step towards ensuring new versions produce same results as old, or that different computer systems produce similar results. Maybe use this test dir with examples and appropriate results to 'validate' new versions. I would prefer that the tests were in a separate dir to the MSVC project files but that's up to Henk. When I refer to the 'test' dir it is currently dealer/MSDOS dir USAGE For the dos programs I have batch files dostest and ddostest (extra d for debug) Similarly for cygtest Put any Descr*.* input files in the test dir cd to it FROM DOS PROMPT type: dostest to run all files through mdealer (o/p to stdout) or type: command.com /c dostest >file.log to redirect to a file. (Output will not be visible) (Have to use a new dos shell in order to redirect the output of a batch file) similarly use 'ddostest' instead of 'dostest' to exercise the debug DOS version These batch files assume executables are one dir higher than test dir If you have put the executables on your Path or have renamed the files edit the batch files as appropriate Also try with cygtest (must have cygwin dll in path etc.) cygtest Results of the three log files appear similar in probabilities etc. So maybe the Dos version can give your analysis a 30% boost in performance! FROM CYGWIN SHELL PROMPT Will need to explicitly add .bat and possibly begin command with ./ to indicate the file is in current dir type: ./dostest.bat or command.com /c dostest.bat >file.log PROBLEMS See my notes in main dir regarding problem with Descr.Stayman in debug version SPEED COMPARISON Release DOS executable seems about ~50-80% faster than Cygwin ver Debug DOS is about 50% slower than Cygwin Mileage may vary (Descr.blue_team modified to run a bit longer) Times: 12 sec on Win release 20 sec on Cygwin 30 sec on Win debug CONCLUSIONS It would be useful to collect a few simulation files to do the following: 1) Exercise all features of dealer 2) Generate some standard sims where results are known. Can check that dealer gets the answers right. dealer/MSDOS/VC++5_project_files.zip0100644000076400001440000001100110002574544016221 0ustar henkusersPKB&V 4 dealer.dspWmo8^a.{$^B˛*ENbĎ줥~y)ݣauRQgƞF̓BE ]@Q vLTC~1 i) 4p<%=YRE?S  I S{Z8Cw`3==o۩5X_J V#1P]Wumdu,~Y[0_1E H|=] )XEyYƣgC *Q(XHF9 x" AdK%3Esy+H¨ xO|L++Nf)}ykmH+' X<%kFm2۵7LRZ Q x;-"QhFJ5ksy/#~*ZvtxYzb:L;6[_6[%3@ T8^o۝z*O ev KjJyLQ]3"ܿJNzA\,WA:@1eBnjEwc$.ghzQ>xG%zR1 ^.& 1_*sxT5g7;Q\-|'K<$n S3L}ӞZyQםï"1*5Ԭ9YˮkY}\yEǮyLvH( 3Pk]qިfF7nsۅPyn0vцQ#[%9s|UH3߈kR]T;/kl&{|pwhDz4aͬc5 "sA,|oE }<52/ uj,XDёO k+FuCOW)=PKu&M dealer.dswOo@$|^T/DLLY,QY\zkCBwjO;͛L~۪0{ ~HsMi]VͮUA*M#lT2M{̜ĶȗIF+D$3? b#29Ld' ܈:ΓO*Z&3׫rʦ*v {2|7ޮl_Op7xsPK&R5 dealer.opt]oWƮ=y8 ۅIvv^&!NI1 3gqPHR>Q!"HP7 $$@bΝ;3Ƒ/:;w9w3;o?9'甤6%Rc틋n#0oI-``bkkSy`PvWAC`(` 6 O= X'XaOIQKe`=``%$lO{,xa+ ] ,FF>66)a{vؓ`mL( y #a* VLi?GODzQ2pQ4EW(d5'JF]] ~?;r?Dg<ħPZ?v*M q$[$b(&+\lJ(Z}o1fQ`>7*|NA22A-qzl lڦ]&idf㲧ԲSG1/9Gi\u5d619)n>y͙EIXPJ'@iaUzɉǘʼnҜ֖9V2=}+ =$%_*8iK+sbeF2#$S% WIf/*ha|=?6:96< ߍ'8f8 _&F]dt_Yim8Iƨ+ؿeyN2޵{xԵ>Yz(?68HM{vу&Z=i,*DŲaҼisaefiNH3 TKZ WM#5JzHxuYu9,\w:K2Z ܣ.WT1J9PhiP0.U/J*rX Z*Xs#>A1c`s5RXpvAG2 sT cɩK#S㽽}=K#r.99VLh*Sׯ~! r7T) 52t gcjOR%_q21}KN:eTx- Vz*R #^!wo #^)FƟx] :b qZ_Xj`U i #g{rsa:jtꨵm: ]'O jMJ*&h>ZV`>!\Wg15 Du<00gϊf٦FjZHտ uEU|` &tG0S|)sgjyvbsN3Ἴ- Js{H?$_qGW8΄伖|=!K799y#G8ۃOo83~ lfg_&ߊ¦q~~9;N|/ipIHnȻ +'I%Q"NK;>g nxEYo_@?. neCU\>!iY,۲ `/*Zx5SOPC?6))͍V;(ڊA ?P?R.*b+ՐRY#ExH(ķ+}p=Z9D{zOD5}\Q0ut$~Riݖ4ίtĹ뎀BtA|AӢu'Yh:%3G!&=GC.Ѱ3م!{ջ@52{\b*$#G['a22`ϙ.E>H.sɅihvMH9Aa %#= f/꿨/꿨ցo"~j1R>1LE@*yeT-M,{ƿ76oVq,ʧ n2*^x(9gGC-U˅^5[-V?t"crFq ]f,iUҠ0J@j-i`QX\Q 0ngJ{)tHIjcs)]2וBȌiJȊV5HVpJuu?FHB"ڄB$'~}x;,2NnlE!^/ [%ed3FPC?PC?P;!5?bs#ϋ~eLZTQC?PC?6T@ VFAJI*eg/ 쾇^/a|mS:w(MV؊?`"??h//7xKG!Esif=u@s8&HYv{XYl z %#&,ȓDޥ¬٧srdd!}&Z-mZaBX0,Zp[գiWnoԉsUL0nF۟}-~V 5Bs7h1#j3sHCW!)iPRZ OR C6xcժ @1]:pv1y-66MIOgI~a7=hl=)nH$AKv[bRCJc.)wЭƽO$`I(ȠZ! ?dP@5+w8ģ;^[Y%mM!u(rlBQ+ Ҩ3$( K/꿨nLo"$@ # # Yacc # .y.c: ${YACC} $< mv -f y.tab.c $@ # # C-code # .c.o: ${CC} ${CFLAGS} -o $@ $< # # File dependencies # scan.c: scan.l defs.c: scan.c defs.y dealer.o: tree.h scan.l dealer.h defs.c scan.c pbn.o: tree.h scan.l dealer.h defs.o: tree.h c4.o: c4.c c4.h dealer/pbn.c0100644000076400001440000000451610002574544012115 0ustar henkusers/* This routine prints a hand in PBN format Added by Henk Uijterwaal, Feb 1999 */ #include #include #include "tree.h" #include "dealer.h" #include "pbn.h" extern long seed; extern char* input_file; int printpbn (int board, deal d) { /* Symbols for the cards */ char representation[] = "23456789TJQKA"; /* Mnemonics for vulnerability and dealer */ char *vulner_name[] = { "None", "NS", "EW", "All" }; char *dealer_name[] = { "N", "E", "S", "W" }; /* Who's vulnerable on which boards */ int board_vul[] = { 0,1,2,3, 1,2,3,0, 2,3,0,1, 3,0,1,2 }; /* Local variables */ time_t timet; size_t len; char timearray[12]; int player, suit, rank; /* Suppress verbose output unless we really want it */ verbose ^= 1; printf ("[Event \"Hand simulated by dealer with file %s, seed %lu\"]\n", input_file, seed); printf ("[Site \"-\"]\n"); /* Today's date */ timet = time(&timet); len = strftime (timearray, 12, "%Y.%m.%d", localtime(&timet)); printf ("[Date \"%s\"]\n", timearray); printf ("[Board \"%d\"]\n", board+1); /* Blank tags for the players */ printf ("[West \"-\"]\n"); printf ("[North \"-\"]\n"); printf ("[East \"-\"]\n"); printf ("[South \"-\"]\n"); /* Dealer, rotates unless set by the user */ if ((maxdealer < 0) || (maxdealer > 3)) { printf ("[Dealer \"%s\"]\n", dealer_name[board%4]); } else { printf ("[Dealer \"%s\"]\n", dealer_name[maxdealer]); } /* Vulnerability, rotates unless set by the user */ if ((maxvuln < 0) || (maxvuln > 3)) { printf ("[Vulnerable \"%s\"]\n", vulner_name[board_vul[board%16]]); } else { printf ("[Vulnerable \"%s\"]\n", vulner_name[maxvuln]); } /* Print the cards */ printf ("[Deal \"N:"); for (player=COMPASS_NORTH; player<=COMPASS_WEST; player++) { for (suit = SUIT_SPADE; suit>= SUIT_CLUB; suit--) { for (rank=12; rank >= 0; rank--) { if (HAS_CARD(d, player, MAKECARD(suit,rank))) { printf ("%c", representation[rank]); } } if (suit > SUIT_CLUB) { printf (".");} } if (player < COMPASS_WEST) {printf (" ");} } printf ("\"]\n"); /* Blank tags for declarer etc */ printf ("[Declarer \"?\"]\n"); printf ("[Contract \"?\"]\n"); printf ("[Result \"?\"]\n"); printf ("\n"); return 0; } dealer/pbn.h0100644000076400001440000000011210002574544012106 0ustar henkusers#ifndef PBN_H #define PBN_H int printpbn (int, deal); #endif /* PBN_H */ dealer/Manual/0040755000076400001440000000000010055171403012377 5ustar henkusersdealer/Manual/running.html0100644000076400001440000000205210002574543014745 0ustar henkusers Running the program

Running the program

Running the program is easy. On your Unix machine, or the Cygwin prompt under Win/NT or Win/98, type: This will start the program, read the Input_file and print the output on your screen. Alternatively, you can use: This will write the output to a file "Output_file".

The input_file argument can also be passed to the program in the normal way, instead of being used for input-redirection:


dealer/Manual/authors.html0100644000076400001440000000274610002574543014764 0ustar henkusers Authors

Authors

Code maintainer

The current code maintainer is:
Henk Uijterwaal
henk@ripe.net

dealer/Manual/preproc.html0100644000076400001440000002126710002574543014750 0ustar henkusers Pre-Processors

Pre-Processors

The pre-processor directory contains code that can be used to generate input for dealer. Currently there is only 1 contribution, DPP by Francois Dellacherie.

DPP

François Dellacherie

1. What is dpp ?

dpp stands for dealer-pre-processor. Its main purpose is to preprocess input files for Hans van Staveren's great dealer program.

2. How is it written ?

dpp is written in Perl-object. In fact, it was a small part of a package that I will probably never finish to write (a package that should do automatic checking of bidding conventions...).

It contains two file:

  • the executable file 'dpp',
  • the package 'Dist.pm'.

3. What do I need to make it work ?

  • You need Perl (and anyway, even if you don't plan to use dpp, you probably need perl, with or without knowing it !),
  • You may need to change the first line of dpp, depending on where your perl interpreter is located, and where you plan to install the package file 'Dist.pm'.
  • You need to read this...

4. What can I do with it ?

The greatest idea of Hans van Staveren was his 'shape' function (please reread his manual). The 'shape' function speed is the same for any number of args in it. Unfortunately, there's no convenient way to express ideas like "a balanced shape with 4 in a major". With the regular dealer, you have to write :
shape(north,2443 + 2434 + 3424 + 3442 + 3433 + 4243 + 4423 + 4234 +
                 4432 + 4324 + 4342 + 4333)
or, if you are clever :
shape(north, any 4432 + any 4333 - 3343 - 3334 - 2344 - 3244)
With dpp, you will just write :
shape{north, 4M(3+3+2+)}
nice isn't it ??

5. Differences with the original syntax of shape:

Perl is great. (Repeat after me...)

The only thing it misses regarding text-parsing is the hability to handle sexp (in a more general case, I don't recommend having sex-p with a computer ;-). The bad news is that I had to change the parenthesis () into braces {}, because I wanted to use () for other purposes inside the shape-func. The only other difference is that shape doesn't recognize the word 'any' anymore.

(I confess I may have kept the old syntax and invent a new word like dist{}. If people complain about this, I may change it... I just wanted to keep HVS-soul alive in my files...)

The new general syntax is :

shape{COMPASS, shp1 + shp2 + ... + shpM - shm1 - ... - shmN}
See below for the atomic (shp or shm) shapes...

6. Features:

when you see a shape after a » signs, it's the result of a shape after being dp-processed...
  1. regular shapes : 7xxx, 4432, 4xx5 have the same meaning as in original dealer.
  2. the 'at least' operator : whenever you put a '+' after a suit-length, it means 'at least'.
  3. Example: shape{north, 5+xx5+} : at least 5/5 in the blacks, »shape(north,5xx5 + 5xx6 + 6xx5 + 5xx7 + 6xx6 + 7xx5 + 5008 + 6007 + 7006 + 8005)

  4. the 'at most' operator : same as the 'at least', just use a '-' :

    Example: shape{north, 2-xxx} : at most 2 spades, »shape(north,0xxx + 1xxx + 2xxx)

  5. the 'range' operator : the range operator operates on a single suit. It comes with [], like in Perl.

    Example: shape{north, x[3-5]x[13]} : (3 to 5) hearts, and one or 3 clubs »shape(north,x3x1 + x4x1 + x3x3 + x5x1 + x4x3 + x5x3)

    Note that shape{north, 3-xxx} is equivalent to shape{north,[0-3]xxx} You can write compound ranges if you want : shape{north, [013-68]xxx} means: 0,1,3,4,5,6 or 8 spades.

  6. the 'permutation' operator : the permutation operator will appears as () like in the WBF rules of specifying shapes. Example :

    shape{north, (4432)} : any 4432 hand. »shape(north,any 4432)

    what's best is that the () operator can operate on restricted groups of cards :

    Example: shape{north, 5s(431)} : 5 spades, the others suits being (431). »shape(north,5134 + 5314 + 5143 + 5341 + 5413 + 5431)

    What you have to do is :

    • specify the suit names (s,h,d,c in english) in the left part of the shape, in any order,
    • and enclose the rest of the permutation into () in the right part.
    A (complicated) example : shape{north, 4+c3+d(2+2+)} : at least 5 clubs, at least 3 diamonds, and no short major. »shape(north,3334 + 4234 + 2434 + 3244 + 2344 + 2254 + 3235 + 2335 + 2245 + 2236)
  7. the 'Major' operator : has to be used together with the () operator. 'M' stands for 'a major' The 'M' operator can only be used in the left part (never put a M inside the parens)

    Examples :
    shape{north, 5M(xxx)} »shape(north,x5xx + 5xxx)
    shape{north, 5+M3+c(31)} »shape(north,1534 + 3514 + 1633 + 3613 + 5134 + 5314 + 6133 + 6313)

  8. the 'minor' operator : same as the 'Major' operator, but in lowercase 'm'.

    Example : shape{north, 5M5m(xx)} »shape(north,x5x5 + 5xx5 + x55x + 5x5x)

  9. the 'conditional' operator : you've got the possibility of specifying complex conditions to be verified that cannot be simply expressed by other operators. In order to do that, you use the ':' operator, just after the atomic-shape specification : shape{north, shp1:condition1,condition2,...}

    The conditions use the letters (s,h,d,c) as variables for the suit lengths, and the usual C-operators (*,+,-,/,>,<,==,!,?, and so on) Note that the ',' stands for the 'and-logical' operator. You can use 'or' for the 'or-logical' operator.

    Example: shape{north, 4+s4+h(xx):d>c,h+s==10} »shape(north,6421 + 6430 + 5521 + 5530 + 4621 + 4630)

7. Some other examples:

  • A balanced hand : (3+3+3+2+)
  • A french 1H opening : x5+xx:h>s,h>=d,h>=c
  • a michaels (spade+minor) : 5+s5+m(xx)
  • my No_trump opening :

  • hn = hcp(north)
    n1NT = (hn > 14 and hn < 18 and shape{north, 5m(332) + 5m2s(42)} ) or
    (hn > 13 and hn < 17 and shape{north, 6m(322)} ) or
    (hn > 15 and hn < 18 and shape{north, 5M(332)} ) or
    (hn > 15 and hn < 19 and shape{north, (4432) + (4333)} )

8. How to use dpp:

  1. Unix world: dpp my_input_file | dealer
  2. Windows/DOS world: I don't know. I've never used windows/DOS in my life :-). I guess 2 possibilities :
    1. 'dpp my_input_file > dppfile' followed by 'dealer dppfile'
    2. Include the dpp code inside the dealer code. Maybe somebody can do that on the next dealer distribution, and add a '-dpp' option to dealer. I won't do it, since I cannot check if that works properly.
  3. you can also try some shapes by typing 'dpp' on the command line, and enter shape{} one by one to see how it transforms them.

9. Languages:

The suit specifications can be made in french or english. The default mode is english. To change the mode, you can do 2 things:
  • add a "Dist->language('French');" in dpp (after the Dist->new)
  • Change the DefaultLanguage value in Dist.pm
If somebody wants to add other languages, it's possible...

10. Bugs and further developments:

If you :
  • notice bugs or,
  • don't understand a peculiar behaviour of dpp (but please reread this README first),
  • have suggestions for further developments,
you can e-mail me at sr007-2@dial.oleane.com

On the other hand, if you :

  • don't understand the *code*,
  • cannot install perl on your machine,
there is unfortunately nothing that I can do for you.

Quoting Hans van Staveren :

This program is hereby put in the public domain. Do with it whatever you want, but I would like you not to redistribute it in modified form without mentioning the fact of modification. I will accept bug reports and modification requests, without any obligation of course, but fixing bugs someone else put in is beyond me.

When you report bugs please mention the version number in the source files, and preferably send context diffs if you changed anything. I might put in your fixes, and ask Henk to distribute a new version someday.

Have Fun!
François Dellacherie
Paris, FRANCE

dealer/Manual/perf.html0100644000076400001440000000316210002574543014224 0ustar henkusers Performance

Performance

The speed of the program obviously depends on the machine it runs on and how complicated the problem is. Last time the program was systematically benchmarked (a couple of major versions ago), these were some results:
  • On Hans' home machine, a SparcStation 1+, it generates about 4000 hands a second if the condition is not too complicated. As he rarely plays more than 150 hands a week, he can generate all the boards for a year in less than 2 seconds.
  • The Descr.test_dealer example, which generates 1,000,000 hands and keeps track of some 72 frequencies, takes about 5.2 minutes, or some 3100 hands/second, on Henk's laptop (a PII/266 with 32 Mb, running RedHat Linux 5.2). The program was compiled with the -g flag.
  • Recompiling with the -O2 flag reduces this to 2:40 minutes or 6250 hands/second.
  • Removing all frequencies but one (e.g. just generating the 1,000,000 hands) reduces this to 26 seconds or 37000 hands/second.
  • Recompiling with the -O2 flag reduces this to 18.4s or 55000 hands/second.

If the "tricks" function is used, the run-time will be, by far, dominated by the time GIB takes to analyze the double-dummy deal result, which can run from half a second to several seconds per analyzed deal, in any case orders of magnitude more than other parts.


dealer/Manual/updates.html0100644000076400001440000000770310055171403014736 0ustar henkusers Updates and Modifications

Updates and Modifications

  • March 13, 1999 (HU): Created this list.
  • March 13, 1999 (HU): Moved all examples to a separate directory, added a perl script that runs them all.
  • March 13, 1999 (HU): Started on this manual.
  • March 19, 1999 (HU): Moved GNU random code to a separate library
  • April 11, 1999 (HU): Added GPL to random code dir.
  • April 11, 1999 (Robin Barker, HU): Added post-processor code.
  • April 18, 1999 (HU): Moved code under CVS.
  • April 18, 1999 (HU): Inserted code from Danil Suits, Paul Hankin, Micke Hovmoller. Released Alpha version of all this.
  • April 22, 1999 (HU): Clean-up of the code, reduced the number of warnings on compilation from 3 screens, to half a page.
  • June 13, 1999 (??): Patches from Alex Martelli, MSVC support from Paul Baxter, put together another release.
  • June 19, 1999 (HU): Incorporated bug fixes from Danil Suits, manual updates from Alex Martelli, more fixes for MSDOS by Paul Baxter.
  • July 1, 1999 (HU):
    • New version of exhaust mode from Francois,
    • Macros instead of function calls whenever possible.
    • Preprocessor code from Francois.
    • Better code for calculating HCP (etc.) from Danil.
    • Updates for defs.y from Danil.
    • Clean-up to reduce warnings.
    • Reference output for the examples.
  • July 5, 1999 (AM):
    • Key issue: a line (the body of a while loop!) had mysteriously disappeared from defs.y, causing several problems with printes/printoneline
    • Lesser issue: a long-standing syntax glitch caused all input of the form "-" followed by a digit to be interpreted as a single token, thus mandating a separating spaces in non-obvious places, e.g.: "spades(south)-2" would be an error, "spades(south)- 2" correct. I fixed that by removing from scan.l the lexical production for negative number and adding "ARMINUS NUMBER" to defs.y for nonterminal "number"; shift/reduce conflicts go up from 9 to 16 but I don't think that breaks anything (I'm not sure how to test for this specifically).
    • Sundry stuff: some clarifications & error fixes in the manual HTML files.
  • July 7, 1999 (DS): Macro for hascard() and interesting() to reduce the number of ifdef's.
  • July 13, 1999 (HU): Review of manual.
  • August 3, 1999 (HU): Included defs.c in the distribution (for people that don't have yacc on their machine). Removed libgnurand.a from the distribution, the binary doesn't belong in there. Added a few comments about compiling to the manual.
  • August 21, 1999 (HU): Check range for -s value, rotate dealer in pbn output, suggestions from Alan Jaffray (jaffray@pobox.com). Print board number in printall output, suggested by Thorvald Aagaard (aagaard@webtrade.dk).
  • May 26, 2004 (HU): Finally found time for this again.
    • Made it compile without warnings on GCC 3.3.1
    • Instructions for compiling on Darwin

dealer/Manual/index.html0100644000076400001440000000516510002574543014404 0ustar henkusers DEALER, a bridge hand generator program

DEALER, a bridge hand generator program

Description

The program dealer can be used to generate hands for partnerships bidding training or for generating statistics that can be used to design conventions, or win postmortems.

Running the program involves 3 steps. First, the user has to write an input file containing hand-descriptions and action. A very simple example would look something like:

condition shape(north, any 4333 + any 4423) and hcp(north)>=19
action printall
The first 2 lines specify a condition for the north hand, in this case, a hand with 4333 or 4432 shape and at least 19 high card points. The last 2 lines tell the program to print the 4 hands. The program reads from standard input, so in principle, it is possible to enter the conditions directly into the program. Using a file is a lot more practical though, as it allows the user to re-use conditions and fine-tune the conditions.

Then the program has to be run, it reads the file, looks at the various command line switches and then produces a number of hands. The output appears on the screen but can be re-directed to a file.

Finally, the user has to look at output and analyze the produced hands. Alternatively, the output can be used for a playing program.

Warning

Dealer is meant for relatively complex use. If you just want to deal hands for a tournament Hans has written totally different code. You can find it at www.xs4all.nl/~sater. If you use other programs now to deal hands for tournaments please read the documentation of Big Deal. You will be convinced and switch.

Index

  • Read this first
  • Copyright
  • Authors
  • Downloading and installation
  • Using the program
  • Performance
  • Bug reports and submitting new code
  • Updates and modifications

  • dealer/Manual/bugs.html0100644000076400001440000001170310002574543014230 0ustar henkusers Bug reports, submitting code and all that

    Bug Reports

    If you suspect a bug in the program:
    • Double-check your input file.
    • Try to reduce your input file to the absolute minimum that still produces the bug. The cleaner the example, the easier it is to debug.
    • Think again if your problem really is a bug.
    • If so, then it is time to send in a bug-report.
    • Send an email to the code maintainer that includes:
      • The (reduced) input file that produced the error.
      • All command-line arguments when the bug was produced,
      • What went wrong and why you think this is a problem.
      • The output of running dealer with the -V flag. This will produce something like:
        Version info....
        $Revision: 1.1 $
        $Date: 1999/07/19 20:24:32 $
        $Author: henk $
        Include this information in your bug-report. This uniquely defines the version of the code that produced the bug.

        If a problem did not occur with a previous version of the program, do a dealer -V on that version as well.

      • The platform and operating system that you are using.
      • The compiler that you used to compile the program. If you modified the Makefile, include that as well.
    • If you think that problem is caused in the code from a particular contributer, send him a copy of your mail.
    • Note that dealer is free and comes without any guarantee. Bugs will be investigated and might be fixed, but all authors work on this on a voluntary basis in their spare time, so do not expect any service.

    Submitting Code

    Besides submitting bugs, you can also contribute towards dealer by providing code that extends the functionality of the program.

    Before modifying the source code, first check if you can solve your problem with a cleverly written input file and how often you would need a function. Changing the code (and testing it) does take a lot of time.

    When modifying the code, you should realize that you are on your own. Other authors may be able to help you, but do not count on it. And do not even think about submitting code that almost works but that still needs a few all-night debugging sessions.

    Once you are happy with your code, consider if you should submit them for inclusion in the "official" source tree. In general, only submit changes that add functionality to the code. If your code is incompatible with existing features, then do not remove it but instead put "#ifdef's" into the code so that users can select the appropriate pieces of code and still be able to run their existing input files.

    When submitting code, please follow the following guidelines in order to keep the code maintainer happy:

    • Try to make your changes against the latest version of the code.
    • Test your code, at a very minimum:
      • Write an example that use the features of your code.
      • Try to test your code in combination with as many existing features as possible.
      • Run a make test in the Examples directory and make sure that the existing examples still work as before. If they do not work as they used to do, carefully check if the output is still correct and document the changes.
    • Provide documentation:
      • Put comments in your code.
      • Update the manual if you change something.
      • Include an example that uses the features of the new code and include the output of the example. This makes it easier to check if your changes have been included correctly.
    • In order to make code management easy, please observe the following rules:
      • Do not change the layout of the code because you do not like the style. This makes it a lot harder when merging updates from several sources into one source file.
      • Do not use tabs, use spaces. (Tabs may expand to different amounts of white space from one machine to another, thus making it hard to understand the code).
      • Always do a dealer -V before submitting the code and include that information, but never update the strings that produce the version info in the source. The code management system will take care of that.
      • I do not really care if you submit complete source files or just diffs, but do not submit source files that have not been modified.

    dealer/Manual/manual.html0100644000076400001440000000404510002574543014546 0ustar henkusers DEALER, a bridge hand generator program

    DEALER, a bridge hand generator program

    Description

    The program dealer can be used to generate hands for partnerships bidding training or for generating statistics that can be used to design conventions, or win postmortems.

    Running the program involves 3 steps. First, the user has to write an input file containing hand-descriptions and action. A very simple example would look something like: A simple example:

    condition shape(north, any 4333 + any 4423) and hcp(north)>=19
    action printall
    The first 2 lines specify a condition for the north hand, in this case, a hand with 4333 or 4432 shape and at least 19 high card points. The last 2 lines tell the program to print the 4 hands. The program reads from standard input, so in principle, it is possible to enter the conditions directly into the program. Using a file is a lot more practical though, as it allows the user to re-use conditions and fine-tune the conditions.

    Then the program has to be run, it reads the file, looks at the various command line switches and then produces a number of hands. The output appears on the screen but can be re-directed to a file.

    Finally, the user has to look at output and analyze the produced hands. Alternatively, the output can be used for a playing program.

    Index

  • Read this first
  • Copyright
  • Authors
  • Downloading and installation
  • Using the program
  • Performance
  • Updates and modifications
  • dealer/Manual/output.html0100644000076400001440000000163210002574543014630 0ustar henkusers Running the program

    Using the output

    Usually, you will just look at the hands generated and analyze them by hand. There are a few other options though:

    1. Reformatting the output

    In the "Post_processors" directory, you'll find tools to reformat the output. Currently there is only 1 contribution, pbn_to_ascii.pl, meant to be used as follows:
    • pbn_to_ascii.pl <pbn_file or
    • dealer <input_file | pbn_to_ascii.pl
    This will take the PBN output and convert it into a newspaper-style diagram. pbn_to_ascii.pl uses the Perl5 language and was written by Robin Barker.
    dealer/Manual/download.html0100644000076400001440000001100210055170540015064 0ustar henkusers Downloading and Installation

    Downloading and installation

    Click here to download the code. This is a so-called gzipped tar file. To install the program on any Unix platform, do:
    • gzip -dc dealer.tar.gz | tar xvf -
    • cd dealer
    • make
    And you should end up with the dealer executable in your current working directory. Then test the program with
    • cd Examples
    • make test
    This will process all examples in the Examples directory, store the output for visual inspection and compare the output against a reference copy of the output. The output from the test typically starts with:
    test_dealer.pl
    ------------------------------------------------------------------
    Now processing Descr.6c
    Done, output in Output.6c
    Comparing against reference output from Refer.6c
    6c6
    < Time needed  25.55 sec
    ---
    > Time needed  12.99 sec
    ...And so on for other examples...
    
    The example that was run was "Descr.6c", output of this example can be found in "Output.6c". Comparing the output against the reference output showed 1 difference: the CPU time that was needed to process the input file. The example took 25.55s when it was just run, the machine where the reference copy was produced needed only 12.99 seconds.

    This particular difference is, of course, harmless, as the CPU time needed to process an example varies from computer to computer. Other differences that can be safely ignored are the dates in the PBN example. However, if the program had crashed on this example, the output from the test had started with:

    test_dealer.pl
    ------------------------------------------------------------------
    Now processing Descr.6c
    Done, output in Output.6c
    Comparing against reference output from Refer.6c
    0a1,6
    > king drops: 0.573465
    > finesse: 0.749792
    > Generated 1000000 hands
    > Produced 110556 hands
    > Initial random seed 1
    > Time needed  12.99 sec
    
    and it would be time to start debugging.

    The exhaust mode is still under development. By default, it is switched off. To include the code, edit the Makefile and change the line:

    • CFLAGS= (...) -DNDEBUG
    into
    • CFLAGS= (...) -DNDEBUG -DFRANCOIS

    Problems when compiling

    • Not all versions of make support the -C flag. If this happens on your system, edit the Makefile and replace all lines:
      ${MAKE} -C directory action
      by
      cd directory ; make action
    • Mike Zimmermann reported that on MAC OS X (aka Darwin), the line CFLAGS has to be:
      • CFLAGS= -g -DNDEBUG -DFRANCOIS -I.

    Portability

    The program has been developed under SunOS on Sun hardware. I (Hans) am a reasonably competent programmer though, and I expect the program to be highly portable. The most suspect part is in the initialisation of the random number generator. The system call used here might need to be changed on other OSes.

    There has been a DOS and OS/2 port by Pedl Rau. I tested the speed at about 9000 hands a second on my 486DX33. Note: this has been superseeded by the work from (a.o.) Paul Baxter, Alex Martelli and Danil Suits.

    Henk Uijterwaal has compiled his version under Linux (2.0.x and 2.2.x) without any problem, except that one needed to do:

    ln -s /usr/bin/flex /usr/bin/lex
    as flex has succeeded lex on Linux. On Ultrix, DEC Alpha(OSF), BSDI/3.x and SGI, the program compiled without any problem.

    A. Martelli (alex@magenta.com) used to build and run Dealer on Win/NT and Win/98 with the free Cygwin GCC C/C++ compiler and Unix emulation environment. Main changes needed were byacc instead of yacc, as well as flex instead of lex, in the Makefile. A Makefile with all these changes is available in the MSDOS subdirectory.

    Dealer's latest versions build and run fine using Microsoft Visual Studio 5 and 6 (still using byacc and flex if needed for syntax mods, but with no other known dependency on Cygwin); there is a current dependency on the Winsock2 DLL (for ntohs, ntohl functions) soon to be removed.


    dealer/Manual/index.gif0100644000076400001440000000026410002574543014200 0ustar henkusersGIF89a+ooo[!,+0ڋV"Qy ʒ5q Lׯ5=kUb"+^p8L &yybW+w[oUbw\左]a_)gƃtǥC4hز()⁙ٹ*:Z;dealer/Manual/prev.gif0100644000076400001440000000033410002574543014043 0ustar henkusersGIF89a?ooo[!,?I޼j~㕶.Lq6z Hir"?$`)|J{Č\vSUM߬95[0Er5WxEWeCxhyfFfY)'#؈:+H4{[3 , Read me first

    Hans van Staveren's original README file

    This program is hereby put in the public domain. Do with it whatever you want, but I would like you not to redistribute it in modified form without mentioning the fact of modification. I will accept bug reports and modification requests, without any obligation of course, but fixing bugs someone else put in is beyond me.

    When you report bugs please mention the version number in the source files, and preferably send context diffs if you changed anything. I might put in your fixes, and distribute a new version someday.

    I would prefer if you did *not* use this program for generating hands for tournaments. I have not investigated the random number generation closely enough for me to be comfortable with that thought.

    (Note: random number generation has been significantly improved since the original release, for which this disclaimer was written; check the source code for more details).

    	Hans van Staveren
    	Amsterdam
    	Holland
    	
    

    dealer/Manual/input.html0100644000076400001440000005672210002574543014441 0ustar henkusers The Input File

    The Input File

    Basic Layout

    The basic lay-out of the file is:
     command1 "parameters for command 1"
     command2 "parameters for command 2"
     ...
     condition "list of conditions"
     action "list of actions"
    
    The exact format is free, as long as it is unambigous, the program will understand it; in other words, lines can be broken freely, wherever it is desired to do so. Any line starting with a #-sign is regarded as a comment and ignored.

    Comments can also be placed at the end of any line, from a marker of "//" all the way to the end of the line; or, independent of line structure, by starting the comment with a marker of "/*" and ending it with a marker of "*/".

    Lexical structure

    All the words recognized by the program act as keywords, that is, reserved words -- you cannot use those words as identifiers for other purposes, or you will get a syntax error.

    For many such keywords, both the singular and plural forms are recognized and accepted interchangeably; this also means both forms are reserved. This plural/singular duality applies to the following keywords: club, diamond, heart, spade, notrump, hcp, jack, queen, king, ace, loser, control, trick and imp.

    Inputs

    The program knows several basic commands, each consisting of a keyword and a parameter. A parameter can be a single value or an expression that will be evaluated for every generated deal. Besides that, the program allows the user to create identifiers and assign expressions to them. The identifiers can be used as parameters for the basic commands or inside other expressions, and this is exactly equivalent to using the expressions they denote.
    • generate (number)
      generate (number) hands. If you do not specify this, then a million hands will be generated
    • produce (number)
      Produce (number) hands that satisfy the condition. If you do specify this and you want the hands to be printed you get 40. If you only asked for statistics or so you will get a 100,000.

      The "generate" and "produce" numbers are upper limits. The first one to become true will terminate the program.

    • vulnerable ({none|NS|EW|all})
      Sets the vulnerability for the hand to 1 of the 4 possibilities, with none the default if the command is not in the input file.

      This command is primarily intended for cases where action-list includes the printpbn action and the hands will be fed into another program for further analysis. These programs often require that the dealer and vulnerability are known. This command allows the user to set the vulnerability, the next command allows him to set the dealer.

    • dealer (compass)
      Sets the dealer on the hand to north, south, east or west, with north the default if the command is not in the input file.
    • predeal (predeallist)
      This command can be used to assign specific cards to a player, for example in problems like the common "you hold SAQ542, HKJ87, D32, CAK" and the auction starts 1C on your left, 2D by partner, pass on your left. With the predeal command, you can assign these 13 cards to this player. Then you create expressions describing the 1C opener and the 2D overcall. Finally, you generate a number of hands fitting the conditions and (hopefully) find the solution for your problem.

      The predeallist consists of a player, followed by holding in one or more suits separated by commas. A holding in a suit consist of a suit-symbol (S, H, D or C) followed by cards (AKQJ, T for 10, 9..2).

      A player can be pre-dealt any number of cards, e.g. for a play problem it is possible to give dummy and declarer their specific hands and the opening-leader the card he just led. The program then generates hands by dividing the remaining 25 cards over the two other players.

      An alternate form of predeal specification is (suit)(player)==1 (for example: "spades(north)==1" and variants thereof for different suits, compass positions, numbers); this will ensure that (player) gets exactly the number of spades specified, (in this case, one), but that spade can be any card (except for the ones predealt to other players). predeal (player),(card) will just force the program to give these cards to this player, without any restrictions for the remaining cards. For example, predeal north,S2 will give north the 2 of spades. However, all other spade cards can still be dealt to north, so north will not necessarily have a singleton spade 2.

      Note that predeal is not compatible with a command-line switch of "-l", and only makes much sense for hands that are not permuted if the command-line switches of "-2" or "-3" are given ("-3" is generally used with predeal for North, "-2" with predeal for North and South) to specify "swapping" (the default is "-0", "no swapping").

    • pointcount (list of numbers)
      Points to give to the various cards, starting from the ace and ending with the 2. The hcp() function uses this. Default is the standard 4, 3, 2, 1 (and 0 for all other cards) scale.
    • altcount (number) (list of numbers)
      Similar to pointcount, but for 10 "alternate counts" numbered 0 to 9, so that several things about a hand can be "counted". The ptN() functions use this (names are pt0, pt1, etc, up to pt9, and there are also synonyms such as tens, jacks, etc; default for what is being counted varies for each of the 10 alternate counts).
    • condition (expression)
      For every generated hand, the expression is evaluated. If it is true (non zero), then the corresponding action is executed. If you do not specify a condition the constant 1 (always true) will be assumed.

      The word condition can actually be omitted. Note that if more than one condition is specified, this is not diagnosed as an error, but the last condition will override the other(s); to have several conditions apply at once, you have to join them into a single expression, i.e. a single condition statement, joining them with "&&" or equivalently "and".

      Deals not meeting the condition are considered to be "generated" but not "produced", and no action is undertaken for them.

    • action (actionlist)
      List of actions to be executed. If you do not specify an action, the printall action is assumed. If more than one action is in the list, separate them with commas.
    • (identifier) = (expression)
      Defines (identifier) to represent (expression)

    Expressions

    An expression looks like regular C-code, with all normal operators that make sense in a bridge program present:
    • && or and: logical AND
    • || or or: logical OR
    • ! or not: logical NOT
    • ==: Equal to (note, NOT "=", but rather "=="!!!)
    • !=: Not equal to
    • < and <=: Less and "Equal or Less" respectively.
    • > and >=: Greater and "Greater or equal" respectively.
    • +, -, *, /: Add, subtract, multiply and divide; note that division truncates to the next lower integer (the program does not use "floating point" numbers).
    • %: Modulo ("remainder of division by").
    • (): Brackets. The program uses the normal C-rules to evaluate expressions. With brackets this can be changed, e.g. 2*a+b is evaluated by multiplying a by 2, then adding b. Changing this into 2*(a+b) reverses this.
    • ?: the ternary "selection" operator. The operand before the ? is first evaluated; if true, then the one right after the ? and before the : is evaluated (and its value is that of this entire sub-expression), else, the one at the end of the sub-expression, i.e. after the :. This operator is usually used for "if-then-else" constructions.

      For example: Suppose you want assign the number of hcp in north's longest minor to a variable. With the selection operator, this can be done as follows:

      minornorth = clubs(north) > diamonds(north) ? hcp(north,clubs) : hcp(north,diamonds)
      
      The program will first evaluate the "clubs(north)>diamonds(north)" part. If this is true, then hcp(north,clubs) will be assigned to minornorth. If not, then minornorth will be set to hcp(north,diamonds). This line is equivalent to the following piece of C-like code:
      if (clubs(north) > diamonds(north) )
        minornorth = hcp(north, clubs);
      else
        minornorth = hcp(north, diamonds);
      
    Besides that, special operators useful in a bridge-program are provided:
    • Suit Lengths

      • (suit) ( (compass) ), eg hearts(west)
        the number of cards in the suit held by the player. Suit can be club(s), diamond(s), heart(s) or spade(s).

    • Hand Evaluation

      • hcp ( (compass) ), eg hcp(north)
        the number of high card points held by the player using the 4321 count, unless overwritten with the pointcount command.
      • hcp ( (compass), (suit) ), eg hcp(south, spades)
        the number of high card points in the specified suit, using the 4321 count (or alternate assignments provided with the pointcount command).
      • ptN ( (compass) ), eg pt3(north)
        alternate-count number N (from 0 to 9) for the player named
      • ptN ( (compass), (suit) ), eg ptN(south, spades)
        the value of alternate-count number N using the specified suit and player
      • tens, jacks, queens, kings, aces, top2, top3, top4, top5, c13
        alternate, readable synonyms for pt0 to pt9 in order -- the names correspond to what these alternate-counts do count if not overridden with the altcount command: number of jacks/queens/kings/aces; numbers of honours in the top 2 (AK), 3 (AKQ), 4 (AKQJ), 5 (AKQJT); "c13" points, with A=6, K=4, Q=2, J=1 (a version of the "Four Aces" or "Burnstine" count using only integers, and with points in each suit that sum to 13, whence the name). Example: top5(east,spades) number of honours that East holds in the Spade suit (unless alternate count number 8 has been overridden with altcount 8, in which case the things being counted can be quite different).
      • control ((compass)), eg control(north)
        The number of controls using A=2, K=1. It is possible to generate hands with N controls using the hcp() function. However, one has to override the standard pointcount table for that, making it impossible to generate hands with requirements on hcp and controls (for example, " hcp(north)>6 and control(north)<3"). This function solves that problem.
      • control ((compass, (suit)), eg control(north, spades)
        The number of controls using A=2, K=1 in a suit.
      • loser ((compass)), eg loser(north)
        The number of losers in the hand, or the sum of the number of losers in each suit. The program does not apply any corrections to the loser-count such as "1 loser less if a player has more aces than queens".
      • loser ((compass, (suit)), eg loser(north, spades)
        The number of losers in a suit. The number of losers in a suit is:
        • 3 cards or more: 3 - 1 for each of A, K or Q held.
        • Void: 0 losers.
        • Singleton A: 0 losers, any other singleton 1.
        • Doubleton AK: 0 losers, Ax or Kx 1, any other doubleton 2.
      • cccc(compass)
      • quality(compass, suit)
        Both quality and cccc use the algorithms described in _The Bridge World_, October 1982, with the single exception that the values are multiplied by 100 (so that we can use integers for them). Thus, a minimum opening bid is about 1200, rather than 12.00 as expressed in the text.
      • tricks(compass, strain)
        Runs GIB's double-dummy engine (BRIDGE under Linux, BRIDGE.EXE under Windows/NT or /98), which must be present on the path or in the same directory as the Dealer executable (together with, on Windows, SH.EXE and CYGWIN.DLL from Cygnus' free Cygwin package; this latter is not necessary in Paul Baxter's version), to compute the number of tricks that, at double-dummy par, will be taken by the given declarer in the given strain (suit or notrumps).
      • score(vulnerability, contract, tricks)
        Returns the positive or negative score that declarer will make if the given contract, at the given vulnerability condition, is played and the given number of tricks are made. The syntax for "contract" is of the form "x3N" for 3 no-trumps, "x7C" for 7 clubs, etc; the leading "x" is needed. There is currently no way to specify that the contract is doubled, nor that it is re-doubled. The result will be positive if the contract makes, negative if it goes down.
      • imps(scoredifference)
        Translates a score-difference into IMPs (International Match Points). The difference, of course, can be positive or negative, and the result of "imps" will then have that same sign.

    • Shapes and specific cards

      • shape ( (compass), shapelist)
        This function specifies specific shapes for a player.

        The shapelist is a list of shapes combined with + or - signs. A shape with a + sign is added to the list, a shape with a - sign is excluded from the list.

        A shape is specified by digits in the normal order spades, hearts, diamonds and clubs, so 5431 specifies a hand with 5 spades, 4 hearts, 3 diamonds and a singleton club.

        Digits can be replaced by the letter "x" to match any length, so "55xx" specifies a hand with 5 spades, 5 hearts and 3 cards in the minors.

        The "any" operator can be prepended to a shape. This will remove the order of the suits, so "any 4333" specifies any hand with 1 4-card suit and 3 cards in the 3 other suits.

        Adding all this together allows you to write expressions like:

        shape(north, any 4333 + 54xx - any 0xxx)
        requiring north to hold any 4333, 5 spades and 4 hearts, but excluding any distribution with a void.

        This operator is one of the most important in the program and is very efficiently implemented. Any shape() call, no matter how complicated is executed in constant time. Use shape() for all length expressions if you can.

      • hascard ( (compass), (card) ), eg hascard(east, TC)
        whether east holds the 10 (T) of clubs

    Actions

    Note that multiple "print" actions, while not forbidden, are not guaranteed to work sensibly. printoneline and printes are roughly "designed" to work with each other, but most other combinations will not produced the overall hoped-for output format; experiment. Actions whose names do not start with "print", i.e. average and frequency, do generally co-operate sensibly with each other and with one print action (or a series of printoneline/printes ones), but, again, experiment is advised.

    The different actions are:

    • printall
      prints all four hands next to each other in the order north, east, south and west. This is the default.
    • print ((list of compasses)), eg print(east,west)
      print all hands specified on separate pages. This is the best way to generate hands to be used for partnership training. One of the partners gets one page, and one the other and they can start practicing.
    • printew
      Prints the east and west hands only, with west to the left of east. This is useful for generating examples for bidding sequences. Generate the 2 hands then add comments in a text editor to the file.
    • printpbn
      Print the output in PBN format, for further analysis by other programs.
    • printcompact [optional expression]
      Print the output, and optionally an expression, in reasonably compact form (4 lines per deal).
    • printoneline [optional expression]
      Print the output, and optionally an expression, in very compact form (1 line per deal).
    • printes (list of strings and expressions)
      Prints one or more expressions and strings; separate them with commas if there is more than one, and use \n to indicate end of line. Example:
      printes "Number of hearts: ", hearts(north), \n
      This is mainly intended to help you debug complicated expressions -- break them up into small pieces and use printes to examine their results.
    • average "optional string" (expr), eg average "points" hcp(north)
      calculates and prints the average of the expression over all hands satisfying the condition. The optional strings is printed before the average.
    • frequency "optional string" ( (expr), (lowbnd), (highbnd) )
      calculates and prints a histogram of the values of (expr), between the bounds (lowbnd) and (highbnd) inclusive (all values lower than lowbnd are cumulated into a first row "Low", all higher than highbnd into a last row "High"). The optional string is printed before the histogram
    • frequency "optional string" ( (expr), (lowbnd), (highbnd), (expr2), (lowbnd2), (highbnd2) )
      calculates and prints a 2-D histogram of the joint values of (expr), between the bounds (lowbnd) and (highbnd) inclusive, and (expr2) between the bounds (lowbnd2) and (highbnd2) inclusive; as above, "low" and "high" are added for each expression, and, also, the marginals of the joint distribution are printed as "Sum" rows and columns. This can give a good idea of the mutual statistical influence of two computed expressions upon each other. The optional string is printed before the histogram.
    The program allows for and unlimited number of actions. More than one print action is allowed, but, depending on the actions involved, this may or may not give the desired results.

    An example

    Back to the "you hold ..." problem. Suppose we want to generate 25 hands that match these specifications on a slow machine, so we don't want to generate too many hands. This is accomplished with the following input file:
    generate   10000
    produce    25
    vulnerable EW
    dealer     west
    predeal    south SAQ542, HKJ87, D32, CAK
    west1c   = hcp(west)>11 && clubs(west)>= 3
    # Condition describing west's 1C opener.
    north2d  = diamonds(north)>=6 && (hcp(north)>5 && hcp(north)<12)
    # Condition describing north's 2D overcall.
    condition  west1c && north2d
    # Require that west bids 1C and north 2D
    action     printall
    
    This produces 25 hands, including, for example, with this one:
    J 7 3               9 8                 A Q 5 4 2           K T 6 
    3                   9 6 4 2             K J 8 7             A Q T 5 
    K Q J T 9 8 5       7                   3 2                 A 6 4 
    T 5                 9 8 7 4 3 2         A K                 Q J 6 
    
    Note that the hands that you get depend on the seed of the random generator, so, unless you use the -s flag to set the random generator seed, the hands that you produce will be different.

    You can now start to analyze the hand and decide on the best action for east. However, if you look carefully at the west-hand, then you see that west could have opened this with a 15-17 NT. If you look at other hands, west might have opened 1D, 1H or 1S. These hands are excluded by:

    west1d = diamonds(west)>clubs(west) || ((diamonds(west)==clubs(west))==4)
    west1h = hearts(west)>= 5
    west1s = spades(west)>= 5
    west1n = shape(west, any 4333 + any 4432 + any 5332 - 5xxx - x5xx) &&
             (hcp(west)>14 && hcp(west)<18)
    west1c = hcp(west)>11 && clubs(west)>= 3 && 
             (not west1n) && (not west1s) && (not west1h) && (not west1d)
    
    A next run shows that north will occasionally overcall 2D on 8-card suit or with a side 4 or 5 card major. These distributions are excluded with:
    north2d = (hcp(north)>5 && (hcp(north)<12) &&
              shape (north, xx6x + xx7x - any 4xxx - any 5xxx)
    
    making the complete example:
    generate   10000
    produce    25
    vulnerable ew
    dealer     west
    predeal    south SAQ542, HKJ87, D32, CAK
    west1n = shape(west, any 4333 + any 4432 + any 5332 - 5xxx - x5xx) &&
             hcp(west)>14 && hcp(west)<18
    west1h = hearts(west)>= 5
    west1s = spades(west)>= 5
    west1d = diamonds(west)>clubs(west) || ((diamonds(west)==clubs(west))==4)
    west1c = (not west1n) && hcp(west)>10 && clubs(west)>=3
             && (not west1h) && (not west1s) && (not west1d)
    north2d = (hcp(north)>5 && hcp(north)<12) &&
              shape(north, xx6x + xx7x - any 4xxx - any 5xxx)
    condition  west1c && north2d
    action     printall
    

    More examples can be found in the Examples directory of the distribution.


    dealer/Manual/command.html0100644000076400001440000000357710002574543014720 0ustar henkusers Running the program

    Command Line Flags

    • -e : Exhaust mode (alpha version).
    • -g number : Maximum number of hands to generate (default 1000000).
    • -l number : Instead of shuffling, deals are read from the file library.dat by M. Ginsberg (see here), so the tricks() function is quite fast and bridge.exe from GIB is
    • -m : Shows a progress meter.
    • -p number : Maximum number of hands to produce (default 40).
    • -q : Suppress PBN output (useful for testing, then switch it back on when generating the "final" sample).
    • -s number : Uses number as the seed for the random generator, running the program twice with the same seed, will produce the same sequence of hands.
    • -u : Select upper- or lowercase for the symbols "AKQJT".
    • -v : Verbose output, prints statistics at the end of the run.
    • -V : Emits a version-identification string and exits
    • -h : Help, prints the syntax.
    • -0 : No swapping, each deal is generated normally (shuffling), default.
    • -2 : 2-way swapping, after each shuffle another deal is generated by permuting E and W, leaving N and S in place (NB: not fully compatible with predeal).
    • -3 : 3-way swapping, after each shuffle another 5 deals are generated by permuting E, W, and S every which way, leaving N in place (NB: not fully compatible with predeal). not needed (NB: not compatible at all with predeal).

    dealer/README0100644000076400001440000000241710055170250012042 0ustar henkusersThis program is hereby put in the public domain. Do with it whatever you want, but I would like you not to redistribute it in modified form without mentioning the fact of modification. I will accept bug reports and modification requests, without any obligation of course, but fixing bugs someone else put in is beyond me. When you report bugs please mention the version number in the source files, and preferably send context diffs if you changed anything. I might put in your fixes, and distribute a new version someday. I would prefer if you did *not* use this program for generating hands for tournaments. I have not investigated the random number generation closely enough for me to be comfortable with that thought. Hans van Staveren Amsterdam Holland ------------------------------------------------------------------------------ This is a version of Hans' program with several new functions. Please look in the Manual directory for a description. Henk Uijterwaal Amsterdam Holland henk@ripe.net ------------------------------------------------------------------------------ Notes: To build on MAC OS, replace the line CFLAGS = -Wall -pedantic -O2 -I. -DNDEBUG -c by CFLAGS= -g -DNDEBUG -DFRANCOIS -I. dealer/Random/0040755000076400001440000000000010056357700012411 5ustar henkusersdealer/Random/GPL0100644000076400001440000004311410002574543012753 0ustar henkusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. dealer/Random/Makefile0100644000076400001440000000074710002574543014053 0ustar henkusersSRC = $(wildcard *.c) OBJ = $(subst .c,.o,$(wildcard *.c)) GCC = gcc GCCFLAGS = -c -Wall -O2 -I. HDR = ansidecl.h LIB = libgnurand.a AR = ar ARFLAGS = rcs help: @echo "Makefile tags:" @echo @echo "lib: Make ${LIB}" @echo "clean: Remove ${OBJ}" @echo lib: ${LIB} clean: -rm ${OBJ} ${LIB} .c.o: ${HDR} ${GCC} ${GCCFLAGS} -o $@ $< ${LIB}: ${OBJ} ${HDR} ${AR} ${ARFLAGS} $@ ${OBJ} __random.o: ${HDR} rand.o: ${HDR} srand.o: ${HDR} dealer/Random/README0100644000076400001440000000016210002574543013262 0ustar henkusersThis directory contains the GNU random generator stuff. Please see the files GPL and GPL.lib for copyright info. dealer/Random/srand.c0100644000076400001440000000202110002574543013651 0ustar henkusers/* This code has been introduced by Bruce Moore */ /* Copyright (C) 1991 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ansidecl.h" #undef srand int __srandom(unsigned int); int gnusrand(unsigned int seed) { return (int) __srandom(seed); } dealer/Random/GPL.lib0100644000076400001440000006130310002574543013520 0ustar henkusers GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! dealer/Random/rand.c0100644000076400001440000000223710002574543013477 0ustar henkusers/* This code has been introduced by Bruce Moore */ /* Copyright (C) 1991 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ansidecl.h" /* #include */ #undef rand #undef __random long int DEFUN_VOID(__random); /* Return a random integer between 0 and RAND_MAX. */ /* int DEFUN_VOID(gnurand) { return (int) __random(); } */ int gnurand () { return (int) __random(); } dealer/Random/ansidecl.h0100644000076400001440000000567110002574543014347 0ustar henkusers/* Copyright (C) 1991 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the GNU C Library; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* ANSI and traditional C compatibility macros ANSI C is assumed if __STDC__ is #defined. Macro ANSI C definition Traditional C definition ----- ---- - ---------- ----------- - ---------- PTR `void *' `char *' LONG_DOUBLE `long double' `double' CONST `const' `' VOLATILE `volatile' `' SIGNED `signed' `' PTRCONST `void *const' `char *' DEFUN(name, arglist, args) Defines function NAME. ARGLIST lists the arguments, separated by commas and enclosed in parentheses. ARGLIST becomes the argument list in traditional C. ARGS list the arguments with their types. It becomes a prototype in ANSI C, and the type declarations in traditional C. Arguments should be separated with `AND'. For functions with a variable number of arguments, the last thing listed should be `DOTS'. DEFUN_VOID(name) Defines a function NAME, which takes no arguments. EXFUN(name, prototype) Is used in an external function declaration. In ANSI C it is `NAMEPROTOTYPE' (so PROTOTYPE should be enclosed in parentheses). In traditional C it is `NAME()'. For a function that takes no arguments, PROTOTYPE should be `(NOARGS)'. For example: extern int EXFUN(printf, (CONST char *format DOTS)); int DEFUN(fprintf, (stream, format), FILE *stream AND CONST char *format DOTS) { ... } void DEFUN_VOID(abort) { ... } */ #ifndef _ANSIDECL_H #define _ANSIDECL_H 1 /* Every source file includes this file, so they will all get the switch for lint. */ /* LINTLIBRARY */ #ifdef __STDC__ #define PTR void * #define PTRCONST void *CONST #define LONG_DOUBLE long double #define AND , #define NOARGS void #define CONST const #define VOLATILE volatile #define SIGNED signed #define DOTS , ... #define EXFUN(name, proto) name proto #define DEFUN(name, arglist, args) name(args) #define DEFUN_VOID(name) name(NOARGS) #else /* Not ANSI C. */ #define PTR char * #define PTRCONST PTR #define LONG_DOUBLE double #define AND ; #define NOARGS #define CONST #define VOLATILE #define SIGNED #define DOTS #define EXFUN(name, proto) name() #define DEFUN(name, arglist, args) name arglist args; #define DEFUN_VOID(name) name() #endif /* ANSI C. */ #endif /* ansidecl.h */ dealer/Random/.cvsignore0100644000076400001440000000001010002574543014372 0ustar henkusers*.o *.a dealer/Random/__random.c0100644000076400001440000003070710002574543014334 0ustar henkusers/* This code has been introduced by Bruce Moore */ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* * This is derived from the Berkeley source: * @(#)random.c 5.5 (Berkeley) 7/6/88 * It was reworked for the GNU C Library by Roland McGrath. */ #include "ansidecl.h" #include #include #include /* #include */ long int DEFUN_VOID(__random); /* An improved random number generation package. In addition to the standard rand()/srand() like interface, this package also has a special state info interface. The initstate() routine is called with a seed, an array of bytes, and a count of how many bytes are being passed in; this array is then initialized to contain information for random number generation with that much state information. Good sizes for the amount of state information are 32, 64, 128, and 256 bytes. The state can be switched by calling the setstate() function with the same array as was initiallized with initstate(). By default, the package runs with 128 bytes of state information and generates far better random numbers than a linear congruential generator. If the amount of state information is less than 32 bytes, a simple linear congruential R.N.G. is used. Internally, the state information is treated as an array of longs; the zeroeth element of the array is the type of R.N.G. being used (small integer); the remainder of the array is the state information for the R.N.G. Thus, 32 bytes of state information will give 7 longs worth of state information, which will allow a degree seven polynomial. (Note: The zeroeth word of state information also has some other information stored in it; see setstate for details). The random number generation technique is a linear feedback shift register approach, employing trinomials (since there are fewer terms to sum up that way). In this approach, the least significant bit of all the numbers in the state table will act as a linear feedback shift register, and will have period 2^deg - 1 (where deg is the degree of the polynomial being used, assuming that the polynomial is irreducible and primitive). The higher order bits will have longer periods, since their values are also influenced by pseudo-random carries out of the lower bits. The total period of the generator is approximately deg*(2**deg - 1); thus doubling the amount of state information has a vast influence on the period of the generator. Note: The deg*(2**deg - 1) is an approximation only good for large deg, when the period of the shift register is the dominant factor. With deg equal to seven, the period is actually much longer than the 7*(2**7 - 1) predicted by this formula. */ /* For each of the currently supported random number generators, we have a break value on the amount of state information (you need at least thi bytes of state info to support this random number generator), a degree for the polynomial (actually a trinomial) that the R.N.G. is based on, and separation between the two lower order coefficients of the trinomial. */ /* Linear congruential. */ #define TYPE_0 0 #define BREAK_0 8 #define DEG_0 0 #define SEP_0 0 /* x**7 + x**3 + 1. */ #define TYPE_1 1 #define BREAK_1 32 #define DEG_1 7 #define SEP_1 3 /* x**15 + x + 1. */ #define TYPE_2 2 #define BREAK_2 64 #define DEG_2 15 #define SEP_2 1 /* x**31 + x**3 + 1. */ #define TYPE_3 3 #define BREAK_3 128 #define DEG_3 31 #define SEP_3 3 /* x**63 + x + 1. */ #define TYPE_4 4 #define BREAK_4 256 #define DEG_4 63 #define SEP_4 1 /* Array versions of the above information to make code run faster. Relies on fact that TYPE_i == i. */ #define MAX_TYPES 5 /* Max number of types above. */ static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; /* Initially, everything is set up as if from: initstate(1, randtbl, 128); Note that this initialization takes advantage of the fact that srandom advances the front and rear pointers 10*rand_deg times, and hence the rear pointer which starts at 0 will also end up at zero; thus the zeroeth element of the state information, which contains info about the current position of the rear pointer is just (MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */ static long int randtbl[DEG_3 + 1] = { TYPE_3, -851904987, -43806228, -2029755270, 1390239686, -1912102820, -485608943, 1969813258, -1590463333, -1944053249, 455935928, 508023712, -1714531963, 1800685987, -2015299881, 654595283, -1149023258, -1470005550, -1143256056, -1325577603, -1568001885, 1275120390, -607508183, -205999574, -1696891592, 1492211999, -1528267240, -952028296, -189082757, 362343714, 1424981831, 2039449641, }; /* FPTR and RPTR are two pointers into the state info, a front and a rear pointer. These two pointers are always rand_sep places aparts, as they cycle through the state information. (Yes, this does mean we could get away with just one pointer, but the code for random is more efficient this way). The pointers are left positioned as they would be from the call: initstate(1, randtbl, 128); (The position of the rear pointer, rptr, is really 0 (as explained above in the initialization of randtbl) because the state table pointer is set to point to randtbl[1] (as explained below).) */ static long int *fptr = &randtbl[SEP_3 + 1]; static long int *rptr = &randtbl[1]; /* The following things are the pointer to the state information table, the type of the current generator, the degree of the current polynomial being used, and the separation between the two pointers. Note that for efficiency of random, we remember the first location of the state information, not the zeroeth. Hence it is valid to access state[-1], which is used to store the type of the R.N.G. Also, we remember the last location, since this is more efficient than indexing every time to find the address of the last element to see if the front and rear pointers have wrapped. */ static long int *state = &randtbl[1]; static int rand_type = TYPE_3; static int rand_deg = DEG_3; static int rand_sep = SEP_3; static long int *end_ptr = &randtbl[sizeof(randtbl) / sizeof(randtbl[0])]; /* Initialize the random number generator based on the given seed. If the type is the trivial no-state-information type, just remember the seed. Otherwise, initializes state[] based on the given "seed" via a linear congruential generator. Then, the pointers are set to known locations that are exactly rand_sep places apart. Lastly, it cycles the state information a given number of times to get rid of any initial dependencies introduced by the L.C.R.N.G. Note that the initialization of randtbl[] for default usage relies on values produced by this routine. */ void DEFUN(__srandom, (x), unsigned int x) { state[0] = x; if (rand_type != TYPE_0) { register long int i; for (i = 1; i < rand_deg; ++i) state[i] = (1103515145 * state[i - 1]) + 12345; fptr = &state[rand_sep]; rptr = &state[0]; for (i = 0; i < 10 * rand_deg; ++i) (void) __random(); } } /* Initialize the state information in the given array of N bytes for future random number generation. Based on the number of bytes we are given, and the break values for the different R.N.G.'s, we choose the best (largest) one we can and set things up for it. srandom is then called to initialize the state information. Note that on return from srandom, we set state[-1] to be the type multiplexed with the current value of the rear pointer; this is so successive calls to initstate won't lose this information and will be able to restart with setstate. Note: The first thing we do is save the current state, if any, just like setstate so that it doesn't matter when initstate is called. Returns a pointer to the old state. */ PTR DEFUN(__initstate, (seed, arg_state, n), unsigned int seed AND PTR arg_state AND size_t n) { PTR ostate = (PTR) &state[-1]; if (rand_type == TYPE_0) state[-1] = rand_type; else state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; if (n < BREAK_1) { if (n < BREAK_0) { errno = EINVAL; return NULL; } rand_type = TYPE_0; rand_deg = DEG_0; rand_sep = SEP_0; } else if (n < BREAK_2) { rand_type = TYPE_1; rand_deg = DEG_1; rand_sep = SEP_1; } else if (n < BREAK_3) { rand_type = TYPE_2; rand_deg = DEG_2; rand_sep = SEP_2; } else if (n < BREAK_4) { rand_type = TYPE_3; rand_deg = DEG_3; rand_sep = SEP_3; } else { rand_type = TYPE_4; rand_deg = DEG_4; rand_sep = SEP_4; } state = &((long int *) arg_state)[1]; /* First location. */ /* Must set END_PTR before srandom. */ end_ptr = &state[rand_deg]; __srandom(seed); if (rand_type == TYPE_0) state[-1] = rand_type; else state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; return ostate; } /* Restore the state from the given state array. Note: It is important that we also remember the locations of the pointers in the current state information, and restore the locations of the pointers from the old state information. This is done by multiplexing the pointer location into the zeroeth word of the state information. Note that due to the order in which things are done, it is OK to call setstate with the same state as the current state Returns a pointer to the old state information. */ PTR DEFUN(__setstate, (arg_state), PTR arg_state) { register long int *new_state = (long int *) arg_state; register int type = new_state[0] % MAX_TYPES; register int rear = new_state[0] / MAX_TYPES; PTR ostate = (PTR) &state[-1]; if (rand_type == TYPE_0) state[-1] = rand_type; else state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; switch (type) { case TYPE_0: case TYPE_1: case TYPE_2: case TYPE_3: case TYPE_4: rand_type = type; rand_deg = degrees[type]; rand_sep = seps[type]; break; default: /* State info munged. */ errno = EINVAL; return NULL; } state = &new_state[1]; if (rand_type != TYPE_0) { rptr = &state[rear]; fptr = &state[(rear + rand_sep) % rand_deg]; } /* Set end_ptr too. */ end_ptr = &state[rand_deg]; return ostate; } /* If we are using the trivial TYPE_0 R.N.G., just do the old linear congruential bit. Otherwise, we do our fancy trinomial stuff, which is the same in all ther other cases due to all the global variables that have been set up. The basic operation is to add the number at the rear pointer into the one at the front pointer. Then both pointers are advanced to the next location cyclically in the table. The value returned is the sum generated, reduced to 31 bits by throwing away the "least random" low bit. Note: The code takes advantage of the fact that both the front and rear pointers can't wrap on the same call by not testing the rear pointer if the front one has wrapped. Returns a 31-bit random number. */ long int DEFUN_VOID(__random) /* long int random(void) */ /* Use this one if your system complains about the DEFUN_VOID statement */ { if (rand_type == TYPE_0) { state[0] = ((state[0] * 1103515245) + 12345) & LONG_MAX; return state[0]; } else { long int i; *fptr += *rptr; /* Chucking least random bit. */ i = (*fptr >> 1) & LONG_MAX; ++fptr; if (fptr >= end_ptr) { fptr = state; ++rptr; } else { ++rptr; if (rptr >= end_ptr) rptr = state; } return i; } } dealer/dealer_dev.html0100644000076400001440000000102310002574544014140 0ustar henkusers DEALER, a bridge hand generator program

    DEALER, a bridge hand generator program

    Development version

    Click here to download the development version of the code. This is Alpha release stuff, e.g. the version that one got when I last bothered to type "make tarfile" ;-) Guarantee until the front door, as they say. Last update on $Date: 1999/06/15 18:43:00 $ dealer/dealer.c0100644000076400001440000015146410056343327012601 0ustar henkusers#include #include #include #include #include #include long seed = 0; int quiet = 0; char* input_file = 0; #ifdef _MSC_VER /* with VC++6, winsock2 declares ntohs and struct timeval */ #pragma warning (disable : 4115) #include #pragma warning (default : 4115) #else /* else we assume we can get ntohs/ntohl from netinet */ #include #endif /* _MSC_VER */ #ifdef WIN32 #ifndef _MSC_VER struct timeval { long tv_sec; /* seconds */ long tv_usec; /* and microseconds */ }; #endif /* _MSC_VER */ #pragma warning (disable : 4100) void gettimeofday (struct timeval *tv, void *pv) { tv->tv_sec = time (0); tv->tv_usec = 0; } #pragma warning (default : 4100) #else #include #include #endif /* WIN32 */ #include "getopt.h" #include "tree.h" #include "pointcount.h" #include "dealer.h" #include "c4.h" #include "pbn.h" void yyerror (char *); #define TWO_TO_THE_13 (1<<13) #define DEFAULT_MODE STAT_MODE #define RANDBITS 16 #define NRANDVALS (1<= j) return scorediff < 0 ? -i : i; return scorediff < 0 ? -i : i; } int score (int vuln, int suit, int level, int tricks) { int total = 0; /* going down */ if (tricks < 6 + level) return -50 * (1 + vuln) * (6 + level - tricks); /* Tricks */ total = total + ((suit >= SUIT_HEART) ? 30 : 20) * (tricks - 6); /* NT bonus */ if (suit == SUIT_NT) total += 10; /* part score bonus */ total += 50; /* game bonus for NT */ if ((suit == SUIT_NT) && level >= 3) total += 250 + 200 * vuln; /* game bonus for major-partscore bns */ if ((suit == SUIT_HEART || suit == SUIT_SPADE) && level >= 4) total += 250 + 200 * vuln; /* game bonus for minor-partscore bns */ if ((suit == SUIT_CLUB || suit == SUIT_DIAMOND) && level >= 5) total += 250 + 200 * vuln; /* small slam bonus */ if (level == 6) total += 500 + 250 * vuln; /* grand slam bonus */ if (level == 7) total += 1000 + 500 * vuln; return total; } void showevalcontract (int nh) { int s, l, i, v; for (v = 0; v < 2; v++) { printf ("%sVulnerable%s", v ? "" : "Not ", crlf); printf (" "); for (l = 1; l < 8; l++) printf (" %d ", l); printf ("%s", crlf); for (s = 0; s < 5; s++) { printf ("%c: ", "cdhsn"[s]); for (l = 1; l < 8; l++) { int t = 0, tn = 0; for (i = 0; i < 14; i++) { t += results[0][s][i] * score (v, s, l, i); tn += results[1][s][i] * score (v, s, l, i); } printf ("%4d/%4d ", t / nh, tn / nh); } printf ("%s", crlf); } printf ("%s", crlf); } } int dd (deal d, int l, int c) { /* results-cached version of dd() */ /* the dd cache, and the ngen it refers to */ static int cached_ngen = -1; static char cached_tricks[4][5]; /* invalidate cache if it's another deal */ if (ngen != cached_ngen) { memset (cached_tricks, -1, sizeof (cached_tricks)); cached_ngen = ngen; } if (cached_tricks[l][c] == -1) { /* cache the costly computation's result */ cached_tricks[l][c] = true_dd (d, l, c); } /* return the cached value */ return cached_tricks[l][c]; } struct tagLibdeal { unsigned long suits[4]; unsigned short tricks[5]; int valid; } libdeal; int get_tricks (int pn, int dn) { int tk = libdeal.tricks[dn]; int resu; resu = (pn ? (tk >> (4 * pn)) : tk) & 0x0F; return resu; } int true_dd (deal d, int l, int c) { if (loading && libdeal.valid) { int resu = get_tricks ((l + 1) % 4, (c + 1) % 5); /* This will get the number of tricks EW can get. If the user wanted NW, we have to subtract 13 from that number. */ return ((l == 0) || (l == 2)) ? 13 - resu : resu; } else { #ifdef MSDOS /* Ugly fix for MSDOS. Requires a file called in.txt and will create the files tst.pbn and out.txt. Note that we need not user crlf here, as it's only dealer that will read the files anyway, Micke Hovmller 990310 */ FILE *f; char tn1[] = "tst.pbn"; char tn2[] = "out.txt"; char res; f = fopen (tn1, "w+"); if (f == 0) error ("Can't open temporary file"); fprintcompact (f, d, 0); /* Write the player to lead and strain. Note that since the player to lead sits _behind_ declarer, the array is "eswn" instead of "nesw". /Micke Hovmller 990312 */ fprintf (f, "%c %c\n", "eswn"[l], "cdhsn"[c]); fclose (f); fflush (stdout); system ("bridge.exe < in.txt > out.txt"); fflush (stdout); f = fopen (tn2, "r"); if (f == 0) error ("Can't read output of analysis"); fscanf (f, "%*[^\n]\nEnter argument line: %c", &res); fclose (f); /* This will get the number of tricks EW can get. If the user wanted NW, we have to subtract 13 from that number. */ return ((l == 1) || (l == 3)) ? 13 - trix (res) : trix (res); #else FILE *f; char cmd[1024]; char tn1[256], tn2[256]; char res; f = fopen (tn1, "w+"); if (f == 0 ) error ("Can't open temporary file"); fprintcompact (f, d, 0); fprintf (f, "%c %c\n", "eswn"[l], "cdhsn"[c]); fclose (f); tmpnam (tn2); sprintf (cmd, "bridge -d -q %s >%s", tn1, tn2); system (cmd); f = fopen (tn2, "r"); if (f == 0) error ("Can't read output of analysis"); fscanf (f, "%*[^\n]\n%c", &res); fclose (f); remove (tn1); remove (tn2); /* This will get the number of tricks EW can get. If the user wanted NW, we have to subtract 13 from that number. */ return ((l == 1) || (l == 3)) ? 13 - trix (res) : trix (res); #endif /* MSDOS */ } } void evalcontract () { int s; for (s = 0; s < 5; s++) { results[1][s][dd (curdeal, 3, s)]++; /* south declarer */ results[0][s][dd (curdeal, 1, s)]++; /* north declarer */ } } void error (char *s) { fprintf (stderr, "%s%s", s, crlf); exit (10); } /* implementations of regular & alternate pointcounts */ int countindex = -1; void zerocount (int points[13]) { int i; for (i = 12; i >= 0; i--) points[i] = 0; } void clearpointcount () { zerocount (tblPointcount[idxHcp]); countindex = -1; } void clearpointcount_alt (int cin) { zerocount (tblPointcount[cin]); countindex = cin; } void pointcount (int index, int value) { assert (index <= 12); if (index < 0) { yyerror ("too many pointcount values"); } if (countindex < 0) tblPointcount[idxHcp][index] = value; else tblPointcount[countindex][index] = value; } char * mycalloc (unsigned nel, unsigned siz) { char *p; p = calloc (nel, siz); if (p) return p; fprintf (stderr, "Out of memory\n"); exit (-1); /*NOTREACHED */ } void initdistr () { int ***p4, **p3, *p2; int clubs, diamonds, hearts; /* Allocate the four dimensional pointer array */ for (clubs = 0; clubs <= 13; clubs++) { p4 = (int ***) mycalloc ((unsigned) 14 - clubs, sizeof (*p4)); distrbitmaps[clubs] = p4; for (diamonds = 0; diamonds <= 13 - clubs; diamonds++) { p3 = (int **) mycalloc ((unsigned) 14 - clubs - diamonds, sizeof (*p3)); p4[diamonds] = p3; for (hearts = 0; hearts <= 13 - clubs - diamonds; hearts++) { p2 = (int *) mycalloc ((unsigned) 14 - clubs - diamonds - hearts, sizeof (*p2)); p3[hearts] = p2; } } } } void setshapebit (int cl, int di, int ht, int sp, int msk, int excepted) { if (excepted) distrbitmaps[cl][di][ht][sp] &= ~msk; else distrbitmaps[cl][di][ht][sp] |= msk; } void newpack (deal d) { int suit, rank, place; place = 0; for (suit = SUIT_CLUB; suit <= SUIT_SPADE; suit++) for (rank = 0; rank < 13; rank++) d[place++] = MAKECARD (suit, rank); } #ifdef FRANCOIS int hascard (deal d, int player, card onecard, int vectordeal){ int i; int who; switch (computing_mode) { case STAT_MODE: for (i = player * 13; i < (player + 1) * 13; i++) if (d[i] == onecard) return 1; return 0; break; case EXHAUST_MODE: if (exh_card_map[onecard] == -1) return 0; who = 1 & (vectordeal >> exh_card_map[onecard]); return (exh_player[who] == player); } return 0; #else int hascard (deal d, int player, card onecard){ int i; for (i = player * 13; i < (player + 1) * 13; i++) if (d[i] == onecard) return 1; return 0; #endif /* FRANCOIS */ } card make_card (char rankchar, char suitchar) { int rank, suit = 0; for (rank = 0; rank < 13 && ucrep[rank] != rankchar; rank++) ; assert (rank < 13); switch (suitchar) { case 'C': suit = 0; break; case 'D': suit = 1; break; case 'H': suit = 2; break; case 'S': suit = 3; break; default: assert (0); } return MAKECARD (suit, rank); } int make_contract (char suitchar, char trickchar) { int trick, suit; trick = (int) trickchar - '0'; switch (suitchar) { case 'C': suit = 0; break; case 'D': suit = 1; break; case 'H': suit = 2; break; case 'S': suit = 3; break; case 'N': suit = 4; break; default: suit = 0; printf ("%c", suitchar); assert (0); } return MAKECONTRACT (suit, trick); } void analyze (deal d, struct handstat *hsbase) { /* Analyze a hand. Modified by HU to count controls and losers. */ /* Further mod by AM to count several alternate pointcounts too */ int player, next, c, r, s, t; card curcard; struct handstat *hs; /* for each player */ for (player = COMPASS_NORTH; player <= COMPASS_WEST; ++player) { /* If the expressions in the input never mention a player we do not calculate his hand statistics. */ if (use_compass[player] == 0) { #ifdef _DEBUG /* In debug mode, blast the unused handstat, so that we can recognize it as garbage should if we accidently read from it */ hs = hsbase + player; memset (hs, 0xDF, sizeof (struct handstat)); #endif /* _DEBUG_ */ continue; } /* where are the handstats for this player? */ hs = hsbase + player; /* Initialize the handstat structure */ memset (hs, 0x00, sizeof (struct handstat)); #ifdef _DEBUG /* To debug, blast it with garbage.... */ memset (hs, 0xDF, sizeof (struct handstat)); /* then overwrite those specific counters which need to be incremented */ for (t = idxHcp; t < idxEnd; ++t) { /* clear the points for each suit */ for (s = SUIT_CLUB; s <= SUIT_SPADE; s++) { hs->hs_counts[t][s] = 0; } /* and the total points as well */ hs->hs_totalcounts[t] = 0; } /* clear the length for each suit */ for (s = SUIT_CLUB; s <= SUIT_SPADE; s++) { hs->hs_length[s] = 0; } /* clear the total losers */ hs->hs_totalloser = 0; #endif /* _DEBUG_ */ /* start from the first card for this player, and walk through them all - use the player offset to jump to the first card. Can't just increment through the deck, because we skip those players who are not part of the analysis */ next = 13 * player; for (c = 0; c < 13; c++) { curcard = d[next++]; s = C_SUIT (curcard); r = C_RANK (curcard); /* Enable this #if to dump a visual look at the hands as they are analysed. Best bet is to use test.all, or something else that generates only one hand, lest you quickly run out of screen realestate */ #if 0 #ifdef _DEBUG #define VIEWCOUNT #endif /* _DEBUG_ */ #endif /* 0 */ #ifdef VIEWCOUNT printf ("%c%c", "CDHS"[s], "23456789TJQKA"[r]); #endif /* VIEWCOUNT */ hs->hs_length[s]++; for (t = idxHcp; t < idxEnd; ++t) { #ifdef VIEWCOUNT printf (" %d ", tblPointcount[t][r]); #endif /* VIEWCOUNT */ hs->hs_counts[t][s] += tblPointcount[t][r]; } #ifdef VIEWCOUNT printf ("\n"); #endif /* VIEWCOUNT */ } #ifdef VIEWCOUNT printf ("---\n"); #undef VIEWCOUNT #endif /* VIEWCOUNT */ for (s = SUIT_CLUB; s <= SUIT_SPADE; s++) { assert (hs->hs_length[s] < 14); assert (hs->hs_length[s] >= 0); switch (hs->hs_length[s]) { case 0: { /* A void is 0 losers */ hs->hs_loser[s] = 0; break; } case 1: { /* Singleton A 0 losers, K or Q 1 loser */ int losers[] = {1, 1, 0}; assert (hs->hs_control[s] < 3); hs->hs_loser[s] = losers[hs->hs_counts[idxControls][s]]; break; } case 2: { /* Doubleton AK 0 losers, Ax or Kx 1, Qx 2 */ int losers[] = {2, 1, 1, 0}; assert (hs->hs_control[s] <= 3); hs->hs_loser[s] = losers[hs->hs_counts[idxControls][s]]; break; } default: { /* Losers, first correct the number of losers */ assert (hs->hs_counts[idxWinners][s] < 4); assert (hs->hs_counts[idxWinners][s] >= 0); hs->hs_loser[s] = 3 - hs->hs_counts[idxWinners][s]; break; } } /* Now add the losers to the total. */ hs->hs_totalloser += hs->hs_loser[s]; /* total up the other flavors of points */ for (t = idxHcp; t < idxEnd; ++t) { hs->hs_totalcounts[t] += hs->hs_counts[t][s]; } /* Now, using the values calculated already, load those pointcount values which are common enough to warrant a non array lookup */ hs->hs_points[s] = hs->hs_counts[idxHcp][s]; hs->hs_control[s] = hs->hs_counts[idxControls][s]; } /* end for each suit */ hs->hs_totalpoints = hs->hs_totalcounts[idxHcp]; hs->hs_totalcontrol = hs->hs_totalcounts[idxControls]; hs->hs_bits = distrbitmaps[hs->hs_length[SUIT_CLUB]] [hs->hs_length[SUIT_DIAMOND]] [hs->hs_length[SUIT_HEART]] [hs->hs_length[SUIT_SPADE]]; } /* end for each player */ } void fprintcompact (FILE * f, deal d, int ononeline) { char pt[] = "nesw"; int s, p, r; for (p = COMPASS_NORTH; p <= COMPASS_WEST; p++) { fprintf (f, "%c ", pt[p]); for (s = SUIT_SPADE; s >= SUIT_CLUB; s--) { for (r = 12; r >= 0; r--) if (HAS_CARD (d, p, MAKECARD (s, r))) fprintf (f, "%c", ucrep[r]); if (s > 0) fprintf (f, "."); } /* OK to use \n as this is mainly intended for internal dealer use. */ fprintf (f, ononeline ? " " : "\n"); } } void printdeal (deal d) { int suit, player, rank, cards; printf ("%4d.\n", (nprod+1)); for (suit = SUIT_SPADE; suit >= SUIT_CLUB; suit--) { cards = 10; for (player = COMPASS_NORTH; player <= COMPASS_WEST; player++) { while (cards < 10) { printf (" "); cards++; } cards = 0; for (rank = 12; rank >= 0; rank--) { if (HAS_CARD (d, player, MAKECARD (suit, rank))) { printf ("%c ", ucrep[rank]); cards++; } } if (cards == 0) { printf ("- "); cards++; } } printf ("\n"); } printf ("\n"); } void setup_deal () { register int i, j; j = 0; for (i = 0; i < 52; i++) { if (stacked_pack[i] != NO_CARD) { curdeal[i] = stacked_pack[i]; } else { while (fullpack[j] == NO_CARD) j++; curdeal[i] = fullpack[j++]; assert (j <= 52); } } } void predeal (int player, card onecard) { int i, j; for (i = 0; i < 52; i++) { if (fullpack[i] == onecard) { fullpack[i] = NO_CARD; for (j = player * 13; j < (player + 1) * 13; j++) if (stacked_pack[j] == NO_CARD) { stacked_pack[j] = onecard; return; } yyerror ("More than 13 cards for one player"); } } yyerror ("Card predealt twice"); } void initprogram () { int i, i_cycle; int val; /* Now initialize array zero52 with numbers 0..51 repeatedly. This whole charade is just to prevent having to do divisions. */ val = 0; for (i = 0, i_cycle = 0; i < NRANDVALS; i++) { while (stacked_pack[val] != NO_CARD) { /* this slot is predealt, do not use it */ val++; if (val == 52) { val = 0; i_cycle = i; } } zero52[i] = val++; if (val == 52) { val = 0; i_cycle = i + 1; } } /* Fill the last part of the array with 0xFF, just to prevent that 0 occurs more than 51. This is probably just for hack value */ while (i > i_cycle) { zero52[i - 1] = 0xFF; i--; } } void swap2 (deal d, int p1, int p2) { /* functions to assist "simulated" shuffling with player swapping or loading from Ginsberg's library.dat -- AM990423 */ card t; int i; p1 *= 13; p2 *= 13; for (i = 0; i < 13; ++i) { t = d[p1 + i]; d[p1 + i] = d[p2 + i]; d[p2 + i] = t; } } FILE * find_library (const char *basename, const char *openopt) { static const char *prefixes[] = { "", "./", "../", "../../", "c:/", "c:/data/", "d:/myprojects/dealer/", "d:/arch/games/gib/", 0 }; int i; char buf[256]; FILE *result = 0; for (i = 0; prefixes[i]; ++i) { strcpy (buf, prefixes[i]); strcat (buf, basename); result = fopen (buf, openopt); if (result) break; } return result; } int shuffle (deal d) { int i, j, k; card t; if (loading) { static FILE *lib = 0; if (!lib) { lib = find_library ("library.dat", "rb"); if (!lib) { fprintf (stderr, "Cannot find or open library file\n"); exit (-1); } fseek (lib, 26 * loadindex, SEEK_SET); } if (fread (&libdeal, 26, 1, lib)) { int ph[4], i, suit, rank, pn; unsigned long su; libdeal.valid = 1; for (i = 0; i < 4; ++i) ph[i] = 13 * i; for (i = 0; i <= 4; ++i) { libdeal.tricks[i] = ntohs (libdeal.tricks[i]); } for (suit = 0; suit < 4; ++suit) { su = libdeal.suits[suit]; su = ntohl (su); for (rank = 0; rank < 13; ++rank) { pn = su & 0x03; su >>= 2; d[ph[pn]++] = MAKECARD (suit, 12 - rank); } } return 1; } else { libdeal.valid = 0; return 0; } } if (swapindex) { switch (swapindex) { case 1: swap2 (d, 1, 3); break; case 2: swap2 (d, 2, 3); break; case 3: swap2 (d, 1, 2); break; case 4: swap2 (d, 1, 3); break; case 5: swap2 (d, 2, 3); break; } } else { /* Algorithm according to Knuth. For each card exchange with a random other card. This is supposed to be the perfect shuffle algorithm. It only depends on a valid random number generator. */ for (i = 0; i < 52; i++) { if (stacked_pack[i] == NO_CARD) { /* Thorvald Aagaard 14.08.1999 don't switch a predealt card */ do { do { #ifdef STD_RAND k = RANDOM (); #else /* Upper bits most random */ k = (RANDOM () >> (31 - RANDBITS)); #endif /* STD_RAND */ j = zero52[k]; } while (j == 0xFF); } while (stacked_pack[j] != NO_CARD); t = d[j]; d[j] = d[i]; d[i] = t; } } } if (swapping) { ++swapindex; if ((swapping == 2 && swapindex > 1) || (swapping == 3 && swapindex > 5)) swapindex = 0; } return 1; } #ifdef FRANCOIS /* Specific routines for EXHAUST_MODE */ void exh_get2players (void) { /* Just finds who are the 2 players for whom we make exhaustive dealing */ int player, player_bit; for (player = COMPASS_NORTH, player_bit = 0; player<=COMPASS_WEST; player++) { if (completely_known_hand[player]) { if (use_compass[player]) { /* We refuse to compute anything for a player who has already his (her) 13 cards */ fprintf (stderr, "Exhaust-mode error: cannot compute anything for %s (known hand)%s", player_name[player],crlf); exit (-1); /*NOTREACHED */ } } else { if (player_bit == 2) { /* Exhaust mode only if *exactly* 2 hands have unknown cards */ fprintf (stderr, "Exhaust-mode error: more than 2 unknown hands...%s",crlf); exit (-1); /*NOTREACHED */ } exh_player[player_bit++] = player; } } if (player_bit < 2) { /* Exhaust mode only if *exactly* 2 hands have unknown cards */ fprintf (stderr, "Exhaust-mode error: less than 2 unknown hands...%s",crlf); exit (-1); /*NOTREACHED */ } } void exh_set_bit_values (int bit_pos, card onecard) { /* only sets up some tables (see table definitions above) */ int suit, rank; int suitloop; suit = C_SUIT (onecard); rank = C_RANK (onecard); for (suitloop = SUIT_CLUB; suitloop <= SUIT_SPADE; suitloop++) { exh_suit_points_at_map[suitloop][bit_pos] = (suit == suitloop ? tblPointcount[0][rank] :0); exh_suit_length_at_map[suitloop][bit_pos] = (suit == suitloop ? 1 : 0); } exh_card_map[onecard] = bit_pos; exh_card_at_bit[bit_pos] = onecard; } void exh_setup_card_map (void) { int i; for (i = 0; i < 256; i++) { exh_card_map[i] = -1; /* undefined */ } } void exh_map_cards (void) { register int i, i_player; int bit_pos; for (i = 0, bit_pos = 0; i < 52; i++) { if (fullpack[i] != NO_CARD) { exh_set_bit_values (bit_pos, fullpack[i]); bit_pos++; } } /* Some cards may also have been predealt for the exh-players. In that case, those cards are "put" in the msb positions of the vectordeal. The value of the exh_predealt_vector is the constant part of the vector deal. */ for (i_player = 0; i_player < 2; i_player++) { int player = exh_player[i_player]; exh_empty_slots[i_player] = 0; for (i = 13 * player; i < 13 * (player + 1); i++) { if (stacked_pack[i] == NO_CARD) { exh_empty_slots[i_player]++; } else { exh_set_bit_values (bit_pos, stacked_pack[i]); exh_predealt_vector |= (i_player << bit_pos); bit_pos++; } } } } void exh_print_stats (struct handstat *hs) { int s; for (s = SUIT_CLUB; s <= SUIT_SPADE; s++) { printf (" Suit %d: ", s); printf ("Len = %2d, Points = %2d\n", hs->hs_length[s], hs->hs_points[s]); } printf (" Totalpoints: %2d\n", hs->hs_totalpoints); } void exh_print_vector (struct handstat *hs) { int i, s, r; int onecard; struct handstat *hsp; printf ("Player %d: ", exh_player[0]); for (i = 0; i < 26; i++) { if (!(1 & (vectordeal >> i))) { onecard = exh_card_at_bit[i]; s = C_SUIT (onecard); r = C_RANK (onecard); printf ("%c%d ", ucrep[r], s); } } printf ("\n"); hsp = hs + exh_player[0]; exh_print_stats (hsp); printf ("Player %d: ", exh_player[1]); for (i = 0; i < 26; i++) { if ((1 & (vectordeal >> i))) { onecard = exh_card_at_bit[i]; s = C_SUIT (onecard); r = C_RANK (onecard); printf ("%c%d ", ucrep[r], s); } } printf ("\n"); hsp = hs + exh_player[1]; exh_print_stats (hsp); } void exh_precompute_analyse_tables (void) { /* This routine precomputes the values of the tables exh_lsb_... and exh_msb_... These tables will allow very fast computation of hand-primitives given the value of the vector deal. Example: the number of hcp in diamonds of the player 0 will be : exh_lsb_suit_length[vectordeal & (TWO_TO_THE_13-1)] + exh_msb_suit_length[vectordeal >> 13]; The way those table are precomputed may seem a little bit ridiculous. This may be the reminiscence of Z80-programming ;-) FD-0499 */ int vec_13; int i_bit; int suit; unsigned char *elsp, *emsp, *elt, *emt, *elsl, *emsl; unsigned char *mespam, *meslam; unsigned char *lespam, *leslam; for (vec_13 = 0; vec_13 < TWO_TO_THE_13; vec_13++) { elt = exh_lsb_totalpoints + vec_13; emt = exh_msb_totalpoints + vec_13; *elt = *emt = 0; for (suit = SUIT_CLUB; suit <= SUIT_SPADE; suit++) { elsp = exh_lsb_suit_points[suit] + vec_13; emsp = exh_msb_suit_points[suit] + vec_13; elsl = exh_lsb_suit_length[suit] + vec_13; emsl = exh_msb_suit_length[suit] + vec_13; lespam = exh_suit_points_at_map[suit] + 12; leslam = exh_suit_length_at_map[suit] + 12; mespam = exh_suit_points_at_map[suit] + 25; meslam = exh_suit_length_at_map[suit] + 25; *elsp = *emsp = *elsl = *emsl = 0; for (i_bit = 13; i_bit--; lespam--, leslam--, mespam--, meslam--) { if (!(1 & (vec_13 >> i_bit))) { *(elsp) += *lespam; *(emsp) += *mespam; *(elt) += *lespam; *(emt) += *mespam; *(elsl) += *leslam; *(emsl) += *meslam; } } } } for (suit = SUIT_CLUB; suit <= SUIT_SPADE; suit++) { exh_total_points_in_suit[suit] = exh_lsb_suit_points[suit][0] + exh_msb_suit_points[suit][0]; exh_total_cards_in_suit[suit] = exh_lsb_suit_length[suit][0] + exh_msb_suit_length[suit][0]; } exh_total_points = exh_lsb_totalpoints[0] + exh_msb_totalpoints[0]; } void exh_analyze_vec (int high_vec, int low_vec, struct handstat *hs) { /* analyse the 2 remaining hands with the vectordeal data-structure. This is VERY fast !!! */ int s; struct handstat *hs0; struct handstat *hs1; hs0 = hs + exh_player[0]; hs1 = hs + exh_player[1]; hs0->hs_totalpoints = hs1->hs_totalpoints = 0; for (s = SUIT_CLUB; s <= SUIT_SPADE; s++) { hs0->hs_length[s] = exh_lsb_suit_length[s][low_vec] + exh_msb_suit_length[s][high_vec]; hs0->hs_points[s] = exh_lsb_suit_points[s][low_vec] + exh_msb_suit_points[s][high_vec]; hs1->hs_length[s] = exh_total_cards_in_suit[s] - hs0->hs_length[s]; hs1->hs_points[s] = exh_total_points_in_suit[s] - hs0->hs_points[s]; } hs0->hs_totalpoints = exh_lsb_totalpoints[low_vec] + exh_msb_totalpoints[high_vec]; hs1->hs_totalpoints = exh_total_points - hs0->hs_totalpoints; hs0->hs_bits = distrbitmaps [hs0->hs_length[SUIT_CLUB]] [hs0->hs_length[SUIT_DIAMOND]] [hs0->hs_length[SUIT_HEART]] [hs0->hs_length[SUIT_SPADE]]; hs1->hs_bits = distrbitmaps [hs1->hs_length[SUIT_CLUB]] [hs1->hs_length[SUIT_DIAMOND]] [hs1->hs_length[SUIT_HEART]] [hs1->hs_length[SUIT_SPADE]]; } /* End of Specific routines for EXHAUST_MODE */ #endif /* FRANCOIS */ int trix (char c) { if (c >= '0' && c <= '9') return c - '0'; return c - 'A' + 10; } int evaltree (struct tree *t) { switch (t->tr_type) { default: assert (0); case TRT_NUMBER: return t->tr_int1; case TRT_AND2: return evaltree (t->tr_leaf1) && evaltree (t->tr_leaf2); case TRT_OR2: return evaltree (t->tr_leaf1) || evaltree (t->tr_leaf2); case TRT_ARPLUS: return evaltree (t->tr_leaf1) + evaltree (t->tr_leaf2); case TRT_ARMINUS: return evaltree (t->tr_leaf1) - evaltree (t->tr_leaf2); case TRT_ARTIMES: return evaltree (t->tr_leaf1) * evaltree (t->tr_leaf2); case TRT_ARDIVIDE: return evaltree (t->tr_leaf1) / evaltree (t->tr_leaf2); case TRT_ARMOD: return evaltree (t->tr_leaf1) % evaltree (t->tr_leaf2); case TRT_CMPEQ: return evaltree (t->tr_leaf1) == evaltree (t->tr_leaf2); case TRT_CMPNE: return evaltree (t->tr_leaf1) != evaltree (t->tr_leaf2); case TRT_CMPLT: return evaltree (t->tr_leaf1) < evaltree (t->tr_leaf2); case TRT_CMPLE: return evaltree (t->tr_leaf1) <= evaltree (t->tr_leaf2); case TRT_CMPGT: return evaltree (t->tr_leaf1) > evaltree (t->tr_leaf2); case TRT_CMPGE: return evaltree (t->tr_leaf1) >= evaltree (t->tr_leaf2); case TRT_NOT: return !evaltree (t->tr_leaf1); case TRT_LENGTH: /* suit, compass */ assert (t->tr_int1 >= SUIT_CLUB && t->tr_int1 <= SUIT_SPADE); assert (t->tr_int2 >= COMPASS_NORTH && t->tr_int2 <= COMPASS_WEST); return hs[t->tr_int2].hs_length[t->tr_int1]; case TRT_HCPTOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalpoints; case TRT_PT0TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxTens]; case TRT_PT1TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxJacks]; case TRT_PT2TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxQueens]; case TRT_PT3TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxKings]; case TRT_PT4TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxAces]; case TRT_PT5TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxTop2]; case TRT_PT6TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxTop3]; case TRT_PT7TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxTop4]; case TRT_PT8TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxTop5]; case TRT_PT9TOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcounts[idxC13]; case TRT_HCP: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_points[t->tr_int2]; case TRT_PT0: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxTens][t->tr_int2]; case TRT_PT1: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxJacks][t->tr_int2]; case TRT_PT2: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxQueens][t->tr_int2]; case TRT_PT3: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxKings][t->tr_int2]; case TRT_PT4: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxAces][t->tr_int2]; case TRT_PT5: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxTop2][t->tr_int2]; case TRT_PT6: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxTop3][t->tr_int2]; case TRT_PT7: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxTop4][t->tr_int2]; case TRT_PT8: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxTop5][t->tr_int2]; case TRT_PT9: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_counts[idxC13][t->tr_int2]; case TRT_SHAPE: /* compass, shapemask */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); /* assert (t->tr_int2 >= 0 && t->tr_int2 < MAXDISTR); */ return (hs[t->tr_int1].hs_bits & t->tr_int2) != 0; case TRT_HASCARD: /* compass, card */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); #ifdef FRANCOIS return hascard (curdeal, t->tr_int1, (card)t->tr_int2, vectordeal); #else return hascard (curdeal, t->tr_int1, (card)t->tr_int2); #endif /* FRANCOIS */ case TRT_LOSERTOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalloser; case TRT_LOSER: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_loser[t->tr_int2]; case TRT_CONTROLTOTAL: /* compass */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return hs[t->tr_int1].hs_totalcontrol; case TRT_CONTROL: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return hs[t->tr_int1].hs_control[t->tr_int2]; case TRT_CCCC: assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); return cccc (t->tr_int1); case TRT_QUALITY: assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= SUIT_SPADE); return quality (t->tr_int1, t->tr_int2); case TRT_IF: assert (t->tr_leaf2->tr_type == TRT_THENELSE); return (evaltree (t->tr_leaf1) ? evaltree (t->tr_leaf2->tr_leaf1) : evaltree (t->tr_leaf2->tr_leaf2)); case TRT_TRICKS: /* compass, suit */ assert (t->tr_int1 >= COMPASS_NORTH && t->tr_int1 <= COMPASS_WEST); assert (t->tr_int2 >= SUIT_CLUB && t->tr_int2 <= 1 + SUIT_SPADE); return dd (curdeal, t->tr_int1, t->tr_int2); case TRT_SCORE: /* vul/non_vul, contract, tricks in leaf1 */ assert (t->tr_int1 >= NON_VUL && t->tr_int1 <= VUL); return score (t->tr_int1, t->tr_int2 % 5, t->tr_int2 / 5, evaltree (t->tr_leaf1)); case TRT_IMPS: return imps (evaltree (t->tr_leaf1)); case TRT_RND: return (int) (((double) evaltree (t->tr_leaf1)) * RANDOM () / (RAND_MAX + 1.0)); } } /* This is a macro to replace the original code : int interesting () { return evaltree (decisiontree); } */ #define interesting() ((int)evaltree(decisiontree)) void setup_action () { struct action *acp; /* Initialize all actions */ for (acp = actionlist; acp != 0; acp = acp->ac_next) { switch (acp->ac_type) { default: assert (0); /*NOTREACHED */ case ACT_EVALCONTRACT: initevalcontract (); break; case ACT_PRINTCOMPACT: case ACT_PRINTPBN: case ACT_PRINTEW: case ACT_PRINTALL: case ACT_PRINTONELINE: case ACT_PRINTES: break; case ACT_PRINT: deallist = (deal *) mycalloc (maxproduce, sizeof (deal)); break; case ACT_AVERAGE: break; case ACT_FREQUENCY: acp->ac_u.acu_f.acuf_freqs = (long *) mycalloc ( acp->ac_u.acu_f.acuf_highbnd - acp->ac_u.acu_f.acuf_lowbnd + 1, sizeof (long)); break; case ACT_FREQUENCY2D: acp->ac_u.acu_f2d.acuf_freqs = (long *) mycalloc ( (acp->ac_u.acu_f2d.acuf_highbnd_expr1 - acp->ac_u.acu_f2d.acuf_lowbnd_expr1 + 3) * (acp->ac_u.acu_f2d.acuf_highbnd_expr2 - acp->ac_u.acu_f2d.acuf_lowbnd_expr2 + 3), sizeof (long)); break; } } } void action () { struct action *acp; int expr, expr2, val1, val2, high1 = 0, high2 = 0, low1 = 0, low2 = 0; for (acp = actionlist; acp != 0; acp = acp->ac_next) { switch (acp->ac_type) { default: assert (0); /*NOTREACHED */ case ACT_PRINTCOMPACT: printcompact (curdeal); if (acp->ac_expr1) { expr = evaltree (acp->ac_expr1); printf ("%d\n", expr); } break; case ACT_PRINTONELINE: printoneline (curdeal); if (acp->ac_expr1) { expr = evaltree (acp->ac_expr1); printf ("%d", expr); } printf ("\n"); break; case ACT_PRINTES: { struct expr *pex = (struct expr *) acp->ac_expr1; while (pex) { if (pex->ex_tr) { expr = evaltree (pex->ex_tr); printf ("%d", expr); } if (pex->ex_ch) { printf ("%s", pex->ex_ch); } pex = pex->next; } } break; case ACT_PRINTALL: printdeal (curdeal); break; case ACT_PRINTEW: printew (curdeal); break; case ACT_PRINTPBN: if (! quiet) printpbn (nprod, curdeal); break; case ACT_PRINT: memcpy (deallist[nprod], curdeal, sizeof (deal)); break; case ACT_AVERAGE: acp->ac_int1 += evaltree (acp->ac_expr1); break; case ACT_FREQUENCY: expr = evaltree (acp->ac_expr1); if (expr < acp->ac_u.acu_f.acuf_lowbnd) acp->ac_u.acu_f.acuf_uflow++; else if (expr > acp->ac_u.acu_f.acuf_highbnd) acp->ac_u.acu_f.acuf_oflow++; else acp->ac_u.acu_f.acuf_freqs[expr - acp->ac_u.acu_f.acuf_lowbnd]++; break; case ACT_FREQUENCY2D: expr = evaltree (acp->ac_expr1); expr2 = evaltree (acp->ac_expr2); high1 = acp->ac_u.acu_f2d.acuf_highbnd_expr1; high2 = acp->ac_u.acu_f2d.acuf_highbnd_expr2; low1 = acp->ac_u.acu_f2d.acuf_lowbnd_expr1; low2 = acp->ac_u.acu_f2d.acuf_lowbnd_expr2; if (expr > high1) val1 = high1 - low1 + 2; else { val1 = expr - low1 + 1; if (val1 < 0) val1 = 0; } if (expr2 > high2) val2 = high2 - low2 + 2; else { val2 = expr2 - low2 + 1; if (val2 < 0) val2 = 0; } acp->ac_u.acu_f2d.acuf_freqs[(high2 - low2 + 3) * val1 + val2]++; break; } } } void printhands (int boardno, deal * dealp, int player, int nhands) { int i, suit, rank, cards; for (i = 0; i < nhands; i++) printf ("%4d.%15c", boardno + i + 1, ' '); printf ("\n"); for (suit = SUIT_SPADE; suit >= SUIT_CLUB; suit--) { cards = 10; for (i = 0; i < nhands; i++) { while (cards < 10) { printf (" "); cards++; } cards = 0; for (rank = 12; rank >= 0; rank--) { if (HAS_CARD (dealp[i], player, MAKECARD (suit, rank))) { printf ("%c ", ucrep[rank]); cards++; } } if (cards == 0) { printf ("- "); cards++; } } printf ("\n"); } printf ("\n"); } void cleanup_action () { struct action *acp; int player, i; for (acp = actionlist; acp != 0; acp = acp->ac_next) { switch (acp->ac_type) { default: assert (0); /*NOTREACHED */ case ACT_PRINTALL: case ACT_PRINTCOMPACT: case ACT_PRINTPBN: case ACT_PRINTEW: case ACT_PRINTONELINE: case ACT_PRINTES: break; case ACT_EVALCONTRACT: showevalcontract (nprod); break; case ACT_PRINT: for (player = COMPASS_NORTH; player <= COMPASS_WEST; player++) { if (!(acp->ac_int1 & (1 << player))) continue; printf ("\n\n%s hands:\n\n\n\n", player_name[player]); for (i = 0; i < nprod; i += 4) printhands (i, deallist + i, player, nprod - i > 4 ? 4 : nprod - i); printf ("\f"); } break; case ACT_AVERAGE: if (acp->ac_str1) printf ("%s: ", acp->ac_str1); printf ("%g\n", (double) acp->ac_int1 / nprod); break; case ACT_FREQUENCY: printf ("Frequency %s:\n", acp->ac_str1 ? acp->ac_str1 : ""); if (acp->ac_u.acu_f.acuf_uflow) printf ("Low\t%8ld\n", acp->ac_u.acu_f.acuf_uflow); for (i = acp->ac_u.acu_f.acuf_lowbnd; i <= acp->ac_u.acu_f.acuf_highbnd; i++) printf ("%5d\t%8ld\n", i, acp->ac_u.acu_f.acuf_freqs[i - acp->ac_u.acu_f.acuf_lowbnd]); if (acp->ac_u.acu_f.acuf_oflow) printf ("High\t%8ld\n", acp->ac_u.acu_f.acuf_oflow); break; case ACT_FREQUENCY2D: { int j, n = 0, low1 = 0, high1 = 0, low2 = 0, high2 = 0, sumrow, sumtot, sumcol; printf ("Frequency %s:%s", acp->ac_str1 ? acp->ac_str1 : "", crlf); high1 = acp->ac_u.acu_f2d.acuf_highbnd_expr1; high2 = acp->ac_u.acu_f2d.acuf_highbnd_expr2; low1 = acp->ac_u.acu_f2d.acuf_lowbnd_expr1; low2 = acp->ac_u.acu_f2d.acuf_lowbnd_expr2; printf (" Low"); for (j = 1; j < (high2 - low2) + 2; j++) printf (" %6d", j + low2 - 1); printf (" High Sum%s", crlf); sumtot = 0; for (i = 0; i < (high1 - low1) + 3; i++) { sumrow = 0; if (i == 0) printf ("Low "); else if (i == (high1 - low1 + 2)) printf ("High"); else printf ("%4d", i + low1 - 1); for (j = 0; j < (high2 - low2) + 3; j++) { n = acp->ac_u.acu_f2d.acuf_freqs[(high2 - low2 + 3) * i + j]; sumrow += n; printf (" %6d", n); } printf (" %6d%s", sumrow, crlf); sumtot += sumrow; } printf ("Sum "); for (j = 0; j < (high2 - low2) + 3; j++) { sumcol = 0; for (i = 0; i < (high1 - low1) + 3; i++) sumcol += acp->ac_u.acu_f2d.acuf_freqs[(high2 - low2 + 3) * i + j]; printf (" %6d", sumcol); } printf (" %6d%s%s", sumtot, crlf, crlf); } } } } int yywrap () { /* Necessary if you do not have a -ll library */ return 1; } void printew (deal d) { /* This function prints the east and west hands only (with west to the left of east), primarily intended for examples of auctions with 2 players only. HU. */ int suit, player, rank, cards; for (suit = SUIT_SPADE; suit >= SUIT_CLUB; suit--) { cards = 10; for (player = COMPASS_WEST; player >= COMPASS_EAST; player--) { if (player != COMPASS_SOUTH) { while (cards < 10) { printf (" "); cards++; } cards = 0; for (rank = 12; rank >= 0; rank--) { if (HAS_CARD (d, player, MAKECARD (suit, rank))) { printf ("%c ", ucrep[rank]); cards++; } } if (cards == 0) { printf ("- "); cards++; } } } printf ("\n"); } printf ("\n"); } int main (int argc, char **argv) { int seed_provided = 0; extern int optind; extern char *optarg; char c; int errflg = 0; int progressmeter = 0; int i=0; struct timeval tvstart, tvstop; verbose = 1; gettimeofday (&tvstart, (void *) 0); while ((c = getopt (argc, argv, "023ehuvmqp:g:s:l:V")) != -1) { switch (c) { case '0': case '2': case '3': swapping = c - '0'; break; case 'e': #ifdef FRANCOIS computing_mode = EXHAUST_MODE; break; #else /* Break if code not included in executable */ printf ("Exhaust mode not included in this executable\n"); return 1; #endif /* FRANCOIS */ case 'l': loading = 1; loadindex = atoi (optarg); break; case 'g': maxgenerate = atoi (optarg); break; case 'm': progressmeter ^= 1; break; case 'p': maxproduce = atoi (optarg); break; case 's': seed_provided = 1; seed = atol (optarg); if (seed == LONG_MIN || seed == LONG_MAX) { fprintf (stderr, "Seed overflow: seed must be between %ld and %ld\n", LONG_MIN, LONG_MAX); exit (-1); } break; case 'u': uppercase = 1; break; case 'v': verbose ^= 1; break; case 'q': quiet ^= 1; break; case 'V': printf ("Version info....\n"); printf ("$Revision: 1.24 $\n"); printf ("$Date: 2003/08/05 19:53:04 $\n"); printf ("$Author: henk $\n"); return 1; case '?': case 'h': errflg = 1; break; } } if (argc - optind > 2 || errflg) { fprintf (stderr, "Usage: %s [-emvu] [-s seed] [-p num] [-v num] [inputfile]\n", argv[0]); exit (-1); } if (optind < argc && freopen (input_file = argv[optind], "r", stdin) == NULL) { perror (argv[optind]); exit (-1); } newpack (fullpack); /* Empty pack */ for (i = 0; i < 52; i++) stacked_pack[i] = NO_CARD; initdistr (); maxdealer = -1; maxvuln = -1; yyparse (); /* The most suspect part of this program */ if (!seed_provided) { (void) time (&seed); } SRANDOM (seed); initprogram (); if (maxgenerate == 0) maxgenerate = 10000000; if (maxproduce == 0) maxproduce = ((actionlist == &defaultaction) || will_print) ? 40 : maxgenerate; setup_action (); if (progressmeter) fprintf (stderr, "Calculating... 0%% complete\r"); switch (computing_mode) { case STAT_MODE: setup_deal (); for (ngen = nprod = 0; ngen < maxgenerate && nprod < maxproduce; ngen++) { shuffle (curdeal); analyze (curdeal, hs); if (interesting ()) { action (); nprod++; if (progressmeter) { if ((100 * nprod / maxproduce) > 100 * (nprod - 1) / maxproduce) fprintf (stderr, "Calculating... %2d%% complete\r", 100 * nprod / maxproduce); } } } break; #ifdef FRANCOIS case EXHAUST_MODE: { int i, j, half, ham13, c_tsize[14], highvec, *lowvec_ptr; int emptyslots; exh_get2players (); exh_setup_card_map (); exh_map_cards (); exh_precompute_analyse_tables (); emptyslots = exh_empty_slots[0] + exh_empty_slots[1]; /* building the T table : o HAM_T[ham13] will contain all the 13-bits vector that have a hamming weight 'ham13' o Tsize[ham13] will contain the number of such possible vectors: 13/(ham13!(13-ham13)!) o Tsize will be mirrored into c_tsize */ for (c_tsize[i = 13] = Tsize[i = 13] = 1, HAM_T[13] = (int *) malloc (sizeof (int)); i--;) HAM_T[i] = (int *) malloc (sizeof (int) * (c_tsize[i] = Tsize[i] = Tsize[i + 1] * (i + 1) / (13 - i))); /* one generate the 2^13 possible half-vectors and : o compute its hamming weight; o store it into the table T */ for (half = 1 << 13; half--;) { for (ham13 = 0, i = 13; i--;) ham13 += (half >> i) & 1; HAM_T[ham13][--c_tsize[ham13]] = half; } for (ham13 = 14; ham13--;) for (i = Tsize[ham13]; i--;) { highvec = HAM_T[ham13][i]; if (!(((highvec << 13) ^ exh_predealt_vector) >> emptyslots)) { for (lowvec_ptr = HAM_T[13 - ham13], j = Tsize[ham13]; j--; lowvec_ptr++) { ngen++; vectordeal = (highvec << 13) | *lowvec_ptr; exh_analyze_vec (highvec, *lowvec_ptr, hs); if (interesting ()) { /* exh_print_vector(hs); */ action (); nprod++; } } } } } break; #endif /* FRANCOIS */ default: fprintf (stderr, "Unrecognized computation mode...\n"); exit (-1); /*NOTREACHED */ } if (progressmeter) fprintf (stderr, " \r"); gettimeofday (&tvstop, (void *) 0); cleanup_action (); if (verbose) { printf ("Generated %d hands\n", ngen); printf ("Produced %d hands\n", nprod); printf ("Initial random seed %lu\n", seed); printf ("Time needed %8.3f sec%s", (tvstop.tv_sec + tvstop.tv_usec / 1000000.0 - (tvstart.tv_sec + tvstart.tv_usec / 1000000.0)), crlf); } return 0; } dealer/dealer.h0100644000076400001440000000351710056165030012572 0ustar henkusers#ifndef DEALER_H #define DEALER_H typedef unsigned char card; typedef card deal[52]; static char *player_name[] = { "North", "East", "South", "West" }; int verbose; /* Changes for cccc and quality */ struct context { deal *pd ; /* pointer to current deal */ struct handstat *ps ; /* Pointer to stats of current deal */ } c; #ifdef STD_RAND #define RANDOM rand #define SRANDOM(seed) srand(seed) ; #else #define RANDOM gnurand int gnurand (); #define SRANDOM(seed) gnusrand(seed) int gnusrand (int); #endif /* STD_RAND */ #include "pointcount.h" struct handstat { int hs_length[NSUITS]; /* distribution */ int hs_points[NSUITS]; /* 4321 HCP per suit */ int hs_fl[NSUITS]; /* FL per suit */ int hs_fv[NSUITS]; /* FV per suit */ int hs_together[NSUITS]; /* Length together with partner */ int hs_totalpoints; /* Sum of above four */ int hs_totalfl; /* Sum of above four */ int hs_totalfv; /* Sum of above four */ int hs_bits; /* Bitmap to check distribution */ int hs_loser[NSUITS]; /* Losers in a suit */ int hs_totalloser; /* Losers in the hand */ int hs_control[NSUITS]; /* Controls in a suit */ int hs_totalcontrol; /* Controls in the hand */ int hs_counts[idxEnd][NSUITS]; /* other auxiliary counts */ int hs_totalcounts[idxEnd]; /* totals of the above */ } ; struct handstat hs[4] ; deal curdeal; int maxgenerate; int maxdealer; int maxvuln; int will_print; #define printcompact(d) (fprintcompact(stdout, d, 0)) #define printoneline(d) (fprintcompact(stdout, d, 1)) #ifdef FRANCOIS int hascard (deal, int, card, int); #define HAS_CARD(d,p,c) hascard(d,p,c,0) #else int hascard (deal, int, card); #define HAS_CARD(d,p,c) hascard(d,p,c) #endif #endif /* DEALER_H */ dealer/defs.c0100644000076400001440000020575510056357700012271 0ustar henkusers#ifndef lint /*static char yysccsid[] = "from: @(#)yaccpar 1.9 (Berkeley) 02/21/93";*/ static char yyrcsid[] = "$Id: skeleton.c,v 1.4 1993/12/21 18:45:32 jtc Exp $"; #endif #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 #define yyclearin (yychar=(-1)) #define yyerrok (yyerrflag=0) #define YYRECOVERING (yyerrflag!=0) #define YYPREFIX "yy" #line 2 "defs.y" #include #include #ifdef WIN32 /* void * _alloca( size_t ) ;*/ #define alloca _alloca #endif /* WIN32 */ #include #include "tree.h" #include "dealer.h" void yyerror (char*); void setshapebit (int, int, int, int, int, int); void predeal (int, card); card make_card(char,char); void clearpointcount(void); void clearpointcount_alt(int); void pointcount(int,int); void* mycalloc(int,size_t); int make_contract (char, char); int predeal_compass; /* global variable for predeal communication */ int pointcount_index; /* global variable for pointcount communication */ int shapeno ; struct tree *var_lookup(char *s, int mustbethere) ; struct action *newaction(int type, struct tree * p1, char * s1, int, struct tree * ) ; struct tree *newtree (int, struct tree*, struct tree*, int, int); struct expr *newexpr(struct tree* tr1, char* ch1, struct expr* ex1); void bias_deal(int suit, int compass, int length) ; void predeal_holding(int compass, char *holding) ; void insertshape(char s[4], int any, int neg_shape) ; void new_var(char *s, struct tree *t) ; #line 43 "defs.y" typedef union { int y_int; char *y_str; struct tree *y_tree; struct action *y_action; struct expr *y_expr; char y_distr[4]; } YYSTYPE; #line 61 "y.tab.c" #define QUERY 257 #define COLON 258 #define OR2 259 #define AND2 260 #define CMPEQ 261 #define CMPNE 262 #define CMPLT 263 #define CMPLE 264 #define CMPGT 265 #define CMPGE 266 #define ARPLUS 267 #define ARMINUS 268 #define ARTIMES 269 #define ARDIVIDE 270 #define ARMOD 271 #define NOT 272 #define GENERATE 273 #define PRODUCE 274 #define HCP 275 #define SHAPE 276 #define ANY 277 #define EXCEPT 278 #define CONDITION 279 #define ACTION 280 #define PRINT 281 #define PRINTALL 282 #define PRINTEW 283 #define PRINTPBN 284 #define PRINTCOMPACT 285 #define PRINTONELINE 286 #define AVERAGE 287 #define HASCARD 288 #define FREQUENCY 289 #define PREDEAL 290 #define POINTCOUNT 291 #define ALTCOUNT 292 #define CONTROL 293 #define LOSER 294 #define DEALER 295 #define VULNERABLE 296 #define QUALITY 297 #define CCCC 298 #define TRICKS 299 #define NOTRUMPS 300 #define NORTHSOUTH 301 #define EASTWEST 302 #define EVALCONTRACT 303 #define ALL 304 #define NONE 305 #define SCORE 306 #define IMPS 307 #define RND 308 #define PT0 309 #define PT1 310 #define PT2 311 #define PT3 312 #define PT4 313 #define PT5 314 #define PT6 315 #define PT7 316 #define PT8 317 #define PT9 318 #define PRINTES 319 #define NUMBER 320 #define HOLDING 321 #define STRING 322 #define IDENT 323 #define COMPASS 324 #define VULN 325 #define SUIT 326 #define CARD 327 #define CONTRACT 328 #define DISTR 329 #define DISTR_OR_NUMBER 330 #define YYERRCODE 256 short yylhs[] = { -1, 0, 0, 13, 13, 13, 13, 13, 16, 13, 17, 13, 13, 13, 13, 13, 14, 14, 20, 18, 18, 19, 19, 15, 21, 15, 3, 7, 5, 5, 5, 5, 6, 6, 2, 2, 2, 8, 8, 22, 23, 23, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 11, 11, 11, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 4, 4, }; short yylen[] = { 2, 0, 2, 2, 2, 2, 2, 2, 0, 3, 0, 4, 2, 1, 3, 2, 1, 2, 0, 3, 6, 1, 3, 0, 0, 3, 1, 1, 1, 1, 0, 1, 0, 1, 1, 2, 1, 1, 1, 3, 1, 2, 1, 1, 4, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 6, 6, 6, 6, 8, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 2, 4, 1, 1, 3, 3, 1, 3, 0, 1, 1, 4, 1, 1, 1, 4, 1, 4, 4, 3, 9, 15, 0, 1, 1, 3, }; short yydefred[] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 36, 0, 0, 42, 2, 35, 43, 94, 3, 4, 0, 0, 0, 0, 103, 104, 108, 0, 0, 0, 0, 110, 0, 15, 0, 0, 18, 0, 0, 16, 0, 10, 0, 0, 26, 5, 27, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 117, 0, 0, 0, 0, 0, 0, 0, 17, 24, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 91, 92, 45, 0, 0, 118, 0, 0, 0, 0, 0, 97, 0, 0, 101, 0, 21, 0, 0, 0, 11, 69, 0, 67, 0, 0, 71, 0, 0, 78, 95, 47, 0, 49, 0, 51, 0, 53, 0, 55, 0, 57, 0, 59, 0, 61, 0, 63, 0, 65, 0, 44, 0, 0, 29, 31, 28, 0, 40, 0, 105, 0, 111, 112, 0, 109, 0, 0, 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 33, 0, 73, 41, 119, 0, 99, 0, 74, 22, 0, 70, 68, 72, 76, 75, 0, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 37, 38, 39, 0, 20, 0, 0, 77, 0, 114, 0, 0, 0, 0, 0, 0, 115, }; short yydgoto[] = { 1, 39, 40, 72, 164, 215, 248, 74, 276, 60, 61, 171, 114, 41, 65, 123, 67, 124, 66, 175, 119, 177, 216, 217, }; short yysindex[] = { 0, 1640, -302, 1805, -266, -266, -9, 34, 1805, -270, 36, -317, 0, -266, 47, 77, -304, -256, 108, 142, 145, 146, 147, 148, 151, 152, 154, 155, 156, 157, 158, 159, 160, 161, 0, -15, 162, 0, 1805, -139, 0, 0, 0, 0, 0, 0, 0, -304, -304, -139, 163, 0, 0, 0, 164, 165, -116, -116, 0, 167, 0, 166, -115, 0, 168, -317, 0, -266, 0, -304, -304, 0, 0, 0, 0, -304, -304, -304, -114, 1805, 1805, -304, -304, -304, -304, -304, -304, -304, -304, -304, -304, 1805, -304, -41, 1805, 1805, 1805, 1805, 1805, 1805, 1805, 1805, 1805, 1805, 1805, 1805, 1805, 1805, -2, 169, -112, 1805, 1805, 0, 1805, 174, 1693, -270, 171, -104, -89, 0, 0, 0, -266, 4, 6, 192, 211, 209, 210, -20, 1979, 17, 18, 19, 26, 121, 122, 123, 127, 128, 129, -139, 214, 0, -168, -110, -157, -241, -241, -233, -233, -233, -233, -218, -218, 0, 0, 0, 0, -70, -34, 0, 133, 1994, 2009, -139, 1805, 0, -139, 134, 0, -68, 0, 213, 242, -266, 0, 0, -42, 0, -40, -39, 0, -294, -43, 0, 0, 0, -38, 0, -25, 0, -24, 0, -23, 0, -22, 0, -21, 0, -3, 0, -1, 0, 2, 0, 3, 0, 1805, 249, 0, 0, 0, 29, 0, -36, 0, 20, 0, 0, 2048, 0, 1749, 281, 5, 69, 0, 304, 305, 311, 312, 315, 313, 317, 318, 321, 334, 335, 336, 337, 338, 339, 355, -126, 0, 0, -261, 0, 0, 0, -266, 0, -139, 0, 0, 79, 0, 0, 0, 0, 0, 1805, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 353, 0, 2033, -266, 0, 135, 0, 1805, 2089, -266, 356, -266, 361, 0, }; short yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1323, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1395, 0, 0, 0, 0, 1076, 1135, 1864, 167, 0, 0, 0, 1203, 0, 0, 0, 1463, 0, 1584, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1002, 0, 0, 0, 0, 0, 0, 1584, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1524, 0, 0, 0, 799, 721, 557, 639, 238, 320, 394, 480, 75, 149, 0, 0, 0, 0, 0, -274, 0, 0, 0, 0, 1263, 0, 0, 139, 0, 0, 0, 0, 942, 0, 1584, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -183, 0, -274, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 876, 0, 0, 0, 0, 0, 0, 0, 0, 140, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; short yygindex[] = { 0, 2121, 718, -4, 0, 0, 0, 0, 0, 286, 0, 0, 347, 0, 0, -120, 0, 0, 354, 0, 0, 0, 201, 0, }; #define YYTABLESIZE 2405 short yytable[] = { 145, 43, 2, 30, 178, 249, 232, 63, 214, 64, 214, 50, 51, 52, 53, 54, 55, 56, 42, 57, 71, 187, 99, 100, 101, 102, 103, 104, 105, 106, 107, 47, 233, 58, 103, 104, 105, 106, 107, 160, 73, 43, 161, 108, 109, 179, 91, 181, 180, 59, 182, 105, 106, 107, 34, 30, 30, 228, 189, 191, 193, 190, 192, 194, 37, 125, 126, 195, 274, 275, 196, 127, 128, 129, 48, 88, 62, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 69, 144, 94, 210, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 88, 88, 70, 94, 88, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 32, 32, 75, 89, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 197, 199, 201, 198, 200, 202, 203, 205, 207, 204, 206, 208, 218, 223, 283, 219, 224, 284, 96, 98, 76, 96, 98, 77, 78, 79, 80, 89, 89, 81, 82, 89, 83, 84, 85, 86, 87, 88, 89, 90, 92, 110, 111, 112, 113, 116, 120, 118, 117, 130, 163, 162, 168, 173, 94, 174, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 212, 213, 212, 213, 176, 183, 94, 82, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 184, 185, 186, 209, 211, 226, 43, 225, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 82, 82, 43, 43, 82, 227, 229, 234, 230, 231, 235, 43, 246, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 236, 237, 238, 239, 240, 247, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 83, 43, 255, 241, 43, 242, 256, 43, 243, 244, 257, 43, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 251, 258, 259, 88, 88, 88, 88, 88, 260, 261, 88, 88, 262, 263, 264, 265, 83, 83, 266, 88, 83, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 267, 268, 269, 270, 271, 272, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 84, 88, 273, 280, 88, 278, 288, 88, 290, 172, 115, 88, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 250, 121, 0, 89, 89, 89, 89, 89, 0, 0, 89, 89, 0, 0, 0, 0, 84, 84, 0, 89, 84, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 0, 0, 0, 0, 0, 0, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 0, 89, 0, 0, 89, 0, 0, 89, 0, 0, 0, 89, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 0, 0, 0, 0, 0, 82, 82, 82, 82, 82, 0, 0, 82, 82, 0, 85, 85, 0, 0, 85, 0, 82, 0, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 0, 0, 0, 0, 0, 0, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 80, 82, 0, 0, 82, 0, 0, 82, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 0, 0, 0, 0, 0, 83, 83, 83, 83, 83, 80, 80, 83, 83, 80, 0, 0, 0, 0, 0, 0, 83, 0, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 0, 0, 0, 0, 0, 0, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 81, 83, 0, 0, 83, 0, 0, 83, 0, 0, 0, 83, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 0, 0, 0, 0, 0, 84, 84, 84, 84, 84, 0, 0, 84, 84, 0, 0, 0, 0, 81, 81, 0, 84, 81, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 0, 0, 0, 0, 0, 0, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 0, 84, 0, 0, 84, 0, 0, 84, 86, 45, 46, 84, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 0, 0, 0, 0, 0, 85, 85, 85, 85, 85, 0, 0, 85, 85, 86, 86, 0, 0, 86, 0, 0, 85, 0, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 0, 0, 0, 0, 0, 122, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 87, 85, 0, 0, 85, 0, 0, 85, 0, 0, 0, 85, 0, 0, 0, 80, 80, 80, 80, 80, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 80, 80, 80, 80, 0, 0, 80, 80, 0, 87, 87, 0, 122, 87, 0, 80, 0, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 0, 0, 0, 0, 0, 0, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 93, 80, 0, 0, 80, 0, 0, 80, 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, 122, 81, 81, 81, 81, 81, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 81, 81, 81, 81, 93, 93, 81, 81, 93, 0, 0, 0, 0, 0, 0, 81, 0, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 0, 0, 0, 19, 0, 0, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 0, 81, 0, 0, 81, 0, 0, 81, 0, 0, 0, 81, 277, 0, 0, 0, 0, 0, 0, 0, 86, 86, 86, 86, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 86, 86, 86, 86, 282, 0, 86, 86, 102, 0, 287, 0, 289, 0, 0, 86, 0, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 0, 0, 0, 0, 0, 0, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 0, 86, 102, 0, 86, 0, 0, 86, 0, 0, 0, 86, 0, 0, 0, 0, 87, 87, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 87, 87, 87, 87, 106, 0, 87, 87, 0, 0, 0, 0, 0, 0, 0, 87, 0, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 0, 0, 0, 0, 0, 0, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 0, 87, 106, 0, 87, 0, 0, 87, 0, 0, 0, 87, 0, 0, 0, 93, 93, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 93, 93, 93, 93, 0, 0, 93, 93, 0, 0, 0, 0, 0, 0, 0, 93, 0, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 0, 0, 0, 107, 0, 0, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 0, 93, 0, 0, 93, 0, 0, 93, 100, 0, 0, 93, 0, 0, 0, 19, 0, 0, 0, 19, 19, 19, 19, 19, 0, 0, 19, 19, 0, 0, 0, 0, 0, 0, 0, 19, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 100, 0, 0, 0, 0, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 19, 113, 0, 19, 19, 0, 19, 0, 102, 0, 19, 0, 102, 102, 102, 102, 102, 0, 0, 102, 102, 0, 0, 0, 0, 0, 0, 0, 102, 0, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 0, 113, 0, 0, 0, 113, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 0, 102, 13, 0, 102, 0, 0, 102, 0, 0, 0, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106, 0, 0, 0, 106, 106, 106, 106, 106, 0, 0, 106, 106, 0, 0, 0, 0, 0, 0, 13, 106, 0, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 0, 0, 0, 0, 0, 0, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 12, 106, 0, 0, 106, 0, 0, 106, 107, 0, 0, 106, 107, 107, 107, 107, 107, 0, 0, 107, 107, 0, 0, 0, 0, 0, 0, 0, 107, 0, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 12, 0, 0, 0, 0, 0, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 0, 107, 0, 0, 107, 0, 0, 107, 0, 7, 0, 107, 0, 0, 0, 0, 0, 100, 0, 0, 0, 100, 100, 100, 100, 100, 0, 0, 100, 100, 0, 0, 0, 0, 0, 0, 0, 100, 0, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 7, 0, 0, 0, 0, 0, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 0, 100, 14, 0, 100, 0, 0, 100, 0, 0, 0, 100, 0, 113, 113, 113, 113, 113, 0, 0, 113, 113, 0, 0, 0, 0, 0, 0, 0, 113, 0, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 0, 14, 0, 0, 0, 0, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 0, 113, 23, 0, 113, 0, 0, 113, 0, 0, 0, 113, 0, 13, 13, 13, 13, 13, 0, 0, 13, 13, 0, 0, 0, 0, 0, 0, 0, 13, 0, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 0, 23, 0, 0, 0, 0, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 0, 13, 0, 0, 13, 0, 0, 13, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12, 12, 0, 0, 12, 12, 0, 0, 0, 0, 38, 0, 0, 12, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 12, 0, 0, 12, 0, 0, 12, 0, 0, 0, 12, 0, 0, 0, 0, 0, 7, 0, 38, 0, 7, 7, 7, 7, 7, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 0, 0, 7, 0, 0, 38, 0, 0, 0, 7, 0, 0, 14, 14, 14, 14, 14, 0, 0, 14, 14, 0, 0, 0, 0, 0, 0, 0, 14, 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 0, 0, 0, 0, 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 14, 38, 0, 14, 0, 0, 14, 0, 0, 0, 14, 0, 23, 23, 23, 23, 23, 0, 0, 23, 23, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 116, 0, 0, 23, 2, 0, 23, 0, 3, 4, 5, 6, 7, 0, 0, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, 34, 2, 0, 35, 0, 3, 36, 0, 6, 7, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 14, 15, 0, 0, 18, 19, 20, 0, 0, 0, 0, 0, 0, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, 34, 0, 169, 43, 2, 0, 36, 188, 3, 0, 37, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 220, 0, 10, 0, 0, 0, 0, 14, 15, 0, 0, 18, 19, 20, 0, 221, 0, 0, 0, 0, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 0, 34, 0, 253, 43, 2, 281, 36, 0, 3, 0, 37, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, 10, 0, 0, 0, 0, 14, 15, 0, 0, 18, 19, 20, 0, 0, 0, 0, 0, 0, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 44, 34, 0, 0, 43, 49, 0, 36, 116, 286, 0, 37, 116, 0, 0, 116, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 116, 0, 0, 0, 0, 116, 116, 93, 0, 116, 116, 116, 0, 0, 0, 0, 0, 0, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 0, 116, 0, 0, 116, 0, 0, 116, 0, 0, 0, 116, 0, 0, 0, 0, 0, 131, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 143, 0, 0, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 0, 0, 0, 165, 166, 0, 167, 94, 170, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 94, 0, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 94, 0, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 0, 0, 0, 0, 0, 0, 0, 0, 222, 94, 0, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 94, 0, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 94, 0, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 279, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 285, }; short yycheck[] = { 41, 0, 268, 277, 124, 41, 300, 324, 44, 326, 44, 281, 282, 283, 284, 285, 286, 287, 320, 289, 324, 41, 263, 264, 265, 266, 267, 268, 269, 270, 271, 40, 326, 303, 267, 268, 269, 270, 271, 41, 296, 40, 44, 47, 48, 41, 61, 41, 44, 319, 44, 269, 270, 271, 320, 329, 330, 177, 41, 41, 41, 44, 44, 44, 330, 69, 70, 41, 329, 330, 44, 75, 76, 77, 40, 0, 40, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 40, 92, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 40, 41, 40, 257, 44, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 329, 330, 40, 0, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 41, 41, 41, 44, 44, 44, 41, 41, 41, 44, 44, 44, 41, 41, 41, 44, 44, 44, 41, 41, 40, 44, 44, 40, 40, 40, 40, 40, 41, 40, 40, 44, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 322, 40, 40, 324, 44, 325, 324, 44, 40, 44, 257, 321, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 267, 268, 267, 268, 324, 44, 257, 0, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 41, 44, 44, 41, 326, 44, 257, 327, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 40, 41, 279, 280, 44, 41, 326, 328, 326, 326, 326, 288, 41, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 326, 326, 326, 326, 326, 277, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 0, 320, 41, 326, 323, 326, 321, 326, 326, 326, 261, 330, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 324, 41, 41, 272, 273, 274, 275, 276, 41, 41, 279, 280, 41, 44, 41, 41, 40, 41, 41, 288, 44, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 41, 41, 41, 41, 41, 41, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 0, 320, 41, 44, 323, 320, 44, 326, 41, 117, 57, 330, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 217, 65, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, 40, 41, -1, 288, 44, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, -1, 323, -1, -1, 326, -1, -1, -1, 330, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, 40, 41, -1, -1, 44, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 0, 320, -1, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, -1, -1, -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, 40, 41, 279, 280, 44, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 0, 320, -1, -1, 323, -1, -1, 326, -1, -1, -1, 330, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, 40, 41, -1, 288, 44, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, -1, 323, -1, -1, 326, 0, 4, 5, 330, -1, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, 40, 41, -1, -1, 44, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, 67, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 0, 320, -1, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, -1, -1, 257, 258, 259, 260, 261, 262, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, 40, 41, -1, 124, 44, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 0, 320, -1, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, -1, -1, -1, -1, -1, -1, 177, 257, 258, 259, 260, 261, 262, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, 40, 41, 279, 280, 44, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, 0, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, -1, 323, -1, -1, 326, -1, -1, -1, 330, 252, -1, -1, -1, -1, -1, -1, -1, 257, 258, 259, 260, 40, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, 280, -1, 279, 280, 0, -1, 286, -1, 288, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, 40, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, -1, -1, -1, 257, 258, 259, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, 0, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, 44, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, -1, -1, 257, 258, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, 44, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, -1, 323, -1, -1, 326, 0, -1, -1, 330, -1, -1, -1, 268, -1, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, 40, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, 0, -1, 323, 324, -1, 326, -1, 268, -1, 330, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, 40, -1, -1, -1, 44, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, 0, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 268, -1, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, 40, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 0, 320, -1, -1, 323, -1, -1, 326, 268, -1, -1, 330, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 40, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, -1, 323, -1, -1, 326, -1, 0, -1, 330, -1, -1, -1, -1, -1, 268, -1, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 40, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, 0, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, 40, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, 0, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, 40, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, 40, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, -1, -1, -1, -1, 268, -1, 40, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, -1, 323, -1, -1, 40, -1, -1, -1, 330, -1, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, 40, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 40, -1, -1, 323, 268, -1, 326, -1, 272, 273, 274, 275, 276, -1, -1, 279, 280, -1, -1, -1, -1, -1, -1, -1, 288, -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, 268, -1, 323, -1, 272, 326, -1, 275, 276, 330, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 288, -1, -1, -1, -1, 293, 294, -1, -1, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, 322, 323, 268, -1, 326, 41, 272, -1, 330, 275, 276, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, -1, 288, -1, -1, -1, -1, 293, 294, -1, -1, 297, 298, 299, -1, 41, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, 322, 323, 268, 41, 326, -1, 272, -1, 330, 275, 276, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 288, -1, -1, -1, -1, 293, 294, -1, -1, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 3, 320, -1, -1, 323, 8, -1, 326, 268, 44, -1, 330, 272, -1, -1, 275, 276, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 288, -1, -1, -1, -1, 293, 294, 38, -1, 297, 298, 299, -1, -1, -1, -1, -1, -1, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, -1, 320, -1, -1, 323, -1, -1, 326, -1, -1, -1, 330, -1, -1, -1, -1, -1, 79, 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 91, -1, -1, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, -1, -1, -1, 111, 112, -1, 114, 257, 116, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 257, -1, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 257, -1, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, -1, -1, -1, -1, -1, -1, -1, -1, 168, 257, -1, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 257, -1, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 210, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 224, 257, -1, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 263, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 284, }; #define YYFINAL 1 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 330 #if YYDEBUG char *yyname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'='",0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"QUERY","COLON", "OR2","AND2","CMPEQ","CMPNE","CMPLT","CMPLE","CMPGT","CMPGE","ARPLUS","ARMINUS", "ARTIMES","ARDIVIDE","ARMOD","NOT","GENERATE","PRODUCE","HCP","SHAPE","ANY", "EXCEPT","CONDITION","ACTION","PRINT","PRINTALL","PRINTEW","PRINTPBN", "PRINTCOMPACT","PRINTONELINE","AVERAGE","HASCARD","FREQUENCY","PREDEAL", "POINTCOUNT","ALTCOUNT","CONTROL","LOSER","DEALER","VULNERABLE","QUALITY", "CCCC","TRICKS","NOTRUMPS","NORTHSOUTH","EASTWEST","EVALCONTRACT","ALL","NONE", "SCORE","IMPS","RND","PT0","PT1","PT2","PT3","PT4","PT5","PT6","PT7","PT8", "PT9","PRINTES","NUMBER","HOLDING","STRING","IDENT","COMPASS","VULN","SUIT", "CARD","CONTRACT","DISTR","DISTR_OR_NUMBER", }; char *yyrule[] = { "$accept : defs", "defs :", "defs : defs def", "def : GENERATE number", "def : PRODUCE number", "def : DEALER compass", "def : VULNERABLE vulnerable", "def : PREDEAL predealargs", "$$1 :", "def : POINTCOUNT $$1 pointcountargs", "$$2 :", "def : ALTCOUNT number $$2 pointcountargs", "def : CONDITION expr", "def : expr", "def : IDENT '=' expr", "def : ACTION actionlist", "predealargs : predealarg", "predealargs : predealargs predealarg", "$$3 :", "predealarg : COMPASS $$3 holdings", "predealarg : SUIT '(' COMPASS ')' CMPEQ NUMBER", "holdings : HOLDING", "holdings : holdings ',' HOLDING", "pointcountargs :", "$$4 :", "pointcountargs : number $$4 pointcountargs", "compass : COMPASS", "vulnerable : VULNERABLE", "shlprefix : ','", "shlprefix : ARPLUS", "shlprefix :", "shlprefix : ARMINUS", "any :", "any : ANY", "number : NUMBER", "number : ARMINUS NUMBER", "number : DISTR_OR_NUMBER", "shape : DISTR", "shape : DISTR_OR_NUMBER", "shapelistel : shlprefix any shape", "shapelist : shapelistel", "shapelist : shapelist shapelistel", "expr : number", "expr : IDENT", "expr : SUIT '(' compass ')'", "expr : HCP '(' compass ')'", "expr : HCP '(' compass ',' SUIT ')'", "expr : PT0 '(' compass ')'", "expr : PT0 '(' compass ',' SUIT ')'", "expr : PT1 '(' compass ')'", "expr : PT1 '(' compass ',' SUIT ')'", "expr : PT2 '(' compass ')'", "expr : PT2 '(' compass ',' SUIT ')'", "expr : PT3 '(' compass ')'", "expr : PT3 '(' compass ',' SUIT ')'", "expr : PT4 '(' compass ')'", "expr : PT4 '(' compass ',' SUIT ')'", "expr : PT5 '(' compass ')'", "expr : PT5 '(' compass ',' SUIT ')'", "expr : PT6 '(' compass ')'", "expr : PT6 '(' compass ',' SUIT ')'", "expr : PT7 '(' compass ')'", "expr : PT7 '(' compass ',' SUIT ')'", "expr : PT8 '(' compass ')'", "expr : PT8 '(' compass ',' SUIT ')'", "expr : PT9 '(' compass ')'", "expr : PT9 '(' compass ',' SUIT ')'", "expr : LOSER '(' compass ')'", "expr : LOSER '(' compass ',' SUIT ')'", "expr : CONTROL '(' compass ')'", "expr : CONTROL '(' compass ',' SUIT ')'", "expr : CCCC '(' compass ')'", "expr : QUALITY '(' compass ',' SUIT ')'", "expr : SHAPE '(' compass ',' shapelist ')'", "expr : HASCARD '(' COMPASS ',' CARD ')'", "expr : TRICKS '(' compass ',' SUIT ')'", "expr : TRICKS '(' compass ',' NOTRUMPS ')'", "expr : SCORE '(' VULN ',' CONTRACT ',' expr ')'", "expr : IMPS '(' expr ')'", "expr : '(' expr ')'", "expr : expr CMPEQ expr", "expr : expr CMPNE expr", "expr : expr CMPLT expr", "expr : expr CMPLE expr", "expr : expr CMPGT expr", "expr : expr CMPGE expr", "expr : expr AND2 expr", "expr : expr OR2 expr", "expr : expr ARPLUS expr", "expr : expr ARMINUS expr", "expr : expr ARTIMES expr", "expr : expr ARDIVIDE expr", "expr : expr ARMOD expr", "expr : expr QUERY expr COLON expr", "expr : NOT expr", "expr : RND '(' expr ')'", "exprlist : expr", "exprlist : STRING", "exprlist : exprlist ',' expr", "exprlist : exprlist ',' STRING", "actionlist : action", "actionlist : action ',' actionlist", "actionlist :", "action : PRINTALL", "action : PRINTEW", "action : PRINT '(' printlist ')'", "action : PRINTCOMPACT", "action : PRINTONELINE", "action : PRINTPBN", "action : PRINTES '(' exprlist ')'", "action : EVALCONTRACT", "action : PRINTCOMPACT '(' expr ')'", "action : PRINTONELINE '(' expr ')'", "action : AVERAGE optstring expr", "action : FREQUENCY optstring '(' expr ',' number ',' number ')'", "action : FREQUENCY optstring '(' expr ',' number ',' number ',' expr ',' number ',' number ')'", "optstring :", "optstring : STRING", "printlist : COMPASS", "printlist : printlist ',' COMPASS", }; #endif #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 500 #define YYMAXDEPTH 500 #endif #endif int yydebug; int yynerrs; int yyerrflag; int yychar; short *yyssp; YYSTYPE *yyvsp; YYSTYPE yyval; YYSTYPE yylval; short yyss[YYSTACKSIZE]; YYSTYPE yyvs[YYSTACKSIZE]; #define yystacksize YYSTACKSIZE #line 400 "defs.y" struct var { struct var *v_next; char *v_ident; struct tree *v_tree; } *vars=0; struct tree *var_lookup(char *s, int mustbethere) { struct var *v; for(v=vars; v!=0; v = v->v_next) if (strcmp(s, v->v_ident)==0) return v->v_tree; if (mustbethere) yyerror("unknown variable"); return 0; } void new_var(char *s, struct tree *t) { struct var *v; /* char *mycalloc(); */ if (var_lookup(s, 0)!=0) yyerror("redefined variable"); v = (struct var *) mycalloc(1, sizeof(*v)); v->v_next = vars; v->v_ident = s; v->v_tree = t; vars = v; } int lino=1; void yyerror( char *s) { fprintf(stderr, "line %d: %s\n", lino, s); exit(-1); } int perm[24][4] = { { 0, 1, 2, 3 }, { 0, 1, 3, 2 }, { 0, 2, 1, 3 }, { 0, 2, 3, 1 }, { 0, 3, 1, 2 }, { 0, 3, 2, 1 }, { 1, 0, 2, 3 }, { 1, 0, 3, 2 }, { 1, 2, 0, 3 }, { 1, 2, 3, 0 }, { 1, 3, 0, 2 }, { 1, 3, 2, 0 }, { 2, 0, 1, 3 }, { 2, 0, 3, 1 }, { 2, 1, 0, 3 }, { 2, 1, 3, 0 }, { 2, 3, 0, 1 }, { 2, 3, 1, 0 }, { 3, 0, 1, 2 }, { 3, 0, 2, 1 }, { 3, 1, 0, 2 }, { 3, 1, 2, 0 }, { 3, 2, 0, 1 }, { 3, 2, 1, 0 }, }; int shapeno; void insertshape(s, any, neg_shape) char s[4]; { int i,j,p; int xcount=0, ccount=0; char copy_s[4]; for (i=0;i<4;i++) { if (s[i]=='x') xcount++; else ccount += s[i]-'0'; } switch(xcount) { case 0: if (ccount!=13) yyerror("wrong number of cards in shape"); for (p=0; p<(any? 24 : 1); p++) setshapebit(s[perm[p][3]]-'0', s[perm[p][2]]-'0', s[perm[p][1]]-'0', s[perm[p][0]]-'0', 1<13) yyerror("too many cards in ambiguous shape"); bcopy(s, copy_s, 4); for(i=0; copy_s[i] != 'x'; i++) ; if (xcount==1) { copy_s[i] = 13-ccount+'0'; /* could go above '9' */ insertshape(copy_s, any, neg_shape); } else { for (j=0; j<=13-ccount; j++) { copy_s[i] = j+'0'; insertshape(copy_s, any, neg_shape); } } break; } } int d2n(char s[4]) { static char copys[5]; strncpy(copys, s, 4); return atoi(copys); } struct tree *newtree(type, p1, p2, i1, i2) int type; struct tree *p1, *p2; int i1,i2; { /* char *mycalloc(); */ struct tree *p; p = (struct tree *) mycalloc(1, sizeof(*p)); p->tr_type = type; p->tr_leaf1 = p1; p->tr_leaf2 = p2; p->tr_int1 = i1; p->tr_int2 = i2; return p; } struct action *newaction(type, p1, s1, i1, p2) int type; struct tree *p1; char *s1; int i1; struct tree *p2; { /* char *mycalloc(); */ struct action *a; a = (struct action *) mycalloc(1, sizeof(*a)); a->ac_type = type; a->ac_expr1 = p1; a->ac_str1 = s1; a->ac_int1 = i1; a->ac_expr2 = p2; return a; } struct expr *newexpr(struct tree* tr1, char* ch1, struct expr* ex1) { struct expr* e; e=(struct expr*) mycalloc(1, sizeof(*e)); e->ex_tr = tr1; e->ex_ch = ch1; e->next = 0; if(ex1) { struct expr* exau = ex1; /* AM990705: the while's body had mysteriously disappeared, reinserted it */ while(exau->next) exau = exau->next; exau->next = e; return ex1; } else { return e; } } char *mystrcpy(s) char *s; { char *cs; /* char *mycalloc(); */ cs = mycalloc(strlen(s)+1, sizeof(char)); strcpy(cs, s); return cs; } void predeal_holding(compass, holding) char *holding; { char suit; suit = *holding++; while (*holding) { predeal(compass, make_card(*holding, suit)); holding++; } } #define TRUNCZ(x) ((x)<0?0:(x)) extern int biasdeal[4][4]; extern char*player_name[4]; static char *suit_name[] = {"Club", "Diamond", "Heart", "Spade"}; int bias_len(int compass){ return TRUNCZ(biasdeal[compass][0])+ TRUNCZ(biasdeal[compass][1])+ TRUNCZ(biasdeal[compass][2])+ TRUNCZ(biasdeal[compass][3]); } int bias_totsuit(int suit){ return TRUNCZ(biasdeal[0][suit])+ TRUNCZ(biasdeal[1][suit])+ TRUNCZ(biasdeal[2][suit])+ TRUNCZ(biasdeal[3][suit]); } void bias_deal(int suit, int compass, int length){ if(biasdeal[compass][suit]!=-1){ char s[256]; sprintf(s,"%s's %s suit has length already set to %d", player_name[compass],suit_name[suit], biasdeal[compass][suit]); yyerror(s); } biasdeal[compass][suit]=length; if(bias_len(compass)>13){ char s[256]; sprintf(s,"Suit lengths too long for %s", player_name[compass]); yyerror(s); } if(bias_totsuit(suit)>13){ char s[256]; sprintf(s,"Too many %ss",suit_name[suit]); yyerror(s); } } #define YY_USE_PROTOS #ifdef WIN32 #pragma warning( disable : 4127 ) #endif #include "scan.c" #ifdef WIN32 #pragma warning( default : 4127 ) #endif #line 1179 "y.tab.c" #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int #if defined(__STDC__) yyparse(void) #else yyparse() #endif { register int yym, yyn, yystate; #if YYDEBUG register char *yys; extern char *getenv(); if (yys = getenv("YYDEBUG")) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } #endif yynerrs = 0; yyerrflag = 0; yychar = (-1); yyssp = yyss; yyvsp = yyvs; *yyssp = yystate = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, reading %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif } if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif if (yyssp >= yyss + yystacksize - 1) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; yychar = (-1); if (yyerrflag > 0) --yyerrflag; goto yyloop; } if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag) goto yyinrecovery; yyerror("syntax error"); #ifdef lint goto yyerrlab; #endif yyerrlab: ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); #endif if (yyssp >= yyss + yystacksize - 1) { goto yyoverflow; } *++yyssp = yystate = yytable[yyn]; *++yyvsp = yylval; goto yyloop; } else { #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", YYPREFIX, *yyssp); #endif if (yyssp <= yyss) goto yyabort; --yyssp; --yyvsp; } } } else { if (yychar == 0) goto yyabort; #if YYDEBUG if (yydebug) { yys = 0; if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", YYPREFIX, yystate, yychar, yys); } #endif yychar = (-1); goto yyloop; } yyreduce: #if YYDEBUG if (yydebug) printf("%sdebug: state %d, reducing by rule %d (%s)\n", YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; yyval = yyvsp[1-yym]; switch (yyn) { case 3: #line 100 "defs.y" { extern int maxgenerate; if(!maxgenerate) maxgenerate = yyvsp[0].y_int; } break; case 4: #line 102 "defs.y" { extern int maxproduce; if(!maxproduce) maxproduce = yyvsp[0].y_int; } break; case 5: #line 104 "defs.y" { extern int maxdealer; maxdealer = yyvsp[0].y_int; } break; case 6: #line 108 "defs.y" { extern int maxvuln; maxvuln = yyvsp[0].y_int; } break; case 8: #line 112 "defs.y" { clearpointcount(); pointcount_index=12;} break; case 10: #line 114 "defs.y" { clearpointcount_alt(yyvsp[0].y_int); pointcount_index=12;} break; case 12: #line 116 "defs.y" { extern struct tree *decisiontree; decisiontree = yyvsp[0].y_tree; } break; case 13: #line 118 "defs.y" { extern struct tree *decisiontree; decisiontree = yyvsp[0].y_tree; } break; case 14: #line 120 "defs.y" { new_var(yyvsp[-2].y_str, yyvsp[0].y_tree); } break; case 15: #line 122 "defs.y" { extern struct action *actionlist; actionlist = yyvsp[0].y_action; } break; case 18: #line 131 "defs.y" { predeal_compass = yyvsp[0].y_int;} break; case 20: #line 132 "defs.y" {bias_deal(yyvsp[-5].y_int,yyvsp[-3].y_int,yyvsp[0].y_int);} break; case 21: #line 137 "defs.y" { predeal_holding(predeal_compass, yyvsp[0].y_str); } break; case 22: #line 139 "defs.y" { predeal_holding(predeal_compass, yyvsp[0].y_str); } break; case 24: #line 145 "defs.y" { pointcount(pointcount_index, yyvsp[0].y_int); pointcount_index--; } break; case 26: #line 153 "defs.y" { extern int use_compass[NSUITS]; use_compass[yyvsp[0].y_int] = 1; yyval.y_int= yyvsp[0].y_int; } break; case 27: #line 158 "defs.y" { extern int use_vulnerable[NSUITS]; use_vulnerable[yyvsp[0].y_int] = 1; yyval.y_int= yyvsp[0].y_int; } break; case 28: #line 163 "defs.y" { yyval.y_int = 0; } break; case 29: #line 165 "defs.y" { yyval.y_int = 0; } break; case 30: #line 167 "defs.y" { yyval.y_int = 0; } break; case 31: #line 169 "defs.y" { yyval.y_int = 1; } break; case 32: #line 174 "defs.y" { yyval.y_int = 0; } break; case 33: #line 176 "defs.y" { yyval.y_int = 1; } break; case 35: #line 183 "defs.y" { yyval.y_int = - yyvsp[0].y_int; } break; case 36: #line 185 "defs.y" { yyval.y_int = d2n(yyvsp[0].y_distr); } break; case 39: #line 194 "defs.y" { insertshape(yyvsp[0].y_distr, yyvsp[-1].y_int, yyvsp[-2].y_int); } break; case 42: #line 204 "defs.y" { yyval.y_tree = newtree(TRT_NUMBER, NIL, NIL, yyvsp[0].y_int, 0); } break; case 43: #line 206 "defs.y" { yyval.y_tree = var_lookup(yyvsp[0].y_str, 1); } break; case 44: #line 208 "defs.y" { yyval.y_tree = newtree(TRT_LENGTH, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 45: #line 210 "defs.y" { yyval.y_tree = newtree(TRT_HCPTOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 46: #line 212 "defs.y" { yyval.y_tree = newtree(TRT_HCP, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 47: #line 214 "defs.y" { yyval.y_tree = newtree(TRT_PT0TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 48: #line 216 "defs.y" { yyval.y_tree = newtree(TRT_PT0, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 49: #line 218 "defs.y" { yyval.y_tree = newtree(TRT_PT1TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 50: #line 220 "defs.y" { yyval.y_tree = newtree(TRT_PT1, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 51: #line 222 "defs.y" { yyval.y_tree = newtree(TRT_PT2TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 52: #line 224 "defs.y" { yyval.y_tree = newtree(TRT_PT2, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 53: #line 226 "defs.y" { yyval.y_tree = newtree(TRT_PT3TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 54: #line 228 "defs.y" { yyval.y_tree = newtree(TRT_PT3, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 55: #line 230 "defs.y" { yyval.y_tree = newtree(TRT_PT4TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 56: #line 232 "defs.y" { yyval.y_tree = newtree(TRT_PT4, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 57: #line 234 "defs.y" { yyval.y_tree = newtree(TRT_PT5TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 58: #line 236 "defs.y" { yyval.y_tree = newtree(TRT_PT5, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 59: #line 238 "defs.y" { yyval.y_tree = newtree(TRT_PT6TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 60: #line 240 "defs.y" { yyval.y_tree = newtree(TRT_PT6, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 61: #line 242 "defs.y" { yyval.y_tree = newtree(TRT_PT7TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 62: #line 244 "defs.y" { yyval.y_tree = newtree(TRT_PT7, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 63: #line 246 "defs.y" { yyval.y_tree = newtree(TRT_PT8TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 64: #line 248 "defs.y" { yyval.y_tree = newtree(TRT_PT8, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 65: #line 250 "defs.y" { yyval.y_tree = newtree(TRT_PT9TOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 66: #line 252 "defs.y" { yyval.y_tree = newtree(TRT_PT9, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 67: #line 254 "defs.y" { yyval.y_tree = newtree(TRT_LOSERTOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 68: #line 256 "defs.y" { yyval.y_tree = newtree(TRT_LOSER, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 69: #line 258 "defs.y" { yyval.y_tree = newtree(TRT_CONTROLTOTAL, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 70: #line 260 "defs.y" { yyval.y_tree = newtree(TRT_CONTROL, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 71: #line 262 "defs.y" { yyval.y_tree = newtree(TRT_CCCC, NIL, NIL, yyvsp[-1].y_int, 0); } break; case 72: #line 264 "defs.y" { yyval.y_tree = newtree(TRT_QUALITY, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 73: #line 266 "defs.y" { yyval.y_tree = newtree(TRT_SHAPE, NIL, NIL, yyvsp[-3].y_int, 1<<(shapeno++)); if (shapeno >= 32) { yyerror("Too many shapes -- only 32 allowed!\n"); YYERROR; } } break; case 74: #line 274 "defs.y" { yyval.y_tree = newtree(TRT_HASCARD, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 75: #line 276 "defs.y" { yyval.y_tree = newtree(TRT_TRICKS, NIL, NIL, yyvsp[-3].y_int, yyvsp[-1].y_int); } break; case 76: #line 278 "defs.y" { yyval.y_tree = newtree(TRT_TRICKS, NIL, NIL, yyvsp[-3].y_int, 4); } break; case 77: #line 280 "defs.y" { yyval.y_tree = newtree(TRT_SCORE, yyvsp[-1].y_tree, NIL, yyvsp[-5].y_int, yyvsp[-3].y_int); } break; case 78: #line 282 "defs.y" { yyval.y_tree = newtree(TRT_IMPS, yyvsp[-1].y_tree, NIL, 0, 0); } break; case 79: #line 284 "defs.y" { yyval.y_tree = yyvsp[-1].y_tree; } break; case 80: #line 286 "defs.y" { yyval.y_tree = newtree(TRT_CMPEQ, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 81: #line 288 "defs.y" { yyval.y_tree = newtree(TRT_CMPNE, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 82: #line 290 "defs.y" { yyval.y_tree = newtree(TRT_CMPLT, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 83: #line 292 "defs.y" { yyval.y_tree = newtree(TRT_CMPLE, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 84: #line 294 "defs.y" { yyval.y_tree = newtree(TRT_CMPGT, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 85: #line 296 "defs.y" { yyval.y_tree = newtree(TRT_CMPGE, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 86: #line 298 "defs.y" { yyval.y_tree = newtree(TRT_AND2, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 87: #line 300 "defs.y" { yyval.y_tree = newtree(TRT_OR2, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 88: #line 302 "defs.y" { yyval.y_tree = newtree(TRT_ARPLUS, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 89: #line 304 "defs.y" { yyval.y_tree = newtree(TRT_ARMINUS, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 90: #line 306 "defs.y" { yyval.y_tree = newtree(TRT_ARTIMES, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 91: #line 308 "defs.y" { yyval.y_tree = newtree(TRT_ARDIVIDE, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 92: #line 310 "defs.y" { yyval.y_tree = newtree(TRT_ARMOD, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0); } break; case 93: #line 312 "defs.y" { yyval.y_tree = newtree(TRT_IF, yyvsp[-4].y_tree, newtree(TRT_THENELSE, yyvsp[-2].y_tree, yyvsp[0].y_tree, 0, 0), 0, 0); } break; case 94: #line 314 "defs.y" { yyval.y_tree = newtree(TRT_NOT, yyvsp[0].y_tree, NIL, 0, 0); } break; case 95: #line 316 "defs.y" { yyval.y_tree = newtree(TRT_RND, yyvsp[-1].y_tree, NIL, 0, 0); } break; case 96: #line 321 "defs.y" { yyval.y_expr = newexpr(yyvsp[0].y_tree, 0, 0); } break; case 97: #line 323 "defs.y" { yyval.y_expr = newexpr(0, yyvsp[0].y_str, 0); } break; case 98: #line 325 "defs.y" { yyval.y_expr = newexpr(yyvsp[0].y_tree, 0, yyvsp[-2].y_expr); } break; case 99: #line 327 "defs.y" { yyval.y_expr = newexpr(0, yyvsp[0].y_str, yyvsp[-2].y_expr); } break; case 100: #line 332 "defs.y" { yyval.y_action = yyvsp[0].y_action; } break; case 101: #line 334 "defs.y" { yyval.y_action = yyvsp[-2].y_action; yyval.y_action->ac_next = yyvsp[0].y_action; } break; case 102: #line 336 "defs.y" { yyval.y_action = 0; } break; case 103: #line 340 "defs.y" { will_print++; yyval.y_action = newaction(ACT_PRINTALL, NIL, (char *) 0, 0, NIL); } break; case 104: #line 344 "defs.y" { will_print++; yyval.y_action = newaction(ACT_PRINTEW, NIL, (char *) 0, 0, NIL); } break; case 105: #line 348 "defs.y" { will_print++; yyval.y_action = newaction(ACT_PRINT, NIL, (char *) 0, yyvsp[-1].y_int, NIL); } break; case 106: #line 352 "defs.y" { will_print++; yyval.y_action=newaction(ACT_PRINTCOMPACT,NIL,0,0, NIL);} break; case 107: #line 355 "defs.y" { will_print++; yyval.y_action = newaction(ACT_PRINTONELINE, NIL, 0, 0, NIL);} break; case 108: #line 358 "defs.y" { will_print++; yyval.y_action=newaction(ACT_PRINTPBN,NIL,0,0, NIL);} break; case 109: #line 361 "defs.y" { will_print++; yyval.y_action=newaction(ACT_PRINTES,(struct tree*)yyvsp[-1].y_expr,0,0, NIL); } break; case 110: #line 364 "defs.y" { will_print++; yyval.y_action=newaction(ACT_EVALCONTRACT,0,0,0, NIL);} break; case 111: #line 367 "defs.y" { will_print++; yyval.y_action=newaction(ACT_PRINTCOMPACT,yyvsp[-1].y_tree,0,0, NIL);} break; case 112: #line 370 "defs.y" { will_print++; yyval.y_action=newaction(ACT_PRINTONELINE,yyvsp[-1].y_tree,0,0, NIL);} break; case 113: #line 373 "defs.y" { yyval.y_action = newaction(ACT_AVERAGE, yyvsp[0].y_tree, yyvsp[-1].y_str, 0, NIL); } break; case 114: #line 375 "defs.y" { yyval.y_action = newaction(ACT_FREQUENCY, yyvsp[-5].y_tree, yyvsp[-7].y_str, 0, NIL); yyval.y_action->ac_u.acu_f.acuf_lowbnd = yyvsp[-3].y_int; yyval.y_action->ac_u.acu_f.acuf_highbnd = yyvsp[-1].y_int;} break; case 115: #line 379 "defs.y" { yyval.y_action = newaction(ACT_FREQUENCY2D, yyvsp[-11].y_tree, yyvsp[-13].y_str, 0, yyvsp[-5].y_tree); yyval.y_action->ac_u.acu_f2d.acuf_lowbnd_expr1 = yyvsp[-9].y_int; yyval.y_action->ac_u.acu_f2d.acuf_highbnd_expr1 = yyvsp[-7].y_int; yyval.y_action->ac_u.acu_f2d.acuf_lowbnd_expr2 = yyvsp[-3].y_int; yyval.y_action->ac_u.acu_f2d.acuf_highbnd_expr2 = yyvsp[-1].y_int; } break; case 116: #line 389 "defs.y" { yyval.y_str = (char *) 0; } break; case 117: #line 391 "defs.y" { yyval.y_str = yyvsp[0].y_str; } break; case 118: #line 395 "defs.y" { yyval.y_int = (1<= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ to state %d\n", YYPREFIX, *yyssp, yystate); #endif if (yyssp >= yyss + yystacksize - 1) { goto yyoverflow; } *++yyssp = yystate; *++yyvsp = yyval; goto yyloop; yyoverflow: yyerror("yacc stack overflow"); yyabort: return (1); yyaccept: return (0); } dealer/defs.y0100644000076400001440000004606110002574544012306 0ustar henkusers%{ #include #include #ifdef WIN32 // void * _alloca( size_t ) ; #define alloca _alloca #endif /* WIN32 */ #include #include "tree.h" #include "dealer.h" void yyerror (char*); void setshapebit (int, int, int, int, int, int); void predeal (int, card); card make_card(char,char); void clearpointcount(void); void clearpointcount_alt(int); void pointcount(int,int); void* mycalloc(int,size_t); int make_contract (char, char); int predeal_compass; /* global variable for predeal communication */ int pointcount_index; /* global variable for pointcount communication */ int shapeno ; struct tree *var_lookup(char *s, int mustbethere) ; struct action *newaction(int type, struct tree * p1, char * s1, int, struct tree * ) ; struct tree *newtree (int, struct tree*, struct tree*, int, int); struct expr *newexpr(struct tree* tr1, char* ch1, struct expr* ex1); void bias_deal(int suit, int compass, int length) ; void predeal_holding(int compass, char *holding) ; void insertshape(char s[4], int any, int neg_shape) ; void new_var(char *s, struct tree *t) ; %} %union { int y_int; char *y_str; struct tree *y_tree; struct action *y_action; struct expr *y_expr; char y_distr[4]; } %left QUERY, COLON %left OR2 %left AND2 %left CMPEQ, CMPNE %left CMPLT, CMPLE, CMPGT, CMPGE %left ARPLUS, ARMINUS %left ARTIMES, ARDIVIDE, ARMOD %nonassoc NOT %token GENERATE, PRODUCE, HCP, SHAPE, ANY, EXCEPT, CONDITION, ACTION %token PRINT, PRINTALL,PRINTEW, PRINTPBN, PRINTCOMPACT, PRINTONELINE %token AVERAGE, HASCARD, FREQUENCY, PREDEAL, POINTCOUNT, ALTCOUNT %token CONTROL, LOSER, DEALER, VULNERABLE %token QUALITY, CCCC %token TRICKS, NOTRUMPS, NORTHSOUTH, EASTWEST %token EVALCONTRACT, ALL, NONE, SCORE, IMPS, RND %token PT0,PT1,PT2,PT3,PT4,PT5,PT6,PT7,PT8,PT9,PRINTES %token NUMBER %token HOLDING %token STRING %token IDENT %token COMPASS %token VULNERABLE %token VULN %token SUIT %token CARD %token CONTRACT %token DISTR, DISTR_OR_NUMBER %type expr %type number, compass, printlist, shlprefix, any, vulnerable %type shape %type actionlist action %type exprlist %type optstring %start defs %% defs : /* empty */ | defs def ; def : GENERATE number { extern int maxgenerate; if(!maxgenerate) maxgenerate = $2; } | PRODUCE number { extern int maxproduce; if(!maxproduce) maxproduce = $2; } | DEALER compass { extern int maxdealer; maxdealer = $2; } | VULNERABLE vulnerable { extern int maxvuln; maxvuln = $2; } | PREDEAL predealargs | POINTCOUNT { clearpointcount(); pointcount_index=12;} pointcountargs | ALTCOUNT number { clearpointcount_alt($2); pointcount_index=12;} pointcountargs | CONDITION expr { extern struct tree *decisiontree; decisiontree = $2; } | expr { extern struct tree *decisiontree; decisiontree = $1; } | IDENT '=' expr { new_var($1, $3); } | ACTION actionlist { extern struct action *actionlist; actionlist = $2; } ; predealargs : predealarg | predealargs predealarg ; predealarg : COMPASS { predeal_compass = $1;} holdings | SUIT '(' COMPASS ')' CMPEQ NUMBER {bias_deal($1,$3,$6);} ; holdings : HOLDING { predeal_holding(predeal_compass, $1); } | holdings ',' HOLDING { predeal_holding(predeal_compass, $3); } ; pointcountargs : /* empty */ | number { pointcount(pointcount_index, $1); pointcount_index--; } pointcountargs ; compass : COMPASS { extern int use_compass[NSUITS]; use_compass[$1] = 1; $$= $1; } ; vulnerable : VULNERABLE { extern int use_vulnerable[NSUITS]; use_vulnerable[$1] = 1; $$= $1; } ; shlprefix : ',' { $$ = 0; } | ARPLUS { $$ = 0; } | /* empty */ { $$ = 0; } | ARMINUS { $$ = 1; } ; any : /* empty */ { $$ = 0; } | ANY { $$ = 1; } ; /* AM990705: extra production to fix unary-minus syntax glitch */ number : NUMBER | ARMINUS NUMBER { $$ = - $2; } | DISTR_OR_NUMBER { $$ = d2n($1); } ; shape : DISTR | DISTR_OR_NUMBER ; shapelistel : shlprefix any shape { insertshape($3, $2, $1); } ; shapelist : shapelistel | shapelist shapelistel ; expr : number { $$ = newtree(TRT_NUMBER, NIL, NIL, $1, 0); } | IDENT { $$ = var_lookup($1, 1); } | SUIT '(' compass ')' { $$ = newtree(TRT_LENGTH, NIL, NIL, $1, $3); } | HCP '(' compass ')' { $$ = newtree(TRT_HCPTOTAL, NIL, NIL, $3, 0); } | HCP '(' compass ',' SUIT ')' { $$ = newtree(TRT_HCP, NIL, NIL, $3, $5); } | PT0 '(' compass ')' { $$ = newtree(TRT_PT0TOTAL, NIL, NIL, $3, 0); } | PT0 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT0, NIL, NIL, $3, $5); } | PT1 '(' compass ')' { $$ = newtree(TRT_PT1TOTAL, NIL, NIL, $3, 0); } | PT1 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT1, NIL, NIL, $3, $5); } | PT2 '(' compass ')' { $$ = newtree(TRT_PT2TOTAL, NIL, NIL, $3, 0); } | PT2 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT2, NIL, NIL, $3, $5); } | PT3 '(' compass ')' { $$ = newtree(TRT_PT3TOTAL, NIL, NIL, $3, 0); } | PT3 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT3, NIL, NIL, $3, $5); } | PT4 '(' compass ')' { $$ = newtree(TRT_PT4TOTAL, NIL, NIL, $3, 0); } | PT4 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT4, NIL, NIL, $3, $5); } | PT5 '(' compass ')' { $$ = newtree(TRT_PT5TOTAL, NIL, NIL, $3, 0); } | PT5 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT5, NIL, NIL, $3, $5); } | PT6 '(' compass ')' { $$ = newtree(TRT_PT6TOTAL, NIL, NIL, $3, 0); } | PT6 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT6, NIL, NIL, $3, $5); } | PT7 '(' compass ')' { $$ = newtree(TRT_PT7TOTAL, NIL, NIL, $3, 0); } | PT7 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT7, NIL, NIL, $3, $5); } | PT8 '(' compass ')' { $$ = newtree(TRT_PT8TOTAL, NIL, NIL, $3, 0); } | PT8 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT8, NIL, NIL, $3, $5); } | PT9 '(' compass ')' { $$ = newtree(TRT_PT9TOTAL, NIL, NIL, $3, 0); } | PT9 '(' compass ',' SUIT ')' { $$ = newtree(TRT_PT9, NIL, NIL, $3, $5); } | LOSER '(' compass ')' { $$ = newtree(TRT_LOSERTOTAL, NIL, NIL, $3, 0); } | LOSER '(' compass ',' SUIT ')' { $$ = newtree(TRT_LOSER, NIL, NIL, $3, $5); } | CONTROL '(' compass ')' { $$ = newtree(TRT_CONTROLTOTAL, NIL, NIL, $3, 0); } | CONTROL '(' compass ',' SUIT ')' { $$ = newtree(TRT_CONTROL, NIL, NIL, $3, $5); } | CCCC '(' compass ')' { $$ = newtree(TRT_CCCC, NIL, NIL, $3, 0); } | QUALITY '(' compass ',' SUIT ')' { $$ = newtree(TRT_QUALITY, NIL, NIL, $3, $5); } | SHAPE '(' compass ',' shapelist ')' { $$ = newtree(TRT_SHAPE, NIL, NIL, $3, 1<<(shapeno++)); if (shapeno >= 32) { yyerror("Too many shapes -- only 32 allowed!\n"); YYERROR; } } | HASCARD '(' COMPASS ',' CARD ')' { $$ = newtree(TRT_HASCARD, NIL, NIL, $3, $5); } | TRICKS '(' compass ',' SUIT ')' { $$ = newtree(TRT_TRICKS, NIL, NIL, $3, $5); } | TRICKS '(' compass ',' NOTRUMPS ')' { $$ = newtree(TRT_TRICKS, NIL, NIL, $3, 4); } | SCORE '(' VULN ',' CONTRACT ',' expr ')' { $$ = newtree(TRT_SCORE, $7, NIL, $3, $5); } | IMPS '(' expr ')' { $$ = newtree(TRT_IMPS, $3, NIL, 0, 0); } | '(' expr ')' { $$ = $2; } | expr CMPEQ expr { $$ = newtree(TRT_CMPEQ, $1, $3, 0, 0); } | expr CMPNE expr { $$ = newtree(TRT_CMPNE, $1, $3, 0, 0); } | expr CMPLT expr { $$ = newtree(TRT_CMPLT, $1, $3, 0, 0); } | expr CMPLE expr { $$ = newtree(TRT_CMPLE, $1, $3, 0, 0); } | expr CMPGT expr { $$ = newtree(TRT_CMPGT, $1, $3, 0, 0); } | expr CMPGE expr { $$ = newtree(TRT_CMPGE, $1, $3, 0, 0); } | expr AND2 expr { $$ = newtree(TRT_AND2, $1, $3, 0, 0); } | expr OR2 expr { $$ = newtree(TRT_OR2, $1, $3, 0, 0); } | expr ARPLUS expr { $$ = newtree(TRT_ARPLUS, $1, $3, 0, 0); } | expr ARMINUS expr { $$ = newtree(TRT_ARMINUS, $1, $3, 0, 0); } | expr ARTIMES expr { $$ = newtree(TRT_ARTIMES, $1, $3, 0, 0); } | expr ARDIVIDE expr { $$ = newtree(TRT_ARDIVIDE, $1, $3, 0, 0); } | expr ARMOD expr { $$ = newtree(TRT_ARMOD, $1, $3, 0, 0); } | expr QUERY expr COLON expr { $$ = newtree(TRT_IF, $1, newtree(TRT_THENELSE, $3, $5, 0, 0), 0, 0); } | NOT expr { $$ = newtree(TRT_NOT, $2, NIL, 0, 0); } | RND '(' expr ')' { $$ = newtree(TRT_RND, $3, NIL, 0, 0); } ; exprlist : expr { $$ = newexpr($1, 0, 0); } | STRING { $$ = newexpr(0, $1, 0); } | exprlist ',' expr { $$ = newexpr($3, 0, $1); } | exprlist ',' STRING { $$ = newexpr(0, $3, $1); } ; actionlist : action { $$ = $1; } | action ',' actionlist { $$ = $1; $$->ac_next = $3; } | /* empty */ { $$ = 0; } ; action : PRINTALL { will_print++; $$ = newaction(ACT_PRINTALL, NIL, (char *) 0, 0, NIL); } | PRINTEW { will_print++; $$ = newaction(ACT_PRINTEW, NIL, (char *) 0, 0, NIL); } | PRINT '(' printlist ')' { will_print++; $$ = newaction(ACT_PRINT, NIL, (char *) 0, $3, NIL); } | PRINTCOMPACT { will_print++; $$=newaction(ACT_PRINTCOMPACT,NIL,0,0, NIL);} | PRINTONELINE { will_print++; $$ = newaction(ACT_PRINTONELINE, NIL, 0, 0, NIL);} | PRINTPBN { will_print++; $$=newaction(ACT_PRINTPBN,NIL,0,0, NIL);} | PRINTES '(' exprlist ')' { will_print++; $$=newaction(ACT_PRINTES,(struct tree*)$3,0,0, NIL); } | EVALCONTRACT /* should allow user to specify vuln, suit, decl */ { will_print++; $$=newaction(ACT_EVALCONTRACT,0,0,0, NIL);} | PRINTCOMPACT '(' expr ')' { will_print++; $$=newaction(ACT_PRINTCOMPACT,$3,0,0, NIL);} | PRINTONELINE '(' expr ')' { will_print++; $$=newaction(ACT_PRINTONELINE,$3,0,0, NIL);} | AVERAGE optstring expr { $$ = newaction(ACT_AVERAGE, $3, $2, 0, NIL); } | FREQUENCY optstring '(' expr ',' number ',' number ')' { $$ = newaction(ACT_FREQUENCY, $4, $2, 0, NIL); $$->ac_u.acu_f.acuf_lowbnd = $6; $$->ac_u.acu_f.acuf_highbnd = $8;} | FREQUENCY optstring '(' expr ',' number ',' number ',' expr ',' number ',' number ')' { $$ = newaction(ACT_FREQUENCY2D, $4, $2, 0, $10); $$->ac_u.acu_f2d.acuf_lowbnd_expr1 = $6; $$->ac_u.acu_f2d.acuf_highbnd_expr1 = $8; $$->ac_u.acu_f2d.acuf_lowbnd_expr2 = $12; $$->ac_u.acu_f2d.acuf_highbnd_expr2 = $14; } ; optstring : /* empty */ { $$ = (char *) 0; } | STRING { $$ = $1; } ; printlist : COMPASS { $$ = (1<<$1); } | printlist ',' COMPASS { $$ = $1|(1<<$3); } ; %% struct var { struct var *v_next; char *v_ident; struct tree *v_tree; } *vars=0; struct tree *var_lookup(char *s, int mustbethere) { struct var *v; for(v=vars; v!=0; v = v->v_next) if (strcmp(s, v->v_ident)==0) return v->v_tree; if (mustbethere) yyerror("unknown variable"); return 0; } void new_var(char *s, struct tree *t) { struct var *v; /* char *mycalloc(); */ if (var_lookup(s, 0)!=0) yyerror("redefined variable"); v = (struct var *) mycalloc(1, sizeof(*v)); v->v_next = vars; v->v_ident = s; v->v_tree = t; vars = v; } int lino=1; void yyerror( char *s) { fprintf(stderr, "line %d: %s\n", lino, s); exit(-1); } int perm[24][4] = { { 0, 1, 2, 3 }, { 0, 1, 3, 2 }, { 0, 2, 1, 3 }, { 0, 2, 3, 1 }, { 0, 3, 1, 2 }, { 0, 3, 2, 1 }, { 1, 0, 2, 3 }, { 1, 0, 3, 2 }, { 1, 2, 0, 3 }, { 1, 2, 3, 0 }, { 1, 3, 0, 2 }, { 1, 3, 2, 0 }, { 2, 0, 1, 3 }, { 2, 0, 3, 1 }, { 2, 1, 0, 3 }, { 2, 1, 3, 0 }, { 2, 3, 0, 1 }, { 2, 3, 1, 0 }, { 3, 0, 1, 2 }, { 3, 0, 2, 1 }, { 3, 1, 0, 2 }, { 3, 1, 2, 0 }, { 3, 2, 0, 1 }, { 3, 2, 1, 0 }, }; int shapeno; void insertshape(s, any, neg_shape) char s[4]; { int i,j,p; int xcount=0, ccount=0; char copy_s[4]; for (i=0;i<4;i++) { if (s[i]=='x') xcount++; else ccount += s[i]-'0'; } switch(xcount) { case 0: if (ccount!=13) yyerror("wrong number of cards in shape"); for (p=0; p<(any? 24 : 1); p++) setshapebit(s[perm[p][3]]-'0', s[perm[p][2]]-'0', s[perm[p][1]]-'0', s[perm[p][0]]-'0', 1<13) yyerror("too many cards in ambiguous shape"); bcopy(s, copy_s, 4); for(i=0; copy_s[i] != 'x'; i++) ; if (xcount==1) { copy_s[i] = 13-ccount+'0'; /* could go above '9' */ insertshape(copy_s, any, neg_shape); } else { for (j=0; j<=13-ccount; j++) { copy_s[i] = j+'0'; insertshape(copy_s, any, neg_shape); } } break; } } int d2n(char s[4]) { static char copys[5]; strncpy(copys, s, 4); return atoi(copys); } struct tree *newtree(type, p1, p2, i1, i2) int type; struct tree *p1, *p2; int i1,i2; { /* char *mycalloc(); */ struct tree *p; p = (struct tree *) mycalloc(1, sizeof(*p)); p->tr_type = type; p->tr_leaf1 = p1; p->tr_leaf2 = p2; p->tr_int1 = i1; p->tr_int2 = i2; return p; } struct action *newaction(type, p1, s1, i1, p2) int type; struct tree *p1; char *s1; int i1; struct tree *p2; { /* char *mycalloc(); */ struct action *a; a = (struct action *) mycalloc(1, sizeof(*a)); a->ac_type = type; a->ac_expr1 = p1; a->ac_str1 = s1; a->ac_int1 = i1; a->ac_expr2 = p2; return a; } struct expr *newexpr(struct tree* tr1, char* ch1, struct expr* ex1) { struct expr* e; e=(struct expr*) mycalloc(1, sizeof(*e)); e->ex_tr = tr1; e->ex_ch = ch1; e->next = 0; if(ex1) { struct expr* exau = ex1; /* AM990705: the while's body had mysteriously disappeared, reinserted it */ while(exau->next) exau = exau->next; exau->next = e; return ex1; } else { return e; } } char *mystrcpy(s) char *s; { char *cs; /* char *mycalloc(); */ cs = mycalloc(strlen(s)+1, sizeof(char)); strcpy(cs, s); return cs; } void predeal_holding(compass, holding) char *holding; { char suit; suit = *holding++; while (*holding) { predeal(compass, make_card(*holding, suit)); holding++; } } #define TRUNCZ(x) ((x)<0?0:(x)) extern int biasdeal[4][4]; extern char*player_name[4]; static char *suit_name[] = {"Club", "Diamond", "Heart", "Spade"}; int bias_len(int compass){ return TRUNCZ(biasdeal[compass][0])+ TRUNCZ(biasdeal[compass][1])+ TRUNCZ(biasdeal[compass][2])+ TRUNCZ(biasdeal[compass][3]); } int bias_totsuit(int suit){ return TRUNCZ(biasdeal[0][suit])+ TRUNCZ(biasdeal[1][suit])+ TRUNCZ(biasdeal[2][suit])+ TRUNCZ(biasdeal[3][suit]); } void bias_deal(int suit, int compass, int length){ if(biasdeal[compass][suit]!=-1){ char s[256]; sprintf(s,"%s's %s suit has length already set to %d", player_name[compass],suit_name[suit], biasdeal[compass][suit]); yyerror(s); } biasdeal[compass][suit]=length; if(bias_len(compass)>13){ char s[256]; sprintf(s,"Suit lengths too long for %s", player_name[compass]); yyerror(s); } if(bias_totsuit(suit)>13){ char s[256]; sprintf(s,"Too many %ss",suit_name[suit]); yyerror(s); } } #define YY_USE_PROTOS #ifdef WIN32 #pragma warning( disable : 4127 ) #endif #include "scan.c" #ifdef WIN32 #pragma warning( default : 4127 ) #endif dealer/getopt.c0100644000076400001440000004426410002574545012645 0ustar henkusers/* Getopt for GNU. Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95 Free Software Foundation, Inc. Modified (1993) from bison-1.20 by Wilfred J. Hansen (wjh+@cmu.edu) Andrew Consortium, Carnegie Mellon University This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #define gettext(msgid) (msgid) /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* XXX 1003.2 says this must be 1 before any call. */ int optind = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return EOF with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #include #define my_index strchr /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ static const char * _getopt_initialize (optstring) const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind = 1; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns `EOF'. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { optarg = NULL; if (optind == 0) { optstring = _getopt_initialize (optstring); optind = 1; /* Don't scan ARGV[0], the program name. */ } if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && (argv[optind][0] != '-' || argv[optind][1] == '\0')) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return EOF; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if ((argv[optind][0] != '-' || argv[optind][1] == '\0')) { if (ordering == REQUIRE_ORDER) return EOF; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound =0; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { /* AM990705: must cast to unsigned to avoid a warning in MS VC++6 */ if ((unsigned)(nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, gettext ("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, gettext ("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); } else { /* +option or -option */ fprintf (stderr, gettext ("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); } nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, gettext ("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, gettext ("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf (stderr, gettext ("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, gettext ("%s: illegal option -- %c\n"), argv[0], c); else fprintf (stderr, gettext ("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, gettext ("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } dealer/getopt.h0100644000076400001440000000743610002574545012652 0ustar henkusers/* Declarations for getopt. Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _GETOPT_H #define _GETOPT_H 1 /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { const char *name; int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ #define no_argument 0 #define required_argument 1 #define optional_argument 2 /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int argc, char *const *argv, const char *shortopts); extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind, int long_only); #endif /* _GETOPT_H */ dealer/Examples/0040755000076400001440000000000010056357700012747 5ustar henkusersdealer/Examples/Refer.blue_team0100644000076400001440000000277610056343363015702 0ustar henkusersA Q 3 K 6 A Q 9 7 K J J 9 Q T 7 5 3 2 A K 8 5 J 3 2 K T 5 Q 9 8 A T 3 K 7 6 4 A Q J T 7 4 A 9 K J T 8 7 A K Q 2 J 8 7 3 K 5 2 Q 7 4 A 6 5 4 K Q 3 A 5 K J 2 8 4 J A K Q J 8 7 2 A Q 8 2 J 4 3 K Q J 8 6 A 5 4 2 A K 9 5 4 3 Q T 8 7 6 8 7 A Q 4 A K T Q A Q J 7 5 4 J 7 3 K T 9 6 A K 4 Q T 5 3 2 A Q J 7 2 K 9 Q J 9 7 A J 8 4 K Q 9 7 9 3 Q T 4 A K Q 7 8 A 5 2 Q T 9 4 3 A K Q J 8 3 7 A J 3 K 9 - K 9 7 6 5 4 A K 7 5 Q T 4 2 9 3 K Q 7 A K Q 8 T 7 4 3 K 7 6 J 9 4 2 A J T 8 K 5 A T 5 K Q 8 4 A 7 6 3 A J 6 K Q 9 8 7 K Q 6 3 7 4 2 Frequency : 0 0 1 1 2 9 3 0 4 0 5 0 6 0 Frequency : 0 0 1 0 2 0 3 0 4 0 5 0 6 3 7 4 8 3 9 0 10 0 11 0 12 0 13 0 Generated 904 hands Produced 10 hands Initial random seed 1 Time needed 0.002 sec dealer/Examples/Makefile0100644000076400001440000000116610002574544014406 0ustar henkusers# # Makefile to process all Descr.* files with dealer and write the output # to Output.*. make test executes the test, make clean cleans up. # Depending on the CPU power that you have, these test may take up to # 30 minutes to run. # SHELL=/bin/sh OUTPUT = $(wildcard Output.*) test: examples distribution distribution: ../dealer -s 1 Output.distribution diff Output.distribution Refer.distribution examples: test_dealer.pl refer: -for f in ${OUTPUT}; do \ echo $$f; \ f1=`echo $$f | sed s/Output/Refer/` ; \ echo $$f1; \ /bin/cp $$f $$f1; \ done clean: -rm -f ${OUTPUT} dealer/Examples/Refer.distribution0100644000076400001440000001745510056343636016467 0ustar henkusersGenerated 1000000 hands HCP Distribution ================ # N E S W % diff % diff % diff % diff 0 0.36 -0.001 0.36 0.002 0.36 -0.003 0.37 0.012 0.36 1 0.80 0.012 0.80 0.010 0.79 -0.003 0.79 0.002 0.79 2 1.34 -0.008 1.36 0.011 1.35 -0.000 1.36 0.010 1.35 3 2.44 -0.024 2.48 0.025 2.46 0.000 2.49 0.027 2.46 4 3.86 0.007 3.85 0.004 3.85 -0.001 3.84 -0.011 3.85 5 5.16 -0.030 5.19 -0.003 5.13 -0.060 5.17 -0.019 5.19 6 6.59 0.041 6.58 0.033 6.55 -0.005 6.56 0.009 6.55 7 7.97 -0.059 8.02 -0.007 8.00 -0.035 8.06 0.031 8.03 8 8.91 0.025 8.84 -0.050 8.94 0.050 8.88 -0.010 8.89 9 9.36 0.001 9.34 -0.019 9.40 0.039 9.36 0.001 9.36 10 9.43 0.021 9.42 0.009 9.38 -0.027 9.40 -0.014 9.41 11 8.92 -0.024 8.94 -0.000 8.94 0.004 8.89 -0.049 8.94 12 8.05 0.019 8.01 -0.018 8.02 -0.007 8.07 0.044 8.03 13 6.93 0.024 6.96 0.049 6.91 -0.002 6.88 -0.027 6.91 14 5.70 0.005 5.67 -0.023 5.73 0.037 5.69 0.003 5.69 15 4.43 0.007 4.41 -0.010 4.45 0.031 4.43 0.010 4.42 16 3.31 -0.001 3.34 0.033 3.31 -0.001 3.29 -0.015 3.31 17 2.36 -0.001 2.34 -0.018 2.36 0.003 2.35 -0.005 2.36 18 1.62 0.014 1.60 -0.012 1.60 -0.009 1.61 0.003 1.61 19 1.04 -0.004 1.03 -0.009 1.04 0.001 1.04 0.001 1.04 20 0.65 0.007 0.64 0.002 0.64 0.002 0.65 0.008 0.64 21 0.38 -0.004 0.38 -0.003 0.37 -0.005 0.37 -0.009 0.38 22 0.20 -0.011 0.21 0.003 0.21 -0.002 0.21 0.001 0.21 23 0.11 -0.004 0.12 0.006 0.11 -0.003 0.11 0.004 0.11 24 0.06 -0.004 0.05 -0.006 0.06 -0.004 0.06 -0.001 0.06 25 0.02 -0.005 0.02 -0.007 0.03 -0.002 0.03 -0.004 0.03 26 0.01 0.002 0.01 0.001 0.01 0.002 0.01 0.000 0.01 27 0.01 0.005 0.00 0.005 0.01 0.005 0.01 0.005 0.00 28 0.00 0.002 0.00 0.002 0.00 0.003 0.00 0.002 0.00 29 0.00 0.001 0.00 0.001 0.00 0.001 0.00 0.001 0.00 30 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 31 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 32 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 33 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 34 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 35 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 36 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 37 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 Spades Distribution ===================== # N E S W % diff % diff % diff % diff 0 1.28 0.006 1.27 0.002 1.28 0.008 1.28 0.012 1.27 1 8.00 -0.007 8.03 0.019 7.99 -0.024 8.03 0.016 8.01 2 20.65 0.057 20.55 -0.037 20.57 -0.023 20.50 -0.094 20.59 3 28.61 -0.019 28.56 -0.066 28.77 0.144 28.64 0.014 28.63 4 23.88 0.007 23.87 -0.003 23.79 -0.083 23.91 0.042 23.87 5 12.46 -0.013 12.58 0.114 12.47 0.001 12.45 -0.021 12.47 6 4.12 -0.041 4.14 -0.016 4.13 -0.032 4.19 0.030 4.16 7 0.88 -0.000 0.86 -0.017 0.89 0.009 0.88 -0.003 0.88 8 0.12 -0.001 0.11 -0.005 0.11 -0.008 0.11 -0.005 0.12 9 0.01 0.001 0.01 -0.001 0.01 -0.002 0.01 -0.001 0.01 10 0.00 0.001 0.00 0.001 0.00 0.000 0.00 0.000 0.00 11 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 12 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 13 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 Hearts Distribution ===================== # N E S W % diff % diff % diff % diff 0 1.28 0.006 1.28 0.009 1.28 0.010 1.27 -0.004 1.27 1 7.98 -0.030 7.97 -0.037 7.99 -0.020 8.01 0.001 8.01 2 20.62 0.027 20.61 0.017 20.55 -0.040 20.58 -0.006 20.59 3 28.63 -0.002 28.66 0.027 28.61 -0.020 28.68 0.049 28.63 4 23.96 0.089 23.88 0.013 23.91 0.037 23.84 -0.031 23.87 5 12.41 -0.064 12.49 0.020 12.50 0.032 12.47 -0.005 12.47 6 4.12 -0.040 4.10 -0.062 4.16 0.003 4.16 -0.002 4.16 7 0.89 0.006 0.88 0.004 0.87 -0.006 0.87 -0.009 0.88 8 0.12 -0.004 0.12 -0.003 0.12 -0.004 0.12 -0.002 0.12 9 0.01 0.000 0.01 -0.000 0.01 -0.001 0.01 -0.001 0.01 10 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.001 0.00 11 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 12 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 13 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 Diamonds Distribution ===================== # N E S W % diff % diff % diff % diff 0 1.27 0.005 1.29 0.023 1.28 0.006 1.28 0.008 1.27 1 8.02 0.014 7.96 -0.052 7.98 -0.034 8.00 -0.010 8.01 2 20.59 -0.004 20.58 -0.015 20.63 0.038 20.58 -0.015 20.59 3 28.64 0.014 28.66 0.026 28.56 -0.073 28.68 0.047 28.63 4 23.89 0.017 23.87 -0.003 23.91 0.041 23.86 -0.010 23.87 5 12.46 -0.010 12.53 0.061 12.48 0.011 12.46 -0.008 12.47 6 4.12 -0.038 4.12 -0.042 4.16 0.000 4.13 -0.026 4.16 7 0.88 -0.002 0.88 -0.001 0.89 0.005 0.89 0.013 0.88 8 0.11 -0.006 0.11 -0.006 0.12 -0.005 0.11 -0.007 0.12 9 0.01 -0.001 0.01 -0.001 0.01 0.000 0.01 -0.002 0.01 10 0.00 0.000 0.00 0.001 0.00 0.000 0.00 0.000 0.00 11 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 12 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 13 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 Clubs Distribution ===================== # N E S W % diff % diff % diff % diff 0 1.29 0.019 1.29 0.025 1.29 0.021 1.27 -0.003 1.27 1 7.95 -0.057 8.00 -0.012 8.01 0.001 8.00 -0.010 8.01 2 20.49 -0.099 20.61 0.015 20.61 0.019 20.67 0.080 20.59 3 28.65 0.022 28.66 0.026 28.65 0.016 28.59 -0.044 28.63 4 23.91 0.035 23.83 -0.044 23.85 -0.022 23.86 -0.012 23.87 5 12.54 0.066 12.46 -0.006 12.45 -0.021 12.46 -0.014 12.47 6 4.16 0.003 4.16 -0.002 4.15 -0.009 4.15 -0.010 4.16 7 0.89 0.012 0.87 -0.010 0.87 -0.007 0.89 0.008 0.88 8 0.11 -0.012 0.12 -0.003 0.12 -0.005 0.12 -0.004 0.12 9 0.01 0.000 0.01 0.000 0.01 -0.002 0.01 -0.002 0.01 10 0.00 0.001 0.00 0.001 0.00 0.000 0.00 0.001 0.00 11 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 12 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 13 0.00 0.000 0.00 0.000 0.00 0.000 0.00 0.000 0.00 Individual Cards ================ Spades Hearts Diamonds Clubs # N E S W N E S W N E S W N E S W 2 -0.01 -0.03 -0.01 0.05 0.03 0.01 0.00 -0.05 0.04 -0.00 -0.09 0.05 0.04 -0.00 -0.09 0.05 3 -0.00 0.04 0.01 -0.04 -0.02 -0.01 0.03 -0.00 -0.05 0.07 0.00 -0.01 -0.04 0.06 -0.02 -0.00 4 -0.02 0.03 -0.03 0.02 0.04 -0.01 -0.02 -0.01 0.04 -0.06 -0.02 0.04 -0.03 -0.01 0.01 0.04 5 -0.07 0.03 -0.02 0.06 -0.11 0.04 0.08 -0.01 0.01 -0.09 0.11 -0.04 0.06 -0.05 -0.01 -0.00 6 -0.04 0.10 -0.07 0.00 -0.02 0.03 0.05 -0.06 -0.02 0.05 -0.06 0.02 0.05 -0.05 0.02 -0.02 7 -0.01 0.00 -0.02 0.03 -0.06 -0.00 -0.04 0.11 -0.04 -0.01 0.08 -0.03 0.03 -0.04 -0.01 0.03 8 0.05 0.01 -0.04 -0.02 0.06 -0.00 -0.03 -0.02 0.03 -0.00 0.01 -0.03 0.05 -0.02 0.02 -0.05 9 -0.02 -0.04 0.05 0.01 -0.07 -0.02 0.01 0.08 0.05 0.03 -0.06 -0.03 0.07 -0.02 -0.06 0.01 T -0.05 0.00 0.05 0.01 -0.01 0.07 -0.01 -0.04 -0.03 -0.03 -0.03 0.09 0.06 -0.03 -0.01 -0.02 J -0.00 0.03 0.03 -0.05 -0.04 -0.06 0.00 0.09 -0.07 0.06 0.11 -0.11 0.00 0.09 -0.10 0.01 Q -0.01 0.01 -0.01 0.01 0.08 -0.09 0.06 -0.05 -0.00 -0.04 0.01 0.03 0.07 0.02 -0.02 -0.07 K 0.03 0.00 -0.06 0.02 0.04 -0.03 0.02 -0.03 -0.04 0.02 0.00 0.02 0.06 -0.00 0.01 -0.06 A -0.00 -0.05 0.02 0.04 0.00 0.00 0.03 -0.03 -0.02 0.04 0.01 -0.04 -0.03 -0.08 0.07 0.03 dealer/Examples/Descr.stayman0100644000076400001440000000125510002574544015403 0ustar henkusersgenerate 1000000 east_notrump = shape(east, any 4333 + any 4432 + any 5332) and hcp(east) >= 15 and hcp(east) <= 17 west_stayman = shape(west, 3451 + 4351) and hcp(west) <= 7 east_2d = shape(east, xxxx - 4xxx - x4xx - 5xxx - x5xx) east_2h = shape(east, x4xx) east_2s = shape(east, 4xxx - x4xx) east_2n = shape(east, 5xxx + x5xx) d = diamonds(east)+diamonds(west) h = hearts(east)+hearts(west) s = spades(east)+spades(west) found_d_fit = east_2d and d>=8 found_h_fit = east_2h and h>=8 found_s_fit = east_2s and s>=8 found_M_fit = east_2n and (h>=9 or s>=9) condition east_notrump and west_stayman action average "fit" found_d_fit or found_h_fit or found_s_fit or found_M_fit dealer/Examples/Descr.pbn0100644000076400001440000000042510002574544014504 0ustar henkusers# # This example creates hands in PBN format # west1c = hcp(west)>16 east1h = hcp(east)>7 && control(east)<3 condition west1c and east1h # # Dealer and Vulnerability of the simulated problem # vulnerable all dealer north # produce 10 action printpbn dealer/Examples/Refer.vvga20100644000076400001440000000014410056343617014757 0ustar henkusers3.09904 Generated 1000000 hands Produced 20325 hands Initial random seed 1 Time needed 1.276 sec dealer/Examples/Descr.controls0100644000076400001440000000040310002574544015564 0ustar henkusers# This example calculates the frequency of controls (A=2, K=1) in a # strong balanced hand condition shape(north, any 4333 + any 4432 + any 5332) and hcp(north)>=20 and hcp(north)<=22 produce 10000 action frequency "controls" (control(north), 0, 12) dealer/Examples/Refer.you_hold0100644000076400001440000001554410056343621015561 0ustar henkusers 1. 8 J 9 7 3 A Q 5 4 2 K T 6 A 3 2 9 6 4 K J 8 7 Q T 5 K J T 7 5 4 9 8 3 2 A Q 6 J 6 5 Q 8 7 4 A K T 9 3 2 2. J T 6 K 7 3 A Q 5 4 2 9 8 3 Q T 6 5 2 K J 8 7 A 9 4 K Q 9 7 6 5 T 8 3 2 A J 4 9 5 3 J T 7 A K Q 8 6 4 2 3. 9 3 T 7 6 A Q 5 4 2 K J 8 T 6 4 9 5 K J 8 7 A Q 3 2 A K J T 8 4 Q 9 3 2 7 6 5 8 3 T 9 6 5 4 2 A K Q J 7 4. K 9 8 T 7 A Q 5 4 2 J 6 3 6 2 A Q T 5 4 3 K J 8 7 9 Q J T 9 7 6 5 3 2 A K 8 4 7 3 9 8 4 2 A K Q J T 6 5 5. T 6 J 7 A Q 5 4 2 K 9 8 3 9 2 T 6 3 K J 8 7 A Q 5 4 A K Q J 7 4 T 9 8 3 2 6 5 7 6 4 J 9 8 5 3 A K Q T 2 6. T 6 J 9 7 3 A Q 5 4 2 K 8 9 4 A T 6 3 2 K J 8 7 Q 5 K Q T 6 5 4 7 3 2 A J 9 8 Q 4 2 9 7 6 A K J T 8 5 3 7. K 8 J 9 7 A Q 5 4 2 T 6 3 6 4 3 Q T 5 2 K J 8 7 A 9 Q T 9 7 6 5 J 4 3 2 A K 8 Q 7 J 5 4 3 A K T 9 8 6 2 8. 8 7 6 J T 9 A Q 5 4 2 K 3 9 5 Q T 6 4 2 K J 8 7 A 3 A Q J 9 8 7 5 3 2 K T 6 4 Q 4 T 8 6 5 A K J 9 7 3 2 9. T 9 6 3 A Q 5 4 2 K J 8 7 Q T 9 5 4 2 K J 8 7 A 6 3 A Q 8 7 6 4 K T 3 2 J 9 5 J 6 5 T 9 8 4 2 A K Q 7 3 10. J T 9 8 6 A Q 5 4 2 K 7 3 Q 5 2 T 9 6 3 K J 8 7 A 4 A Q 8 6 5 4 J T 9 7 3 2 K J 6 3 2 A K Q T 9 8 7 5 4 11. J 8 7 T 9 6 A Q 5 4 2 K 3 T 6 Q 9 5 4 2 K J 8 7 A 3 A K 9 8 6 5 4 3 2 Q J T 7 7 6 T 8 5 3 A K Q J 9 4 2 12. 7 3 J 8 6 A Q 5 4 2 K T 9 T 4 2 5 3 K J 8 7 A Q 9 6 K Q J T 7 5 A 9 8 3 2 6 4 7 2 T 8 6 4 3 A K Q J 9 5 13. 9 8 J T 7 6 A Q 5 4 2 K 3 T 3 Q 9 4 2 K J 8 7 A 6 5 A Q J T 8 5 7 4 3 2 K 9 6 6 5 2 7 4 3 A K Q J T 9 8 14. T 8 K J 7 3 A Q 5 4 2 9 6 9 4 2 T 3 K J 8 7 A Q 6 5 K Q J 8 7 5 T 6 4 3 2 A 9 8 2 T 7 4 3 A K Q J 9 6 5 15. J T 6 8 7 A Q 5 4 2 K 9 3 T 2 9 6 4 K J 8 7 A Q 5 3 A K 8 7 6 5 Q T 4 3 2 J 9 4 3 Q 9 8 6 2 A K J T 7 5 16. 9 7 3 T 6 A Q 5 4 2 K J 8 T 4 A 9 6 5 3 2 K J 8 7 Q K Q J 9 6 5 8 7 3 2 A T 4 8 4 9 7 5 A K Q J T 6 3 2 17. K T 8 7 A Q 5 4 2 J 9 6 3 T 4 Q 9 6 5 K J 8 7 A 3 2 K Q J T 9 8 7 6 3 2 A 5 4 8 5 3 J 9 6 4 2 A K Q T 7 18. J T 9 6 A Q 5 4 2 K 8 7 3 A 2 T 5 4 K J 8 7 Q 9 6 3 J T 9 7 6 5 K 8 4 3 2 A Q T 5 J 9 8 6 4 3 A K Q 7 2 19. T 6 K 9 8 7 3 A Q 5 4 2 J 9 5 T 4 2 K J 8 7 A Q 6 3 A Q J T 8 7 9 6 3 2 K 5 4 J 9 8 7 4 3 A K Q T 6 5 2 20. T 9 8 3 A Q 5 4 2 K J 7 6 Q T 3 A 9 5 K J 8 7 6 4 2 K Q J 8 7 5 T 6 4 3 2 A 9 T 6 8 5 4 3 2 A K Q J 9 7 21. K 8 J T 3 A Q 5 4 2 9 7 6 6 2 Q T 9 5 3 K J 8 7 A 4 A J T 8 7 5 4 9 3 2 K Q 6 7 6 J T 9 2 A K Q 8 5 4 3 22. 7 T 9 8 A Q 5 4 2 K J 6 3 5 4 Q 3 2 K J 8 7 A T 9 6 A K J T 9 8 6 Q 7 4 3 2 5 8 5 2 T 7 6 3 A K Q J 9 4 23. 8 7 6 9 A Q 5 4 2 K J T 3 T Q 6 5 4 2 K J 8 7 A 9 3 A K Q T 6 5 J 9 8 7 3 2 4 8 6 3 7 5 4 A K Q J T 9 2 24. T 9 7 K J 6 A Q 5 4 2 8 3 A 6 5 T 4 3 K J 8 7 Q 9 2 Q J 9 8 6 5 4 3 2 A K T 7 T J 9 7 6 5 2 A K Q 8 4 3 25. 3 K J 8 7 6 A Q 5 4 2 T 9 Q 5 2 T 4 3 K J 8 7 A 9 6 A T 9 8 7 5 J 6 4 3 2 K Q J 9 5 7 2 A K Q T 8 6 4 3 Generated 10164 hands Produced 25 hands Initial random seed 1 Time needed 0.021 sec dealer/Examples/Descr.vvga20100644000076400001440000000041610002574544014752 0ustar henkusers# # Example to estimate the number of spades in the west hand opposite # a given east-hand. # predeal east ST9854, HK86, DT765, CT condition hcp(west) >= 20 && hcp(west)<=22 && shape(west, any 4333 + any 4432 + any 5332) generate 1000000 action average spades(west) dealer/Examples/Refer.pbn0100644000076400001440000000612410056343413014507 0ustar henkusers[Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "1"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:7542.T843.8.T964 K6.KJ.QT7532.J32 JT98.652.AK64.Q7 AQ3.AQ97.J9.AK85"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "2"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:A764.J9.532.Q652 Q98.K764.4.KJT87 J32.Q852.K986.43 KT5.AT3.AQJT7.A9"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "3"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:94.JT983.J8.T973 J873.Q74.KQ3.KJ2 T65.A6.T972.Q864 AKQ2.K52.A654.A5"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "4"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:KQT6532.T6.T95.9 J.QJ872.J43.A542 A97.9543.K76.T73 84.AK.AQ82.KQJ86"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "5"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:J.T632.J9754.932 QT876.AQ4.Q.J754 2.KJ95.8632.KT86 AK9543.87.AKT.AQ"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "6"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:Q82.J976.8643.K8 KT96.QT532.K9.97 A54.8.T5.AT65432 J73.AK4.AQJ72.QJ"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "7"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:52.K8752.532.KJ8 KQ97.QT4.8.QT943 T63.AJ6.JT964.76 AJ84.93.AKQ7.A52"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "8"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:952.82.AQT82.J63 7.K9.K97654.QT42 T64.QT7654.J3.98 AKQJ83.AJ3..AK75"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "9"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:J82.J9652.Q8.942 KQ7.T743.J942.K5 AT654..AT53.Q763 93.AKQ8.K76.AJT8"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 1"] [Site "-"] [Date "2004.05.30"] [Board "10"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:763.QJT5.T54.A98 KQ84.3.KQ987.742 J92.K9842.32.JT5 AT5.A76.AJ6.KQ63"] [Declarer "?"] [Contract "?"] [Result "?"] Generated 904 hands Produced 10 hands Initial random seed 1 Time needed 0.003 sec dealer/Examples/Refer.evaluation0100644000076400001440000000171410056343365016105 0ustar henkusers North hands: 1. A K Q T 3 J 6 K J 4 2 9 5 Losers: 6 S : 0 H : 2 D : 2 C : 2 HCP: 14 S : 9 H : 1 D : 4 C : 0 Control: 4 S : 3 H : 0 D : 1 C : 0 North hands: 1. A K Q T 3 J 6 K J 4 2 9 5 C4: 1605 S : 500 H : 20 D : 160 C : 0 tens: 1 S : 1 H : 0 D : 0 C : 0 jacks: 2 S : 0 H : 1 D : 1 C : 0 North hands: 1. A K Q T 3 J 6 K J 4 2 9 5 queens: 1 S : 1 H : 0 D : 0 C : 0 kings: 2 S : 1 H : 0 D : 1 C : 0 aces: 1 S : 1 H : 0 D : 0 C : 0 North hands: 1. A K Q T 3 J 6 K J 4 2 9 5 top2: 3 S : 2 H : 0 D : 1 C : 0 top3: 4 S : 3 H : 0 D : 1 C : 0 top4: 6 S : 3 H : 1 D : 2 C : 0 North hands: 1. A K Q T 3 J 6 K J 4 2 9 5 top5: 7 S : 4 H : 1 D : 2 C : 0 c13: 18 S : 12 H : 1 D : 5 C : 0 North hands: 1. A K Q T 3 J 6 K J 4 2 9 5 Generated 1 hands Produced 1 hands Initial random seed 1 Time needed 0.001 sec dealer/Examples/Descr.evaluation0100644000076400001440000000543210002574544016077 0ustar henkusers# Test script for verifying each of the point count # mechanisms; useful for debugging the analyze function produce 1 action print ( north ), average "Losers" loser(north), average "S " loser(north, spades), average "H " loser(north, hearts), average "D " loser(north, diamonds), average "C " loser(north, clubs), average "HCP" hcp(north), average "S " hcp(north, spades), average "H " hcp(north, hearts), average "D " hcp(north, diamonds), average "C " hcp(north, clubs), average "Control" control(north), average "S " control(north, spades), average "H " control(north, hearts), average "D " control(north, diamonds), average "C " control(north, clubs), print ( north ), average "C4" cccc(north), average "S " quality(north, spades), average "H " quality(north, hearts), average "D " quality(north, diamonds), average "C " quality(north, clubs), average "tens" tens(north), average "S " tens(north, spades), average "H " tens(north, hearts), average "D " tens(north, diamonds), average "C " tens(north, clubs), average "jacks" jacks(north), average "S " jacks(north, spades), average "H " jacks(north, hearts), average "D " jacks(north, diamonds), average "C " jacks(north, clubs), print ( north ), average "queens" queens(north), average "S " queens(north, spades), average "H " queens(north, hearts), average "D " queens(north, diamonds), average "C " queens(north, clubs), average "kings" kings(north), average "S " kings(north, spades), average "H " kings(north, hearts), average "D " kings(north, diamonds), average "C " kings(north, clubs), average "aces" aces(north), average "S " aces(north, spades), average "H " aces(north, hearts), average "D " aces(north, diamonds), average "C " aces(north, clubs), print ( north ), average "top2" top2(north), average "S " top2(north, spades), average "H " top2(north, hearts), average "D " top2(north, diamonds), average "C " top2(north, clubs), average "top3" top3(north), average "S " top3(north, spades), average "H " top3(north, hearts), average "D " top3(north, diamonds), average "C " top3(north, clubs), average "top4" top4(north), average "S " top4(north, spades), average "H " top4(north, hearts), average "D " top4(north, diamonds), average "C " top4(north, clubs), print ( north ), average "top5" top5(north), average "S " top5(north, spades), average "H " top5(north, hearts), average "D " top5(north, diamonds), average "C " top5(north, clubs), average "c13" c13(north), average "S " c13(north, spades), average "H " c13(north, hearts), average "D " c13(north, diamonds), average "C " c13(north, clubs), print ( north ) dealer/Examples/Descr.notrump0100644000076400001440000000105610002574544015432 0ustar henkusers# Generate hands for practicing bidding after 1NT, then print them in the # 1 line/deal format and on separate sheets with only the East and West # hands. east_notrump = shape(east, any 4333 + any 4432 + any 5332 - 5xxx - x5xx) && hcp(east)>=15 && hcp(east)<=17 # # West gets either 7-9 hcp or 13-18 # west_interesting_low = hcp(west)>=7 and hcp(west)<=9 west_interesting_high = hcp(west)>=13 and hcp(west)<=18 condition east_notrump and ( west_interesting_low or west_interesting_high) produce 100 action printoneline, print(east, west) dealer/Examples/Descr.hm1dr2d0100644000076400001440000000662610002574544015177 0ustar henkusersgenerate 50000000 produce 100000 eopen = hcp(east)>=10 and hcp(east)<=14 e1nt = eopen and hearts(east)>=4 and spades(east)>=4 e1h = eopen and (not e1nt) and hearts(east)>=4 e1s = eopen and (not e1nt) and spades(east)>=4 e1d = eopen and (not e1nt) and (not e1h) and (not e1s) wrele = hcp(west)>=12 e2d = spades(east)<=2 and clubs(east)<=3 e0094 = shape(east,0094) e0184 = shape(east,0184) e0193 = shape(east,0193) e0274 = shape(east,0274) e0283 = shape(east,0283) e0292 = shape(east,0292) e0364 = shape(east,0364) e0373 = shape(east,0373) e0382 = shape(east,0382) e0391 = shape(east,0391) e1084 = shape(east,1084) e1093 = shape(east,1093) e1174 = shape(east,1174) e1183 = shape(east,1183) e1192 = shape(east,1192) e1264 = shape(east,1264) e1273 = shape(east,1273) e1282 = shape(east,1282) e1291 = shape(east,1291) e1354 = shape(east,1354) e1363 = shape(east,1363) e1372 = shape(east,1372) e1381 = shape(east,1381) e1390 = shape(east,1390) e2074 = shape(east,2074) e2083 = shape(east,2083) e2092 = shape(east,2092) e2164 = shape(east,2164) e2173 = shape(east,2173) e2182 = shape(east,2182) # e2191 = shape(east,2191) # e2254 = shape(east,2254) # e2263 = shape(east,2263) # e2272 = shape(east,2272) # e2281 = shape(east,2281) # e2290 = shape(east,2290) # e2344 = shape(east,2344) # e2353 = shape(east,2353) # e2362 = shape(east,2362) # e2371 = shape(east,2371) # e2380 = shape(east,2380) # e3064 = shape(east,3064) # e3073 = shape(east,3073) # e3082 = shape(east,3082) # e3091 = shape(east,3091) # e3154 = shape(east,3154) # e3163 = shape(east,3163) # e3172 = shape(east,3172) # e3181 = shape(east,3181) # e3190 = shape(east,3190) # e3244 = shape(east,3244) # e3253 = shape(east,3253) # e3262 = shape(east,3262) # e3271 = shape(east,3271) # e3280 = shape(east,3280) # e3334 = shape(east,3334) # e3343 = shape(east,3343) e3352 = shape(east,3352) # e3361 = shape(east,3361) # e3370 = shape(east,3370) condition e1d and e2d action # average "e0094" e0094, # average "e0184" e0184, # average "e0193" e0193, # average "e0274" e0274, # average "e0283" e0283, # average "e0292" e0292, # average "e0364" e0364, # average "e0373" e0373, # average "e0382" e0382, # average "e0391" e0391, # average "e1084" e1084, # average "e1093" e1093, # average "e1174" e1174, # average "e1183" e1183, # average "e1192" e1192, # average "e1264" e1264, # average "e1273" e1273, # average "e1282" e1282, # average "e1291" e1291, # average "e1354" e1354, # average "e1363" e1363, # average "e1372" e1372, # average "e1381" e1381, # average "e1390" e1390, # average "e2074" e2074, # average "e2083" e2083, # average "e2092" e2092, # average "e2164" e2164, # average "e2173" e2173, # average "e2182" e2182, # average "e2191" e2191, # average "e2254" e2254, # average "e2263" e2263, # average "e2272" e2272, # average "e2281" e2281, # average "e2290" e2290, # average "e2344" e2344, # average "e2353" e2353, # average "e2362" e2362, # average "e2371" e2371, # average "e2380" e2380, # average "e3064" e3064, # average "e3073" e3073, # average "e3082" e3082, # average "e3091" e3091, # average "e3154" e3154, # average "e3163" e3163, # average "e3172" e3172, # average "e3181" e3181, # average "e3190" e3190, # average "e3244" e3244, # average "e3253" e3253, # average "e3262" e3262, # average "e3271" e3271, # average "e3280" e3280, # average "e3334" e3334, # average "e3343" e3343, average "e3352" e3352, # average "e3361" e3361, # average "e3370" e3370, frequency "spades" (spades(east),0,3) dealer/Examples/Descr.6c0100644000076400001440000000131710002574544014236 0ustar henkusers# A typical play decision, here is the hand, the bidding and trick one # # J x x x x x x # J x # x x # 9 5 # # # A # A Q # A # A Q J 10 x x x x x # # W N E S # p p 1D dbl # 1H 2S 3H 4C # p 4S p 6C # all pass # # The lead is a small diamond to the K and A, how to play? # Two possibilities, play for the drop of the KC or lead the QC, # cross to the 9 and take the heart finesse. # # the inferences from bidding and trick one are encoded below predeal north SJ865432, HJ5, D72, C95 west DQ5 south SA, HAQ, DA, CAQJT87642 east DKJ generate 1000000 condition hcp(east)>=10 && shape(west, x5xx) && shape(east, x45x + x46x + x47x) action average "king drops" shape(west, xxx1), average "finesse" hascard(east, KH) dealer/Examples/Refer.test_dealer0100644000076400001440000004054010056343616016230 0ustar henkusersFrequency HCP N: 0 36429 1 78845 2 135739 3 245369 4 384365 5 518847 6 655775 7 801919 8 888580 9 936047 10 940283 11 895060 12 803454 13 691704 14 569899 15 442112 16 330708 17 236912 18 160933 19 103053 20 64167 21 37668 22 21043 23 10917 24 5572 25 2622 26 1202 27 495 28 199 29 51 30 26 31 4 32 1 33 0 34 0 35 0 36 0 37 0 Frequency HCP E: 0 36338 1 78787 2 135429 3 246186 4 384859 5 518681 6 655920 7 803525 8 890036 9 934981 10 941346 11 893522 12 803179 13 690725 14 569350 15 441956 16 331470 17 235520 18 160607 19 103179 20 64469 21 37570 22 21059 23 11183 24 5588 25 2569 26 1212 27 475 28 190 29 65 30 17 31 4 32 2 33 1 34 0 35 0 36 0 37 0 Frequency HCP S: 0 36450 1 78476 2 135613 3 245606 4 383458 5 518561 6 656952 7 801915 8 889866 9 935903 10 941565 11 895822 12 802349 13 690651 14 569236 15 442690 16 331373 17 235767 18 160071 19 103558 20 64335 21 37748 22 20909 23 10923 24 5609 25 2607 26 1212 27 485 28 185 29 71 30 29 31 3 32 1 33 1 34 0 35 0 36 0 37 0 Frequency HCP W: 0 36384 1 79070 2 135267 3 246207 4 384949 5 517067 6 655071 7 802332 8 888895 9 936562 10 941270 11 894140 12 802168 13 692348 14 570356 15 442847 16 330479 17 236300 18 160131 19 103745 20 64452 21 37408 22 21109 23 11155 24 5652 25 2658 26 1181 27 487 28 207 29 72 30 24 31 7 32 0 33 0 34 0 35 0 36 0 37 0 Frequency Spades N: 0 127385 1 800736 2 2057406 3 2863814 4 2385912 5 1248302 6 415811 7 88115 8 11583 9 899 10 36 11 1 12 0 13 0 Frequency Spades E: 0 127601 1 801085 2 2058121 3 2863738 4 2386040 5 1247217 6 415708 7 87861 8 11617 9 964 10 47 11 1 12 0 13 0 Frequency Spades S: 0 128509 1 800639 2 2058603 3 2861891 4 2387082 5 1247859 6 414624 7 88018 8 11832 9 915 10 28 11 0 12 0 13 0 Frequency Spades W: 0 127768 1 800363 2 2058290 3 2866421 4 2385405 5 1246338 6 414376 7 88334 8 11771 9 900 10 33 11 1 12 0 13 0 Frequency Hearts N: 0 127511 1 801565 2 2057609 3 2863660 4 2387829 5 1246431 6 415155 7 87710 8 11590 9 900 10 38 11 2 12 0 13 0 Frequency Hearts E: 0 127258 1 801350 2 2058202 3 2863139 4 2386501 5 1247489 6 414963 7 88348 8 11762 9 956 10 31 11 1 12 0 13 0 Frequency Hearts S: 0 127675 1 800275 2 2059058 3 2863108 4 2387860 5 1245620 6 415657 7 88022 8 11726 9 965 10 33 11 1 12 0 13 0 Frequency Hearts W: 0 127992 1 800354 2 2058321 3 2863805 4 2385703 5 1248375 6 414397 7 88300 8 11802 9 902 10 49 11 0 12 0 13 0 Frequency Diamonds N: 0 128001 1 799133 2 2059279 3 2863499 4 2387043 5 1246701 6 415535 7 88356 8 11441 9 972 10 38 11 2 12 0 13 0 Frequency Diamonds E: 0 127958 1 799956 2 2056988 3 2863505 4 2387428 5 1247936 6 415438 7 88220 8 11634 9 887 10 49 11 1 12 0 13 0 Frequency Diamonds S: 0 128220 1 801152 2 2058113 3 2864909 4 2385643 5 1246446 6 414837 7 87840 8 11907 9 887 10 45 11 1 12 0 13 0 Frequency Diamonds W: 0 127785 1 800482 2 2059302 3 2864098 4 2386266 5 1245530 6 415743 7 88196 8 11659 9 907 10 29 11 2 12 1 13 0 Frequency Clubs N: 0 128141 1 801180 2 2058687 3 2863698 4 2385385 5 1247463 6 414780 7 88111 8 11553 9 953 10 46 11 3 12 0 13 0 Frequency Clubs E: 0 128218 1 800935 2 2059628 3 2863494 4 2386749 5 1245824 6 414145 7 88302 8 11724 9 947 10 34 11 0 12 0 13 0 Frequency Clubs S: 0 127499 1 801102 2 2056585 3 2863939 4 2384330 5 1250088 6 415564 7 88285 8 11623 9 939 10 45 11 1 12 0 13 0 Frequency Clubs W: 0 128376 1 800258 2 2059241 3 2858810 4 2388241 5 1247798 6 416393 7 88468 8 11538 9 838 10 39 11 0 12 0 13 0 Frequency Card N SA: 0 7499848 1 2500152 Frequency Card N SK: 0 7500353 1 2499647 Frequency Card N SQ: 0 7496977 1 2503023 Frequency Card N SJ: 0 7497906 1 2502094 Frequency Card N ST: 0 7498185 1 2501815 Frequency Card N S9: 0 7501244 1 2498756 Frequency Card N S8: 0 7498622 1 2501378 Frequency Card N S7: 0 7501004 1 2498996 Frequency Card N S6: 0 7500990 1 2499010 Frequency Card N S5: 0 7502601 1 2497399 Frequency Card N S4: 0 7500657 1 2499343 Frequency Card N S3: 0 7498331 1 2501669 Frequency Card N S2: 0 7498337 1 2501663 Frequency Card N HA: 0 7501960 1 2498040 Frequency Card N HK: 0 7498655 1 2501345 Frequency Card N HQ: 0 7500978 1 2499022 Frequency Card N HJ: 0 7501002 1 2498998 Frequency Card N HT: 0 7499617 1 2500383 Frequency Card N H9: 0 7500899 1 2499101 Frequency Card N H8: 0 7499920 1 2500080 Frequency Card N H7: 0 7500396 1 2499604 Frequency Card N H6: 0 7500448 1 2499552 Frequency Card N H5: 0 7501377 1 2498623 Frequency Card N H4: 0 7499345 1 2500655 Frequency Card N H3: 0 7500040 1 2499960 Frequency Card N H2: 0 7498007 1 2501993 Frequency Card N DA: 0 7498125 1 2501875 Frequency Card N DK: 0 7501852 1 2498148 Frequency Card N DQ: 0 7500333 1 2499667 Frequency Card N DJ: 0 7500100 1 2499900 Frequency Card N DT: 0 7499088 1 2500912 Frequency Card N D9: 0 7496936 1 2503064 Frequency Card N D8: 0 7498199 1 2501801 Frequency Card N D7: 0 7497617 1 2502383 Frequency Card N D6: 0 7503053 1 2496947 Frequency Card N D5: 0 7501995 1 2498005 Frequency Card N D4: 0 7499708 1 2500292 Frequency Card N D3: 0 7500786 1 2499214 Frequency Card N D2: 0 7502908 1 2497092 Frequency Card N CA: 0 7501157 1 2498843 Frequency Card N CK: 0 7499625 1 2500375 Frequency Card N CQ: 0 7497538 1 2502462 Frequency Card N CJ: 0 7497978 1 2502022 Frequency Card N CT: 0 7500667 1 2499333 Frequency Card N C9: 0 7498800 1 2501200 Frequency Card N C8: 0 7500125 1 2499875 Frequency Card N C7: 0 7501435 1 2498565 Frequency Card N C6: 0 7501319 1 2498681 Frequency Card N C5: 0 7498782 1 2501218 Frequency Card N C4: 0 7503332 1 2496668 Frequency Card N C3: 0 7500880 1 2499120 Frequency Card N C2: 0 7502908 1 2497092 Frequency Card E SA: 0 7500151 1 2499849 Frequency Card E SK: 0 7498931 1 2501069 Frequency Card E SQ: 0 7501389 1 2498611 Frequency Card E SJ: 0 7500766 1 2499234 Frequency Card E ST: 0 7500622 1 2499378 Frequency Card E S9: 0 7500334 1 2499666 Frequency Card E S8: 0 7498997 1 2501003 Frequency Card E S7: 0 7498436 1 2501564 Frequency Card E S6: 0 7498728 1 2501272 Frequency Card E S5: 0 7501496 1 2498504 Frequency Card E S4: 0 7499605 1 2500395 Frequency Card E S3: 0 7499409 1 2500591 Frequency Card E S2: 0 7500982 1 2499018 Frequency Card E HA: 0 7499920 1 2500080 Frequency Card E HK: 0 7500786 1 2499214 Frequency Card E HQ: 0 7498809 1 2501191 Frequency Card E HJ: 0 7498874 1 2501126 Frequency Card E HT: 0 7497227 1 2502773 Frequency Card E H9: 0 7500982 1 2499018 Frequency Card E H8: 0 7500987 1 2499013 Frequency Card E H7: 0 7501524 1 2498476 Frequency Card E H6: 0 7500528 1 2499472 Frequency Card E H5: 0 7498057 1 2501943 Frequency Card E H4: 0 7499515 1 2500485 Frequency Card E H3: 0 7500476 1 2499524 Frequency Card E H2: 0 7500460 1 2499540 Frequency Card E DA: 0 7502186 1 2497814 Frequency Card E DK: 0 7498892 1 2501108 Frequency Card E DQ: 0 7501003 1 2498997 Frequency Card E DJ: 0 7499318 1 2500682 Frequency Card E DT: 0 7499101 1 2500899 Frequency Card E D9: 0 7500183 1 2499817 Frequency Card E D8: 0 7499378 1 2500622 Frequency Card E D7: 0 7500928 1 2499072 Frequency Card E D6: 0 7497506 1 2502494 Frequency Card E D5: 0 7498448 1 2501552 Frequency Card E D4: 0 7498802 1 2501198 Frequency Card E D3: 0 7498772 1 2501228 Frequency Card E D2: 0 7499807 1 2500193 Frequency Card E CA: 0 7502671 1 2497329 Frequency Card E CK: 0 7499353 1 2500647 Frequency Card E CQ: 0 7501390 1 2498610 Frequency Card E CJ: 0 7497737 1 2502263 Frequency Card E CT: 0 7500538 1 2499462 Frequency Card E C9: 0 7502408 1 2497592 Frequency Card E C8: 0 7501808 1 2498192 Frequency Card E C7: 0 7501553 1 2498447 Frequency Card E C6: 0 7499399 1 2500601 Frequency Card E C5: 0 7502000 1 2498000 Frequency Card E C4: 0 7499546 1 2500454 Frequency Card E C3: 0 7499362 1 2500638 Frequency Card E C2: 0 7499807 1 2500193 Frequency Card S SA: 0 7500611 1 2499389 Frequency Card S SK: 0 7501492 1 2498508 Frequency Card S SQ: 0 7502699 1 2497301 Frequency Card S SJ: 0 7501202 1 2498798 Frequency Card S ST: 0 7500612 1 2499388 Frequency Card S S9: 0 7497868 1 2502132 Frequency Card S S8: 0 7500356 1 2499644 Frequency Card S S7: 0 7499978 1 2500022 Frequency Card S S6: 0 7498051 1 2501949 Frequency Card S S5: 0 7499278 1 2500722 Frequency Card S S4: 0 7499198 1 2500802 Frequency Card S S3: 0 7500411 1 2499589 Frequency Card S S2: 0 7500062 1 2499938 Frequency Card S HA: 0 7498953 1 2501047 Frequency Card S HK: 0 7500318 1 2499682 Frequency Card S HQ: 0 7499653 1 2500347 Frequency Card S HJ: 0 7501812 1 2498188 Frequency Card S HT: 0 7498895 1 2501105 Frequency Card S H9: 0 7501236 1 2498764 Frequency Card S H8: 0 7498768 1 2501232 Frequency Card S H7: 0 7500306 1 2499694 Frequency Card S H6: 0 7498373 1 2501627 Frequency Card S H5: 0 7501177 1 2498823 Frequency Card S H4: 0 7499336 1 2500664 Frequency Card S H3: 0 7500192 1 2499808 Frequency Card S H2: 0 7500796 1 2499204 Frequency Card S DA: 0 7500623 1 2499377 Frequency Card S DK: 0 7499936 1 2500064 Frequency Card S DQ: 0 7500926 1 2499074 Frequency Card S DJ: 0 7497557 1 2502443 Frequency Card S DT: 0 7502190 1 2497810 Frequency Card S D9: 0 7500101 1 2499899 Frequency Card S D8: 0 7500371 1 2499629 Frequency Card S D7: 0 7500766 1 2499234 Frequency Card S D6: 0 7500892 1 2499108 Frequency Card S D5: 0 7497459 1 2502541 Frequency Card S D4: 0 7502831 1 2497169 Frequency Card S D3: 0 7499277 1 2500723 Frequency Card S D2: 0 7500015 1 2499985 Frequency Card S CA: 0 7498505 1 2501495 Frequency Card S CK: 0 7498000 1 2502000 Frequency Card S CQ: 0 7498945 1 2501055 Frequency Card S CJ: 0 7502464 1 2497536 Frequency Card S CT: 0 7498978 1 2501022 Frequency Card S C9: 0 7499756 1 2500244 Frequency Card S C8: 0 7498536 1 2501464 Frequency Card S C7: 0 7497755 1 2502245 Frequency Card S C6: 0 7499539 1 2500461 Frequency Card S C5: 0 7500467 1 2499533 Frequency Card S C4: 0 7499441 1 2500559 Frequency Card S C3: 0 7500475 1 2499525 Frequency Card S C2: 0 7500015 1 2499985 Frequency Card W SA: 0 7499390 1 2500610 Frequency Card W SK: 0 7499224 1 2500776 Frequency Card W SQ: 0 7498935 1 2501065 Frequency Card W SJ: 0 7500126 1 2499874 Frequency Card W ST: 0 7500581 1 2499419 Frequency Card W S9: 0 7500554 1 2499446 Frequency Card W S8: 0 7502025 1 2497975 Frequency Card W S7: 0 7500582 1 2499418 Frequency Card W S6: 0 7502231 1 2497769 Frequency Card W S5: 0 7496625 1 2503375 Frequency Card W S4: 0 7500540 1 2499460 Frequency Card W S3: 0 7501849 1 2498151 Frequency Card W S2: 0 7500619 1 2499381 Frequency Card W HA: 0 7499167 1 2500833 Frequency Card W HK: 0 7500241 1 2499759 Frequency Card W HQ: 0 7500560 1 2499440 Frequency Card W HJ: 0 7498312 1 2501688 Frequency Card W HT: 0 7504261 1 2495739 Frequency Card W H9: 0 7496883 1 2503117 Frequency Card W H8: 0 7500325 1 2499675 Frequency Card W H7: 0 7497774 1 2502226 Frequency Card W H6: 0 7500651 1 2499349 Frequency Card W H5: 0 7499389 1 2500611 Frequency Card W H4: 0 7501804 1 2498196 Frequency Card W H3: 0 7499292 1 2500708 Frequency Card W H2: 0 7500737 1 2499263 Frequency Card W DA: 0 7499066 1 2500934 Frequency Card W DK: 0 7499320 1 2500680 Frequency Card W DQ: 0 7497738 1 2502262 Frequency Card W DJ: 0 7503025 1 2496975 Frequency Card W DT: 0 7499621 1 2500379 Frequency Card W D9: 0 7502780 1 2497220 Frequency Card W D8: 0 7502052 1 2497948 Frequency Card W D7: 0 7500689 1 2499311 Frequency Card W D6: 0 7498549 1 2501451 Frequency Card W D5: 0 7502098 1 2497902 Frequency Card W D4: 0 7498659 1 2501341 Frequency Card W D3: 0 7501165 1 2498835 Frequency Card W D2: 0 7497270 1 2502730 Frequency Card W CA: 0 7497667 1 2502333 Frequency Card W CK: 0 7503022 1 2496978 Frequency Card W CQ: 0 7502127 1 2497873 Frequency Card W CJ: 0 7501821 1 2498179 Frequency Card W CT: 0 7499817 1 2500183 Frequency Card W C9: 0 7499036 1 2500964 Frequency Card W C8: 0 7499531 1 2500469 Frequency Card W C7: 0 7499257 1 2500743 Frequency Card W C6: 0 7499743 1 2500257 Frequency Card W C5: 0 7498751 1 2501249 Frequency Card W C4: 0 7497681 1 2502319 Frequency Card W C3: 0 7499283 1 2500717 Frequency Card W C2: 0 7497270 1 2502730 Generated 10000000 hands Produced 10000000 hands Initial random seed 1 Time needed 128.709 sec dealer/Examples/Descr.test_dealer0100644000076400001440000003336410002574544016230 0ustar henkusers# # This an input file to test dealer. It generates a million hands without # any constraints, then prints the frequency of the various suit lengths # and hcp holdings. The output can be piped into a perl-script to compare # it against the theoretical holdings. It should give a quick check if # the deals you are producing are sort-of random. # generate 10000000 action frequency "HCP N" (hcp(north), 0, 37), frequency "HCP E" (hcp(east), 0, 37), frequency "HCP S" (hcp(south), 0, 37), frequency "HCP W" (hcp(west), 0, 37), frequency "Spades N" (spades(north), 0, 13), frequency "Spades E" (spades(east), 0, 13), frequency "Spades S" (spades(south), 0, 13), frequency "Spades W" (spades(west), 0, 13), frequency "Hearts N" (hearts(north), 0, 13), frequency "Hearts E" (hearts(east), 0, 13), frequency "Hearts S" (hearts(south), 0, 13), frequency "Hearts W" (hearts(west), 0, 13), frequency "Diamonds N" (diamonds(north), 0, 13), frequency "Diamonds E" (diamonds(east), 0, 13), frequency "Diamonds S" (diamonds(south), 0, 13), frequency "Diamonds W" (diamonds(west), 0, 13), frequency "Clubs N" (clubs(north), 0, 13), frequency "Clubs E" (clubs(east), 0, 13), frequency "Clubs S" (clubs(south), 0, 13), frequency "Clubs W" (clubs(west), 0, 13), frequency "Card N SA" (hascard(north, AS), 0, 1), frequency "Card N SK" (hascard(north, KS), 0, 1), frequency "Card N SQ" (hascard(north, QS), 0, 1), frequency "Card N SJ" (hascard(north, JS), 0, 1), frequency "Card N ST" (hascard(north, TS), 0, 1), frequency "Card N S9" (hascard(north, 9S), 0, 1), frequency "Card N S8" (hascard(north, 8S), 0, 1), frequency "Card N S7" (hascard(north, 7S), 0, 1), frequency "Card N S6" (hascard(north, 6S), 0, 1), frequency "Card N S5" (hascard(north, 5S), 0, 1), frequency "Card N S4" (hascard(north, 4S), 0, 1), frequency "Card N S3" (hascard(north, 3S), 0, 1), frequency "Card N S2" (hascard(north, 2S), 0, 1), frequency "Card N HA" (hascard(north, AH), 0, 1), frequency "Card N HK" (hascard(north, KH), 0, 1), frequency "Card N HQ" (hascard(north, QH), 0, 1), frequency "Card N HJ" (hascard(north, JH), 0, 1), frequency "Card N HT" (hascard(north, TH), 0, 1), frequency "Card N H9" (hascard(north, 9H), 0, 1), frequency "Card N H8" (hascard(north, 8H), 0, 1), frequency "Card N H7" (hascard(north, 7H), 0, 1), frequency "Card N H6" (hascard(north, 6H), 0, 1), frequency "Card N H5" (hascard(north, 5H), 0, 1), frequency "Card N H4" (hascard(north, 4H), 0, 1), frequency "Card N H3" (hascard(north, 3H), 0, 1), frequency "Card N H2" (hascard(north, 2H), 0, 1), frequency "Card N DA" (hascard(north, AD), 0, 1), frequency "Card N DK" (hascard(north, KD), 0, 1), frequency "Card N DQ" (hascard(north, QD), 0, 1), frequency "Card N DJ" (hascard(north, JD), 0, 1), frequency "Card N DT" (hascard(north, TD), 0, 1), frequency "Card N D9" (hascard(north, 9D), 0, 1), frequency "Card N D8" (hascard(north, 8D), 0, 1), frequency "Card N D7" (hascard(north, 7D), 0, 1), frequency "Card N D6" (hascard(north, 6D), 0, 1), frequency "Card N D5" (hascard(north, 5D), 0, 1), frequency "Card N D4" (hascard(north, 4D), 0, 1), frequency "Card N D3" (hascard(north, 3D), 0, 1), frequency "Card N D2" (hascard(north, 2C), 0, 1), frequency "Card N CA" (hascard(north, AC), 0, 1), frequency "Card N CK" (hascard(north, KC), 0, 1), frequency "Card N CQ" (hascard(north, QC), 0, 1), frequency "Card N CJ" (hascard(north, JC), 0, 1), frequency "Card N CT" (hascard(north, TC), 0, 1), frequency "Card N C9" (hascard(north, 9C), 0, 1), frequency "Card N C8" (hascard(north, 8C), 0, 1), frequency "Card N C7" (hascard(north, 7C), 0, 1), frequency "Card N C6" (hascard(north, 6C), 0, 1), frequency "Card N C5" (hascard(north, 5C), 0, 1), frequency "Card N C4" (hascard(north, 4C), 0, 1), frequency "Card N C3" (hascard(north, 3C), 0, 1), frequency "Card N C2" (hascard(north, 2C), 0, 1), frequency "Card E SA" (hascard(east, AS), 0, 1), frequency "Card E SK" (hascard(east, KS), 0, 1), frequency "Card E SQ" (hascard(east, QS), 0, 1), frequency "Card E SJ" (hascard(east, JS), 0, 1), frequency "Card E ST" (hascard(east, TS), 0, 1), frequency "Card E S9" (hascard(east, 9S), 0, 1), frequency "Card E S8" (hascard(east, 8S), 0, 1), frequency "Card E S7" (hascard(east, 7S), 0, 1), frequency "Card E S6" (hascard(east, 6S), 0, 1), frequency "Card E S5" (hascard(east, 5S), 0, 1), frequency "Card E S4" (hascard(east, 4S), 0, 1), frequency "Card E S3" (hascard(east, 3S), 0, 1), frequency "Card E S2" (hascard(east, 2S), 0, 1), frequency "Card E HA" (hascard(east, AH), 0, 1), frequency "Card E HK" (hascard(east, KH), 0, 1), frequency "Card E HQ" (hascard(east, QH), 0, 1), frequency "Card E HJ" (hascard(east, JH), 0, 1), frequency "Card E HT" (hascard(east, TH), 0, 1), frequency "Card E H9" (hascard(east, 9H), 0, 1), frequency "Card E H8" (hascard(east, 8H), 0, 1), frequency "Card E H7" (hascard(east, 7H), 0, 1), frequency "Card E H6" (hascard(east, 6H), 0, 1), frequency "Card E H5" (hascard(east, 5H), 0, 1), frequency "Card E H4" (hascard(east, 4H), 0, 1), frequency "Card E H3" (hascard(east, 3H), 0, 1), frequency "Card E H2" (hascard(east, 2H), 0, 1), frequency "Card E DA" (hascard(east, AD), 0, 1), frequency "Card E DK" (hascard(east, KD), 0, 1), frequency "Card E DQ" (hascard(east, QD), 0, 1), frequency "Card E DJ" (hascard(east, JD), 0, 1), frequency "Card E DT" (hascard(east, TD), 0, 1), frequency "Card E D9" (hascard(east, 9D), 0, 1), frequency "Card E D8" (hascard(east, 8D), 0, 1), frequency "Card E D7" (hascard(east, 7D), 0, 1), frequency "Card E D6" (hascard(east, 6D), 0, 1), frequency "Card E D5" (hascard(east, 5D), 0, 1), frequency "Card E D4" (hascard(east, 4D), 0, 1), frequency "Card E D3" (hascard(east, 3D), 0, 1), frequency "Card E D2" (hascard(east, 2C), 0, 1), frequency "Card E CA" (hascard(east, AC), 0, 1), frequency "Card E CK" (hascard(east, KC), 0, 1), frequency "Card E CQ" (hascard(east, QC), 0, 1), frequency "Card E CJ" (hascard(east, JC), 0, 1), frequency "Card E CT" (hascard(east, TC), 0, 1), frequency "Card E C9" (hascard(east, 9C), 0, 1), frequency "Card E C8" (hascard(east, 8C), 0, 1), frequency "Card E C7" (hascard(east, 7C), 0, 1), frequency "Card E C6" (hascard(east, 6C), 0, 1), frequency "Card E C5" (hascard(east, 5C), 0, 1), frequency "Card E C4" (hascard(east, 4C), 0, 1), frequency "Card E C3" (hascard(east, 3C), 0, 1), frequency "Card E C2" (hascard(east, 2C), 0, 1), frequency "Card S SA" (hascard(south, AS), 0, 1), frequency "Card S SK" (hascard(south, KS), 0, 1), frequency "Card S SQ" (hascard(south, QS), 0, 1), frequency "Card S SJ" (hascard(south, JS), 0, 1), frequency "Card S ST" (hascard(south, TS), 0, 1), frequency "Card S S9" (hascard(south, 9S), 0, 1), frequency "Card S S8" (hascard(south, 8S), 0, 1), frequency "Card S S7" (hascard(south, 7S), 0, 1), frequency "Card S S6" (hascard(south, 6S), 0, 1), frequency "Card S S5" (hascard(south, 5S), 0, 1), frequency "Card S S4" (hascard(south, 4S), 0, 1), frequency "Card S S3" (hascard(south, 3S), 0, 1), frequency "Card S S2" (hascard(south, 2S), 0, 1), frequency "Card S HA" (hascard(south, AH), 0, 1), frequency "Card S HK" (hascard(south, KH), 0, 1), frequency "Card S HQ" (hascard(south, QH), 0, 1), frequency "Card S HJ" (hascard(south, JH), 0, 1), frequency "Card S HT" (hascard(south, TH), 0, 1), frequency "Card S H9" (hascard(south, 9H), 0, 1), frequency "Card S H8" (hascard(south, 8H), 0, 1), frequency "Card S H7" (hascard(south, 7H), 0, 1), frequency "Card S H6" (hascard(south, 6H), 0, 1), frequency "Card S H5" (hascard(south, 5H), 0, 1), frequency "Card S H4" (hascard(south, 4H), 0, 1), frequency "Card S H3" (hascard(south, 3H), 0, 1), frequency "Card S H2" (hascard(south, 2H), 0, 1), frequency "Card S DA" (hascard(south, AD), 0, 1), frequency "Card S DK" (hascard(south, KD), 0, 1), frequency "Card S DQ" (hascard(south, QD), 0, 1), frequency "Card S DJ" (hascard(south, JD), 0, 1), frequency "Card S DT" (hascard(south, TD), 0, 1), frequency "Card S D9" (hascard(south, 9D), 0, 1), frequency "Card S D8" (hascard(south, 8D), 0, 1), frequency "Card S D7" (hascard(south, 7D), 0, 1), frequency "Card S D6" (hascard(south, 6D), 0, 1), frequency "Card S D5" (hascard(south, 5D), 0, 1), frequency "Card S D4" (hascard(south, 4D), 0, 1), frequency "Card S D3" (hascard(south, 3D), 0, 1), frequency "Card S D2" (hascard(south, 2C), 0, 1), frequency "Card S CA" (hascard(south, AC), 0, 1), frequency "Card S CK" (hascard(south, KC), 0, 1), frequency "Card S CQ" (hascard(south, QC), 0, 1), frequency "Card S CJ" (hascard(south, JC), 0, 1), frequency "Card S CT" (hascard(south, TC), 0, 1), frequency "Card S C9" (hascard(south, 9C), 0, 1), frequency "Card S C8" (hascard(south, 8C), 0, 1), frequency "Card S C7" (hascard(south, 7C), 0, 1), frequency "Card S C6" (hascard(south, 6C), 0, 1), frequency "Card S C5" (hascard(south, 5C), 0, 1), frequency "Card S C4" (hascard(south, 4C), 0, 1), frequency "Card S C3" (hascard(south, 3C), 0, 1), frequency "Card S C2" (hascard(south, 2C), 0, 1), frequency "Card W SA" (hascard(west, AS), 0, 1), frequency "Card W SK" (hascard(west, KS), 0, 1), frequency "Card W SQ" (hascard(west, QS), 0, 1), frequency "Card W SJ" (hascard(west, JS), 0, 1), frequency "Card W ST" (hascard(west, TS), 0, 1), frequency "Card W S9" (hascard(west, 9S), 0, 1), frequency "Card W S8" (hascard(west, 8S), 0, 1), frequency "Card W S7" (hascard(west, 7S), 0, 1), frequency "Card W S6" (hascard(west, 6S), 0, 1), frequency "Card W S5" (hascard(west, 5S), 0, 1), frequency "Card W S4" (hascard(west, 4S), 0, 1), frequency "Card W S3" (hascard(west, 3S), 0, 1), frequency "Card W S2" (hascard(west, 2S), 0, 1), frequency "Card W HA" (hascard(west, AH), 0, 1), frequency "Card W HK" (hascard(west, KH), 0, 1), frequency "Card W HQ" (hascard(west, QH), 0, 1), frequency "Card W HJ" (hascard(west, JH), 0, 1), frequency "Card W HT" (hascard(west, TH), 0, 1), frequency "Card W H9" (hascard(west, 9H), 0, 1), frequency "Card W H8" (hascard(west, 8H), 0, 1), frequency "Card W H7" (hascard(west, 7H), 0, 1), frequency "Card W H6" (hascard(west, 6H), 0, 1), frequency "Card W H5" (hascard(west, 5H), 0, 1), frequency "Card W H4" (hascard(west, 4H), 0, 1), frequency "Card W H3" (hascard(west, 3H), 0, 1), frequency "Card W H2" (hascard(west, 2H), 0, 1), frequency "Card W DA" (hascard(west, AD), 0, 1), frequency "Card W DK" (hascard(west, KD), 0, 1), frequency "Card W DQ" (hascard(west, QD), 0, 1), frequency "Card W DJ" (hascard(west, JD), 0, 1), frequency "Card W DT" (hascard(west, TD), 0, 1), frequency "Card W D9" (hascard(west, 9D), 0, 1), frequency "Card W D8" (hascard(west, 8D), 0, 1), frequency "Card W D7" (hascard(west, 7D), 0, 1), frequency "Card W D6" (hascard(west, 6D), 0, 1), frequency "Card W D5" (hascard(west, 5D), 0, 1), frequency "Card W D4" (hascard(west, 4D), 0, 1), frequency "Card W D3" (hascard(west, 3D), 0, 1), frequency "Card W D2" (hascard(west, 2C), 0, 1), frequency "Card W CA" (hascard(west, AC), 0, 1), frequency "Card W CK" (hascard(west, KC), 0, 1), frequency "Card W CQ" (hascard(west, QC), 0, 1), frequency "Card W CJ" (hascard(west, JC), 0, 1), frequency "Card W CT" (hascard(west, TC), 0, 1), frequency "Card W C9" (hascard(west, 9C), 0, 1), frequency "Card W C8" (hascard(west, 8C), 0, 1), frequency "Card W C7" (hascard(west, 7C), 0, 1), frequency "Card W C6" (hascard(west, 6C), 0, 1), frequency "Card W C5" (hascard(west, 5C), 0, 1), frequency "Card W C4" (hascard(west, 4C), 0, 1), frequency "Card W C3" (hascard(west, 3C), 0, 1), frequency "Card W C2" (hascard(west, 2C), 0, 1), dealer/Examples/Descr.weaktwo0100644000076400001440000000106110002574544015403 0ustar henkusers# calculates some statistics of hands deemed to be weak two's # I do not claim this definition of a weak two will satisfy everybody weaktwospades = shape(north, 6xxx - any 0xxx) and hcp(north) >= 5 and hcp(north) <= 11 and hcp(north, spades) >= hcp(north)/2 heartfit = hearts(north) + hearts(south) >= 8 condition weaktwospades generate 1000000 action frequency "points" (hcp(north), 5, 11) , average "hearts" hearts(north) , average "Ace of spades" hascard(north, AS) , average "Jack of spades" hascard(north, JS) , average "Heart fit" heartfit dealer/Examples/Descr.you_hold0100644000076400001440000000141710002574544015551 0ustar henkusers# # This is the "you hold ..." problem from the manual. # generate 20000 produce 25 vulnerable ew dealer west predeal south SAQ542, HKJ87, D32, CAK # # Exclude other opening bids by west (1D/H/S/NT) # west1n = shape(west, any 4333 + any 4432 + any 5332 - 5xxx - x5xx) && hcp(west)>14 && hcp(west)<18 west1h = hearts(west)>= 5 west1s = spades(west)>= 5 west1d = diamonds(west)>clubs(west) || ((diamonds(west)==clubs(west))==4) west1c = hcp(west)>10 && clubs(west)>=3 && (not west1n) && (not west1h) && (not west1s) && (not west1d) # # 2D overcall from north # north2d = (hcp(north)>5 && hcp(north)<12) && shape(north, xx6x + xx7x - any 4xxx - any 5xxx) # # West bids 1C, north overcalls 2D # condition west1c && north2d # action printall dealer/Examples/Refer.stayman0100644000076400001440000000015010056343415015377 0ustar henkusersfit: 0.549587 Generated 1000000 hands Produced 242 hands Initial random seed 1 Time needed 1.965 sec dealer/Examples/Refer.yarb0100644000076400001440000000205010056343621014660 0ustar henkusers North hands: 1. 2. 3. 4. 6 5 2 7 6 3 2 7 6 5 3 8 4 3 2 9 7 9 6 5 4 2 6 5 3 2 5 3 8 7 4 2 7 4 7 6 2 9 6 5 3 2 8 7 6 4 6 5 7 4 4 2 5. 6. 7. 8. 9 7 6 3 9 8 7 3 2 7 3 6 2 6 5 8 7 6 4 3 9 6 4 3 2 7 3 8 5 5 2 9 7 4 3 6 5 9 8 6 4 3 5 3 2 8 7 6 5 4 3 2 9. 10. 8 6 5 4 3 8 2 2 8 7 9 7 6 4 8 6 5 4 3 2 7 4 2 8 4 2 Frequency : 0 10 1 0 2 0 3 0 4 0 5 0 Generated 16655 hands Produced 10 hands Initial random seed 1 Time needed 0.022 sec dealer/Examples/Descr.yarb0100644000076400001440000000042210002574544014657 0ustar henkusers# # Generate some truly lousy hands. # # Redefine the pointcount table and assign 1 point to the 5 honnors # # A K Q J T 9 8 7 6 5 4 3 2 pointcount 1 1 1 1 1 0 0 0 0 0 0 0 0 produce 10 condition hcp(north)==0 action print (north), frequency (hcp(north), 0, 5) dealer/Examples/Refer.6c0100644000076400001440000000020410056343363014235 0ustar henkusersking drops: 0.573465 finesse: 0.749792 Generated 1000000 hands Produced 110556 hands Initial random seed 1 Time needed 1.600 sec dealer/Examples/Test.distribution0100644000076400001440000003336310002574544016332 0ustar henkusers# # This an input file to test dealer. It generates a million hands without # any constraints, then prints the frequency of the various suit lengths # and hcp holdings. The output can be piped into a perl-script to compare # it against the theoretical holdings. It should give a quick check if # the deals you are producing are sort-of random. # generate 1000000 action frequency "HCP N" (hcp(north), 0, 37), frequency "HCP E" (hcp(east), 0, 37), frequency "HCP S" (hcp(south), 0, 37), frequency "HCP W" (hcp(west), 0, 37), frequency "Spades N" (spades(north), 0, 13), frequency "Spades E" (spades(east), 0, 13), frequency "Spades S" (spades(south), 0, 13), frequency "Spades W" (spades(west), 0, 13), frequency "Hearts N" (hearts(north), 0, 13), frequency "Hearts E" (hearts(east), 0, 13), frequency "Hearts S" (hearts(south), 0, 13), frequency "Hearts W" (hearts(west), 0, 13), frequency "Diamonds N" (diamonds(north), 0, 13), frequency "Diamonds E" (diamonds(east), 0, 13), frequency "Diamonds S" (diamonds(south), 0, 13), frequency "Diamonds W" (diamonds(west), 0, 13), frequency "Clubs N" (clubs(north), 0, 13), frequency "Clubs E" (clubs(east), 0, 13), frequency "Clubs S" (clubs(south), 0, 13), frequency "Clubs W" (clubs(west), 0, 13), frequency "Card N SA" (hascard(north, AS), 0, 1), frequency "Card N SK" (hascard(north, KS), 0, 1), frequency "Card N SQ" (hascard(north, QS), 0, 1), frequency "Card N SJ" (hascard(north, JS), 0, 1), frequency "Card N ST" (hascard(north, TS), 0, 1), frequency "Card N S9" (hascard(north, 9S), 0, 1), frequency "Card N S8" (hascard(north, 8S), 0, 1), frequency "Card N S7" (hascard(north, 7S), 0, 1), frequency "Card N S6" (hascard(north, 6S), 0, 1), frequency "Card N S5" (hascard(north, 5S), 0, 1), frequency "Card N S4" (hascard(north, 4S), 0, 1), frequency "Card N S3" (hascard(north, 3S), 0, 1), frequency "Card N S2" (hascard(north, 2S), 0, 1), frequency "Card N HA" (hascard(north, AH), 0, 1), frequency "Card N HK" (hascard(north, KH), 0, 1), frequency "Card N HQ" (hascard(north, QH), 0, 1), frequency "Card N HJ" (hascard(north, JH), 0, 1), frequency "Card N HT" (hascard(north, TH), 0, 1), frequency "Card N H9" (hascard(north, 9H), 0, 1), frequency "Card N H8" (hascard(north, 8H), 0, 1), frequency "Card N H7" (hascard(north, 7H), 0, 1), frequency "Card N H6" (hascard(north, 6H), 0, 1), frequency "Card N H5" (hascard(north, 5H), 0, 1), frequency "Card N H4" (hascard(north, 4H), 0, 1), frequency "Card N H3" (hascard(north, 3H), 0, 1), frequency "Card N H2" (hascard(north, 2H), 0, 1), frequency "Card N DA" (hascard(north, AD), 0, 1), frequency "Card N DK" (hascard(north, KD), 0, 1), frequency "Card N DQ" (hascard(north, QD), 0, 1), frequency "Card N DJ" (hascard(north, JD), 0, 1), frequency "Card N DT" (hascard(north, TD), 0, 1), frequency "Card N D9" (hascard(north, 9D), 0, 1), frequency "Card N D8" (hascard(north, 8D), 0, 1), frequency "Card N D7" (hascard(north, 7D), 0, 1), frequency "Card N D6" (hascard(north, 6D), 0, 1), frequency "Card N D5" (hascard(north, 5D), 0, 1), frequency "Card N D4" (hascard(north, 4D), 0, 1), frequency "Card N D3" (hascard(north, 3D), 0, 1), frequency "Card N D2" (hascard(north, 2C), 0, 1), frequency "Card N CA" (hascard(north, AC), 0, 1), frequency "Card N CK" (hascard(north, KC), 0, 1), frequency "Card N CQ" (hascard(north, QC), 0, 1), frequency "Card N CJ" (hascard(north, JC), 0, 1), frequency "Card N CT" (hascard(north, TC), 0, 1), frequency "Card N C9" (hascard(north, 9C), 0, 1), frequency "Card N C8" (hascard(north, 8C), 0, 1), frequency "Card N C7" (hascard(north, 7C), 0, 1), frequency "Card N C6" (hascard(north, 6C), 0, 1), frequency "Card N C5" (hascard(north, 5C), 0, 1), frequency "Card N C4" (hascard(north, 4C), 0, 1), frequency "Card N C3" (hascard(north, 3C), 0, 1), frequency "Card N C2" (hascard(north, 2C), 0, 1), frequency "Card E SA" (hascard(east, AS), 0, 1), frequency "Card E SK" (hascard(east, KS), 0, 1), frequency "Card E SQ" (hascard(east, QS), 0, 1), frequency "Card E SJ" (hascard(east, JS), 0, 1), frequency "Card E ST" (hascard(east, TS), 0, 1), frequency "Card E S9" (hascard(east, 9S), 0, 1), frequency "Card E S8" (hascard(east, 8S), 0, 1), frequency "Card E S7" (hascard(east, 7S), 0, 1), frequency "Card E S6" (hascard(east, 6S), 0, 1), frequency "Card E S5" (hascard(east, 5S), 0, 1), frequency "Card E S4" (hascard(east, 4S), 0, 1), frequency "Card E S3" (hascard(east, 3S), 0, 1), frequency "Card E S2" (hascard(east, 2S), 0, 1), frequency "Card E HA" (hascard(east, AH), 0, 1), frequency "Card E HK" (hascard(east, KH), 0, 1), frequency "Card E HQ" (hascard(east, QH), 0, 1), frequency "Card E HJ" (hascard(east, JH), 0, 1), frequency "Card E HT" (hascard(east, TH), 0, 1), frequency "Card E H9" (hascard(east, 9H), 0, 1), frequency "Card E H8" (hascard(east, 8H), 0, 1), frequency "Card E H7" (hascard(east, 7H), 0, 1), frequency "Card E H6" (hascard(east, 6H), 0, 1), frequency "Card E H5" (hascard(east, 5H), 0, 1), frequency "Card E H4" (hascard(east, 4H), 0, 1), frequency "Card E H3" (hascard(east, 3H), 0, 1), frequency "Card E H2" (hascard(east, 2H), 0, 1), frequency "Card E DA" (hascard(east, AD), 0, 1), frequency "Card E DK" (hascard(east, KD), 0, 1), frequency "Card E DQ" (hascard(east, QD), 0, 1), frequency "Card E DJ" (hascard(east, JD), 0, 1), frequency "Card E DT" (hascard(east, TD), 0, 1), frequency "Card E D9" (hascard(east, 9D), 0, 1), frequency "Card E D8" (hascard(east, 8D), 0, 1), frequency "Card E D7" (hascard(east, 7D), 0, 1), frequency "Card E D6" (hascard(east, 6D), 0, 1), frequency "Card E D5" (hascard(east, 5D), 0, 1), frequency "Card E D4" (hascard(east, 4D), 0, 1), frequency "Card E D3" (hascard(east, 3D), 0, 1), frequency "Card E D2" (hascard(east, 2C), 0, 1), frequency "Card E CA" (hascard(east, AC), 0, 1), frequency "Card E CK" (hascard(east, KC), 0, 1), frequency "Card E CQ" (hascard(east, QC), 0, 1), frequency "Card E CJ" (hascard(east, JC), 0, 1), frequency "Card E CT" (hascard(east, TC), 0, 1), frequency "Card E C9" (hascard(east, 9C), 0, 1), frequency "Card E C8" (hascard(east, 8C), 0, 1), frequency "Card E C7" (hascard(east, 7C), 0, 1), frequency "Card E C6" (hascard(east, 6C), 0, 1), frequency "Card E C5" (hascard(east, 5C), 0, 1), frequency "Card E C4" (hascard(east, 4C), 0, 1), frequency "Card E C3" (hascard(east, 3C), 0, 1), frequency "Card E C2" (hascard(east, 2C), 0, 1), frequency "Card S SA" (hascard(south, AS), 0, 1), frequency "Card S SK" (hascard(south, KS), 0, 1), frequency "Card S SQ" (hascard(south, QS), 0, 1), frequency "Card S SJ" (hascard(south, JS), 0, 1), frequency "Card S ST" (hascard(south, TS), 0, 1), frequency "Card S S9" (hascard(south, 9S), 0, 1), frequency "Card S S8" (hascard(south, 8S), 0, 1), frequency "Card S S7" (hascard(south, 7S), 0, 1), frequency "Card S S6" (hascard(south, 6S), 0, 1), frequency "Card S S5" (hascard(south, 5S), 0, 1), frequency "Card S S4" (hascard(south, 4S), 0, 1), frequency "Card S S3" (hascard(south, 3S), 0, 1), frequency "Card S S2" (hascard(south, 2S), 0, 1), frequency "Card S HA" (hascard(south, AH), 0, 1), frequency "Card S HK" (hascard(south, KH), 0, 1), frequency "Card S HQ" (hascard(south, QH), 0, 1), frequency "Card S HJ" (hascard(south, JH), 0, 1), frequency "Card S HT" (hascard(south, TH), 0, 1), frequency "Card S H9" (hascard(south, 9H), 0, 1), frequency "Card S H8" (hascard(south, 8H), 0, 1), frequency "Card S H7" (hascard(south, 7H), 0, 1), frequency "Card S H6" (hascard(south, 6H), 0, 1), frequency "Card S H5" (hascard(south, 5H), 0, 1), frequency "Card S H4" (hascard(south, 4H), 0, 1), frequency "Card S H3" (hascard(south, 3H), 0, 1), frequency "Card S H2" (hascard(south, 2H), 0, 1), frequency "Card S DA" (hascard(south, AD), 0, 1), frequency "Card S DK" (hascard(south, KD), 0, 1), frequency "Card S DQ" (hascard(south, QD), 0, 1), frequency "Card S DJ" (hascard(south, JD), 0, 1), frequency "Card S DT" (hascard(south, TD), 0, 1), frequency "Card S D9" (hascard(south, 9D), 0, 1), frequency "Card S D8" (hascard(south, 8D), 0, 1), frequency "Card S D7" (hascard(south, 7D), 0, 1), frequency "Card S D6" (hascard(south, 6D), 0, 1), frequency "Card S D5" (hascard(south, 5D), 0, 1), frequency "Card S D4" (hascard(south, 4D), 0, 1), frequency "Card S D3" (hascard(south, 3D), 0, 1), frequency "Card S D2" (hascard(south, 2C), 0, 1), frequency "Card S CA" (hascard(south, AC), 0, 1), frequency "Card S CK" (hascard(south, KC), 0, 1), frequency "Card S CQ" (hascard(south, QC), 0, 1), frequency "Card S CJ" (hascard(south, JC), 0, 1), frequency "Card S CT" (hascard(south, TC), 0, 1), frequency "Card S C9" (hascard(south, 9C), 0, 1), frequency "Card S C8" (hascard(south, 8C), 0, 1), frequency "Card S C7" (hascard(south, 7C), 0, 1), frequency "Card S C6" (hascard(south, 6C), 0, 1), frequency "Card S C5" (hascard(south, 5C), 0, 1), frequency "Card S C4" (hascard(south, 4C), 0, 1), frequency "Card S C3" (hascard(south, 3C), 0, 1), frequency "Card S C2" (hascard(south, 2C), 0, 1), frequency "Card W SA" (hascard(west, AS), 0, 1), frequency "Card W SK" (hascard(west, KS), 0, 1), frequency "Card W SQ" (hascard(west, QS), 0, 1), frequency "Card W SJ" (hascard(west, JS), 0, 1), frequency "Card W ST" (hascard(west, TS), 0, 1), frequency "Card W S9" (hascard(west, 9S), 0, 1), frequency "Card W S8" (hascard(west, 8S), 0, 1), frequency "Card W S7" (hascard(west, 7S), 0, 1), frequency "Card W S6" (hascard(west, 6S), 0, 1), frequency "Card W S5" (hascard(west, 5S), 0, 1), frequency "Card W S4" (hascard(west, 4S), 0, 1), frequency "Card W S3" (hascard(west, 3S), 0, 1), frequency "Card W S2" (hascard(west, 2S), 0, 1), frequency "Card W HA" (hascard(west, AH), 0, 1), frequency "Card W HK" (hascard(west, KH), 0, 1), frequency "Card W HQ" (hascard(west, QH), 0, 1), frequency "Card W HJ" (hascard(west, JH), 0, 1), frequency "Card W HT" (hascard(west, TH), 0, 1), frequency "Card W H9" (hascard(west, 9H), 0, 1), frequency "Card W H8" (hascard(west, 8H), 0, 1), frequency "Card W H7" (hascard(west, 7H), 0, 1), frequency "Card W H6" (hascard(west, 6H), 0, 1), frequency "Card W H5" (hascard(west, 5H), 0, 1), frequency "Card W H4" (hascard(west, 4H), 0, 1), frequency "Card W H3" (hascard(west, 3H), 0, 1), frequency "Card W H2" (hascard(west, 2H), 0, 1), frequency "Card W DA" (hascard(west, AD), 0, 1), frequency "Card W DK" (hascard(west, KD), 0, 1), frequency "Card W DQ" (hascard(west, QD), 0, 1), frequency "Card W DJ" (hascard(west, JD), 0, 1), frequency "Card W DT" (hascard(west, TD), 0, 1), frequency "Card W D9" (hascard(west, 9D), 0, 1), frequency "Card W D8" (hascard(west, 8D), 0, 1), frequency "Card W D7" (hascard(west, 7D), 0, 1), frequency "Card W D6" (hascard(west, 6D), 0, 1), frequency "Card W D5" (hascard(west, 5D), 0, 1), frequency "Card W D4" (hascard(west, 4D), 0, 1), frequency "Card W D3" (hascard(west, 3D), 0, 1), frequency "Card W D2" (hascard(west, 2C), 0, 1), frequency "Card W CA" (hascard(west, AC), 0, 1), frequency "Card W CK" (hascard(west, KC), 0, 1), frequency "Card W CQ" (hascard(west, QC), 0, 1), frequency "Card W CJ" (hascard(west, JC), 0, 1), frequency "Card W CT" (hascard(west, TC), 0, 1), frequency "Card W C9" (hascard(west, 9C), 0, 1), frequency "Card W C8" (hascard(west, 8C), 0, 1), frequency "Card W C7" (hascard(west, 7C), 0, 1), frequency "Card W C6" (hascard(west, 6C), 0, 1), frequency "Card W C5" (hascard(west, 5C), 0, 1), frequency "Card W C4" (hascard(west, 4C), 0, 1), frequency "Card W C3" (hascard(west, 3C), 0, 1), frequency "Card W C2" (hascard(west, 2C), 0, 1), dealer/Examples/convert.pl0100755000076400001440000000737210002574544014773 0ustar henkusers#!/usr/bin/perl # This script reformats the output of Descr.test_dealer into a nice # table, with the theoretical values next to the hcp and suit distributions # for the 4 players # This is not the best piece of Perl that I've ever written. # # Frequency of suit lengths and hcp help by players. From Frederic H. Frost, # "Bridge Odds Complete". # @suitlen = (1.27, 8.01, 20.59, 28.63, 23.87, 12.47, 4.16, 0.88, 0.12, 0.01, 0,0,0); @rawhcp = (0.36, 0.79, 1.35, 2.46, 3.85, 5.19, 6.55, 8.03, 8.89, 9.36, 9.41, 8.94, 8.03, 6.91, 5.69, 4.42, 3.31, 2.36, 1.61, 1.04, 0.64, 0.38, 0.21, 0.11, 0.06, 0.03, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $player_to_int{"N"} = 0; $player_to_int{"E"} = 1; $player_to_int{"S"} = 2; $player_to_int{"W"} = 3; $suit_to_int{"Spades"} = 0; $suit_to_int{"Hearts"} = 1; $suit_to_int{"Diamonds"} = 2; $suit_to_int{"Clubs"} = 3; $suit_to_int{"S"} = 0; $suit_to_int{"H"} = 1; $suit_to_int{"D"} = 2; $suit_to_int{"C"} = 3; $rank_to_int{"T"} = 10; $rank_to_int{"J"} = 11; $rank_to_int{"Q"} = 12; $rank_to_int{"K"} = 13; $rank_to_int{"A"} = 14; while () { chop; chop; if ($_ =~ "HCP") { ($dummy, $dummy, $player) = split (/\s+/, $_); $player = $player_to_int{$player}; for ($i=0; $i<38; $i++) { $_ = ; ($dummy, $dummy, $freq) = (split /\s+/, $_); $hcp[$i][$player] = $freq; } } elsif ($_ =~ "Frequency Card") { ($dummy, $dumy, $player, $card) = (split /\s+/, $_); $player = $player_to_int{$player}; $suit = $suit_to_int {substr($card, 0, 1)}; $rank = substr($card, 1, 1); if (defined $rank_to_int{$rank}) { $rank = $rank_to_int{$rank}; } $_ = ; $_ = ; ($dummy, $dummy, $count) = split (/\s+/, $_); $hascard[$player][$suit][$rank] = $count; } elsif ($_ =~ "Frequency") { ($dummy, $suit, $player) = split (/\s+/, $_); $player = $player_to_int{$player}; $suit = $suit_to_int{$suit}; for ($i=0 ; $i<13; $i++) { $_ = ; ($dummy, $dummy, $freq) = split (/\s+/, $_); $suit[$i][$player][$suit] = $freq; } } elsif ($_ =~ "Generated") { ($dummy, $constant, $dummy) = split (/\s+/, $_); } } print "Generated $constant hands\n\n"; $constant /= 100; print "HCP Distribution\n================\n"; print " # N E S W\n"; print " % diff % diff % diff % diff\n"; for ($i=0 ; $i<38 ; $i++) { printf ("%2d ", $i); for ($j=0 ; $j<4; $j++) { printf ("%5.2f ", $hcp[$i][$j]/$constant); printf ("%6.3f ", $hcp[$i][$j]/$constant- $rawhcp[$i]); } printf ("%5.2f", $rawhcp[$i]); print "\n"; } foreach $k ("Spades", "Hearts", "Diamonds", "Clubs") { print "\n$k Distribution\n=====================\n"; print " # N E S W\n"; print " % diff % diff % diff % diff\n"; $k1 = $suit_to_int{$k}; for ($i=0 ; $i<14 ; $i++) { printf ("%2d ", $i); for ($j=0 ; $j<4; $j++) { printf ("%5.2f ", $suit[$i][$j][$k1]/$constant); printf ("%6.3f ", $suit[$i][$j][$k1]/$constant-$suitlen[$i]); } printf ("%5.2f", $suitlen[$i]); print "\n"; } } print "\nIndividual Cards\n================\n"; print " Spades Hearts Diamonds Clubs\n"; print "# N E S W N E S W N E S W N E S W\n"; for ($rank = 2 ; $rank < 15 ; $rank++) { printf ("%s ", substr("23456789TJQKA", $rank-2, 1)); for ($suit = 0 ; $suit < 4; $suit++) { for ($player = 0 ; $player < 4 ; $player++) { printf ("%5.2f ", $hascard [$player][$suit][$rank]/$constant-25.00); } } print "\n"; } dealer/Examples/Refer.notrump0100644000076400001440000006151710056343413015443 0ustar henkusersn 982.KQ2.KT73.982 e Q3.AT7.AQ65.AJT4 s AT64.98643.94.K6 w KJ75.J5.J82.Q753 n 92.5.QT852.JT943 e T63.AK3.AJ.A8652 s KJ54.JT9872.73.K w AQ87.Q64.K964.Q7 n T32.QJT643.T3.53 e A65.75.AK4.AT974 s KQ9.A82.Q65.KJ62 w J874.K9.J9872.Q8 n 3.JT542.Q.AT7642 e K2.KQ6.AK963.J83 s QT987.A98.J52.K9 w AJ654.73.T874.Q5 n 6532.K9.986.Q986 e AQT9.AJ83.A3.T75 s J84.Q75.KQJ52.A4 w K7.T642.T74.KJ32 n 6532.KQ87.J932.2 e KQJ.6432.AQ6.A93 s AT874.5.KT8.K874 w 9.AJT9.754.QJT65 n 7654.86.7653.JT7 e AQJ.AJ74.KT4.852 s KT32.Q9532.J.K64 w 98.KT.AQ982.AQ93 n A632.97.J742.AK6 e Q985.AQJ6.AQ.T94 s JT.T854.T9653.QJ w K74.K32.K8.87532 n KJ6.K3.T975.AT76 e AQ.T72.AQ43.K854 s 9832.A98654.K6.3 w T754.QJ.J82.QJ92 n KQT.QT83.J73.JT5 e J3.AK92.K54.A974 s A72.J74.QT92.Q82 w 98654.65.A86.K63 n 98.QJ865.9732.Q5 e KJ53.A7.AQT4.KT3 s AQT42.K9432..J62 w 76.T.KJ865.A9874 n JT73.KT974.98.97 e K9.AQ83.J74.AJ85 s 6.J52.QT653.K643 w AQ8542.6.AK2.QT2 n QT942.764.KT.T96 e K863.J3.A82.AK87 s 7.Q982.J753.QJ43 w AJ5.AKT5.Q964.52 n QJ82.JT86.853.T9 e KT3.AQ72.Q6.KQ83 s 94.K543.974.J642 w A765.9.AKJT2.A75 n A754.92.J762.QT3 e KJT3.K4.A985.A74 s 986.QJT863.QT3.2 w Q2.A75.K4.KJ9865 n QT52.75.Q986.T97 e A8.T83.AK53.KJ84 s K7.KQ94.JT42.A53 w J9643.AJ62.7.Q62 n AT43.K7.KT76.T62 e KQ7.AT92.A3.A985 s 962.QJ8.984.QJ74 w J85.6543.QJ52.K3 n 4.QT875.J8.J9764 e AQ86.KJ6.AK65.T3 s J732.932.T742.KQ w KT95.A4.Q93.A852 n 95.KQ9.J876.AKT5 e AJ.AT52.AK4.J643 s 742.J87643.QT53. w KQT863..92.Q9872 n QT743.T42.J8.A94 e AK6.AQ.K95.T8632 s 9.853.QT7643.KQJ w J852.KJ976.A2.75 n 743.JT62.94.A863 e K9.K94.AKJT3.J75 s Q.AQ53.Q52.KT942 w AJT8652.87.876.Q n A74.J98.Q8653.A3 e T8.AQ43.AKT4.Q82 s KJ9653.72.J.T654 w Q2.KT65.972.KJ97 n 532.64.J9843.T97 e A974.AT3.K75.AJ3 s KJ86.9875.AQ62.4 w QT.KQJ2.T.KQ8652 n QT75.T3.T9543.Q6 e AJ83.AK7.Q82.J42 s K962.86.J7.T9875 w 4.QJ9542.AK6.AK3 n T4.AK.AJ86532.A7 e KJ62.QJ2.KQ9.KT5 s 975.97543..Q9432 w AQ83.T86.T74.J86 n J.AK76.K843.KT43 e KQ98.T82.AQ6.A86 s T6432.Q3.975.J92 w A75.J954.JT2.Q75 n KQ2.J7.AQ876.874 e J85.K95.KJ9.AQJ9 s AT.T864.543.T632 w 97643.AQ32.T2.K5 n T9.AKQJ3.763.872 e AQ3.T5.AK94.KT95 s K6542.8642.T5.A4 w J87.97.QJ82.QJ63 n 9.J64.JT94.KQJ87 e KT4.K973.AK72.A9 s J873.T85.65.5432 w AQ652.AQ2.Q83.T6 n Q965.JT6532.K5.T e AKJ4.K94.QT6.K82 s 72.Q7.982.QJ9753 w T83.A8.AJ743.A64 n J4.AQ875.T7.Q864 e Q963.J6.AKQ9.K72 s K875.2.J65432.AJ w AT2.KT943.8.T953 n KT5.K9432..K9732 e AJ6.AQ8.KQ932.86 s 98732.T6.AJT6.Q4 w Q4.J75.8754.AJT5 n J43.A9632..KT842 e A75.87.KQT2.AQ65 s KQ96.JT5.A8654.3 w T82.KQ4.J973.J97 n 876.Q832.AQ.7642 e QT53.K5.JT2.AKQ9 s AJ2.A764.8753.53 w K94.JT9.K964.JT8 n 3.Q95.K963.98764 e K96.A874.Q82.AQ3 s 742.KJ2.AT7.KJT5 w AQJT85.T63.J54.2 n Q5.9764.A86.QT75 e AK32.KQ5.JT.KJ63 s J.JT32.97532.A98 w T98764.A8.KQ4.42 n A76.T.KJ952.J953 e K985.J5.A73.AKT6 s T43.KQ73.86.Q742 w QJ2.A98642.QT4.8 n Q75.94.AK653.964 e KJ93.KQ.JT7.AJT8 s A84.J832.Q942.32 w T62.AT765.8.KQ75 n KJT7.K63.QT7.AT9 e A4.A52.K85.KQ876 s 986532.94.A432.4 w Q.QJT87.J96.J532 n J72.Q972.AT.QT87 e QT9.KT.KQ853.AJ2 s 854.A643.642.K65 w AK63.J85.J97.943 n K652.K65.K93.KT4 e QJ7.AQ7.Q742.A87 s 43.32.AT865.J962 w AT98.JT984.J.Q53 n T98.J5.A94.K7432 e KJ73.82.KJT.AQJT s Q642.KQT743.Q6.6 w A5.A96.87532.985 n 65.J876.A2.QJ987 e Q932.AK2.QJ54.A5 s AT8.Q.9863.KT642 w KJ74.T9543.KT7.3 n AKJT8.Q98.864.64 e Q642.AKT.K7.AT98 s 3.7542.J53.KQJ73 w 975.J63.AQT92.52 n JT752.42.K2.A532 e AKQ9.965.AQ.T984 s 643.AJ873.J83.Q7 w 8.KQT.T97654.KJ6 n 62.J3.K8732.QT83 e A873.Q8.AQT9.A92 s KQT954.T7642..74 w J.AK95.J654.KJ65 n 5.QT.KJ9542.QT97 e Q83.AK9.QT86.AJ4 s KJ642.J862.A.832 w AT97.7543.73.K65 n 654.K64.AK98.543 e AK7.AQ75.J763.QJ s JT92.T98.QT2.K98 w Q83.J32.54.AT762 n T985.KT.9754.T76 e K63.QJ97.QJT.AQ3 s J4.8643.632.K982 w AQ72.A52.AK8.J54 n 97.AJ.JT7.AT7532 e KJT.Q95.AKQ8.Q94 s Q852.K8763.43.J8 w A643.T42.9652.K6 n J9863.J.732.K874 e AKQ.T873.K5.AJ65 s 742.96542.A98.92 w T5.AKQ.QJT64.QT3 n Q754.97.T864.J65 e J82.AKT4.A95.A72 s KT96.J653.Q3.T43 w A3.Q82.KJ72.KQ98 n QJ85.AQ6532.Q7.5 e 42.KT8.A92.AKQJ4 s KT7..JT8543.T962 w A963.J974.K6.873 n Q932.T653.2.KJ96 e A65.AJ42.AKJ7.84 s JT74.K97.983.AQ5 w K8.Q8.QT654.T732 n K32.Q96.9864.JT7 e AT8.AK4.AQ53.542 s J64.J7532..AK986 w Q975.T8.KJT72.Q3 n QJ8.432.AQ932.T3 e A5.AKJ7.J84.A982 s 97643.986.K7.QJ7 w KT2.QT5.T65.K654 n 952.AJ92.J43.QJ9 e AQ64.Q85.97.AK87 s T87.K4.AQ62.T653 w KJ3.T763.KT85.42 n .94.Q96532.T8742 e AQ76.A653.K87.Q5 s J853.KQT..AKJ963 w KT942.J872.AJT4. n KQ83.QJ75.T986.9 e JT9.T2.AK7.AKJ76 s 62.AK98643.3.T53 w A754..QJ542.Q842 n 7.J72.JT87.KQ653 e K632.AQ3.K53.A97 s AJT98.T854.A2.J8 w Q54.K96.Q964.T42 n Q82.KT94.K98.J53 e K7.QJ5.AQ752.K62 s A543.72.JT6.AT97 w JT96.A863.43.Q84 n 53.K75.KQT963.76 e AK.AQ82.J84.QT53 s QJT9642.JT.7.A94 w 87.9643.A52.KJ82 n JT.93.AQJ2.JT962 e Q843.KQ.T75.AKQ4 s K762.J875.K93.85 w A95.AT642.864.73 n Q974.9864.Q9.Q96 e 62.KQ73.AKJ6.A82 s 3.AJ2.432.KT7543 w AKJT85.T5.T875.J n Q93.J93.53.KT953 e JT.AQT4.A762.AJ7 s K754.875.JT84.86 w A862.K62.KQ9.Q42 n J6.JT83.T543.AT6 e A7.A64.AK96.J742 s KQT954.92.Q2.Q53 w 832.KQ75.J87.K98 n KJ2.9873.QJ8.A63 e AT9.AJ5.43.KQJ52 s 763.KT4.KT762.74 w Q854.Q62.A95.T98 n J9876.A.AT98.T73 e K32.QJ62.QJ4.AQ4 s .K983.753.KJ9652 w AQT54.T754.K62.8 n AQJT73.A4.J8.853 e K5.KQT.Q9743.KQJ s 98642.J.52.AT642 w .9876532.AKT6.97 n K87.Q7.QJT4.8642 e 9652.A85.A62.AKJ s AJT.J9642.5.QT73 w Q43.KT3.K9873.95 n QJ962.T532.3.532 e AK.J84.KQT85.Q86 s T875.AQ.A42.KJ94 w 43.K976.J976.AT7 n A42.T72.AJ43.KT7 e K53.A84.K98.AQ86 s QJ987.Q653.T75.9 w T6.KJ9.Q62.J5432 n AQJ93.Q62.K9.874 e K7.AJ53.A432.AT3 s T652.T9874.T.KJ2 w 84.K.QJ8765.Q965 n J6.KT5.KQT83.J87 e 97.AJ8.J764.AKQ4 s 53.Q9763.A5.T962 w AKQT842.42.92.53 n QJ87.432.A7.J762 e 43.KQ7.KQ94.KQT9 s 6.AJT986.T865.A5 w AKT952.5.J32.843 n K953.K.KT76.K862 e A2.J876.AQ42.AQ9 s T76.Q95432.J3.J3 w QJ84.AT.985.T754 n K8.K64.4.AJT7653 e Q6.AJ5.A865.KQ92 s 97542.872.KJ72.8 w AJT3.QT93.QT93.4 n J7.JT74.K82.KQ96 e QT8.A32.AQJ7.A74 s 9654.KQ95.T.J852 w AK32.86.96543.T3 n 964.9842.Q95.A83 e KT8.KQT.AK4.T964 s AQJ732.A765.J2.5 w 5.J3.T8763.KQJ72 n A84.JT94.K542.65 e T76.A2.AQT7.AQ83 s Q5.KQ876.963.J94 w KJ932.53.J8.KT72 n 763.973.7532.QJ5 e KJ.AJT2.AK84.T76 s Q82.854.QJT96.AK w AT954.KQ6..98432 n AJ74.J763.AQ2.75 e KQ.AKQ2.J73.Q862 s T962.9854.94.A94 w 853.T.KT865.KJT3 n A5.9853.JT72.T93 e 83.AKQ7.Q93.AQ87 s JT97.T62.A.KJ654 w KQ642.J4.K8654.2 n JT7.JT92.KJ.Q862 e K83.A3.AT852.KJT s Q962.Q87.Q43.A43 w A54.K654.976.975 n 8532.Q4.T7543.85 e KQJ.K82.A9.AT764 s A9.965.K62.KQJ93 w T764.AJT73.QJ8.2 n Q82.Q9852.862.Q3 e KT97.A3.AQ53.A65 s 3.KJ74.K9.KT8742 w AJ654.T6.JT74.J9 n Q3.72.Q432.AKT98 e AK52.T3.AJ95.QJ4 s T87.AK864.6.7532 w J964.QJ95.KT87.6 n 652.752.62.J8743 e J87.K86.AK954.A9 s Q.AQJ9.T873.Q652 w AKT943.T43.QJ.KT n K976.J984.T42.Q4 e Q52.Q75.AK96.A62 s AT843.AK3.87.JT9 w J.T62.QJ53.K8753 n K42.J972.Q3.JT76 e 876.AQ8.AJ96.KQ3 s T5.KT643.T4.9854 w AQJ93.5.K8752.A2 n JT5.952.KJ.QJT98 e 873.AK86.AT5.A32 s K942.JT.98742.64 w AQ6.Q743.Q63.K75 n AKT9874.7.74.T73 e 32.AK5.KJ93.AJ52 s Q5.6432.AQT85.Q4 w J6.QJT98.62.K986 n A43.T982.85.A732 e T9.AQJ5.AK7.J654 s 876.63.QT9632.Q8 w KQJ52.K74.J4.KT9 n QT94.862.876.Q42 e K53.K7.KJ932.AJ8 s AJ862.A93.Q5.KT5 w 7.QJT54.AT4.9763 n 76.Q832.K42.KT63 e KQ83.AJ.AQ96.752 s 52.KT97.T75.A984 w AJT94.654.J83.QJ n 64.Q83.AT9.T7642 e A72.A94.KQ532.K8 s Q853.KJT75.87.A5 w KJT9.62.J64.QJ93 n T9873.52.Q75.K87 e AQ.KJ83.963.AQ54 s KJ654.AQ4.84.J32 w 2.T976.AKJT2.T96 n K85.QJT6.T73.KJ4 e 642.A42.AQ5.AQ65 s AQ93.85.J942.T32 w JT7.K973.K86.987 n J863.T84.QT3.T93 e A72.J75.A94.KQJ8 s 94.AQ2.KJ82.A764 w KQT5.K963.765.52 n QT852.J7.J4.AT86 e AK64.A95.A762.74 s J93.Q32.T953.J92 w 7.KT864.KQ8.KQ53 East hands: 1. 2. 3. 4. Q 3 T 6 3 A 6 5 K 2 A T 7 A K 3 7 5 K Q 6 A Q 6 5 A J A K 4 A K 9 6 3 A J T 4 A 8 6 5 2 A T 9 7 4 J 8 3 5. 6. 7. 8. A Q T 9 K Q J A Q J Q 9 8 5 A J 8 3 6 4 3 2 A J 7 4 A Q J 6 A 3 A Q 6 K T 4 A Q T 7 5 A 9 3 8 5 2 T 9 4 9. 10. 11. 12. A Q J 3 K J 5 3 K 9 T 7 2 A K 9 2 A 7 A Q 8 3 A Q 4 3 K 5 4 A Q T 4 J 7 4 K 8 5 4 A 9 7 4 K T 3 A J 8 5 13. 14. 15. 16. K 8 6 3 K T 3 K J T 3 A 8 J 3 A Q 7 2 K 4 T 8 3 A 8 2 Q 6 A 9 8 5 A K 5 3 A K 8 7 K Q 8 3 A 7 4 K J 8 4 17. 18. 19. 20. K Q 7 A Q 8 6 A J A K 6 A T 9 2 K J 6 A T 5 2 A Q A 3 A K 6 5 A K 4 K 9 5 A 9 8 5 T 3 J 6 4 3 T 8 6 3 2 21. 22. 23. 24. K 9 T 8 A 9 7 4 A J 8 3 K 9 4 A Q 4 3 A T 3 A K 7 A K J T 3 A K T 4 K 7 5 Q 8 2 J 7 5 Q 8 2 A J 3 J 4 2 25. 26. 27. 28. K J 6 2 K Q 9 8 J 8 5 A Q 3 Q J 2 T 8 2 K 9 5 T 5 K Q 9 A Q 6 K J 9 A K 9 4 K T 5 A 8 6 A Q J 9 K T 9 5 29. 30. 31. 32. K T 4 A K J 4 Q 9 6 3 A J 6 K 9 7 3 K 9 4 J 6 A Q 8 A K 7 2 Q T 6 A K Q 9 K Q 9 3 2 A 9 K 8 2 K 7 2 8 6 33. 34. 35. 36. A 7 5 Q T 5 3 K 9 6 A K 3 2 8 7 K 5 A 8 7 4 K Q 5 K Q T 2 J T 2 Q 8 2 J T A Q 6 5 A K Q 9 A Q 3 K J 6 3 37. 38. 39. 40. K 9 8 5 K J 9 3 A 4 Q T 9 J 5 K Q A 5 2 K T A 7 3 J T 7 K 8 5 K Q 8 5 3 A K T 6 A J T 8 K Q 8 7 6 A J 2 41. 42. 43. 44. Q J 7 K J 7 3 Q 9 3 2 Q 6 4 2 A Q 7 8 2 A K 2 A K T Q 7 4 2 K J T Q J 5 4 K 7 A 8 7 A Q J T A 5 A T 9 8 45. 46. 47. 48. A K Q 9 A 8 7 3 Q 8 3 A K 7 9 6 5 Q 8 A K 9 A Q 7 5 A Q A Q T 9 Q T 8 6 J 7 6 3 T 9 8 4 A 9 2 A J 4 Q J 49. 50. 51. 52. K 6 3 K J T A K Q J 8 2 Q J 9 7 Q 9 5 T 8 7 3 A K T 4 Q J T A K Q 8 K 5 A 9 5 A Q 3 Q 9 4 A J 6 5 A 7 2 53. 54. 55. 56. 4 2 A 6 5 A T 8 A 5 K T 8 A J 4 2 A K 4 A K J 7 A 9 2 A K J 7 A Q 5 3 J 8 4 A K Q J 4 8 4 5 4 2 A 9 8 2 57. 58. 59. 60. A Q 6 4 A Q 7 6 J T 9 K 6 3 2 Q 8 5 A 6 5 3 T 2 A Q 3 9 7 K 8 7 A K 7 K 5 3 A K 8 7 Q 5 A K J 7 6 A 9 7 61. 62. 63. 64. K 7 A K Q 8 4 3 6 2 Q J 5 A Q 8 2 K Q K Q 7 3 A Q 7 5 2 J 8 4 T 7 5 A K J 6 K 6 2 Q T 5 3 A K Q 4 A 8 2 65. 66. 67. 68. J T A 7 A T 9 K 3 2 A Q T 4 A 6 4 A J 5 Q J 6 2 A 7 6 2 A K 9 6 4 3 Q J 4 A J 7 J 7 4 2 K Q J 5 2 A Q 4 69. 70. 71. 72. K 5 9 6 5 2 A K K 5 3 K Q T A 8 5 J 8 4 A 8 4 Q 9 7 4 3 A 6 2 K Q T 8 5 K 9 8 K Q J A K J Q 8 6 A Q 8 6 73. 74. 75. 76. K 7 9 7 4 3 A 2 A J 5 3 A J 8 K Q 7 J 8 7 6 A 4 3 2 J 7 6 4 K Q 9 4 A Q 4 2 A T 3 A K Q 4 K Q T 9 A Q 9 77. 78. 79. 80. Q 6 Q T 8 K T 8 T 7 6 A J 5 A 3 2 K Q T A 2 A 8 6 5 A Q J 7 A K 4 A Q T 7 K Q 9 2 A 7 4 T 9 6 4 A Q 8 3 81. 82. 83. 84. K J K Q 8 3 K 8 3 A J T 2 A K Q 2 A K Q 7 A 3 A K 8 4 J 7 3 Q 9 3 A T 8 5 2 T 7 6 Q 8 6 2 A Q 8 7 K J T 85. 86. 87. 88. K Q J K T 9 7 A K 5 2 J 8 7 K 8 2 A 3 T 3 K 8 6 A 9 A Q 5 3 A J 9 5 A K 9 5 4 A T 7 6 4 A 6 5 Q J 4 A 9 89. 90. 91. 92. Q 5 2 8 7 6 8 7 3 3 2 Q 7 5 A Q 8 A K 8 6 A K 5 A K 9 6 A J 9 6 A T 5 K J 9 3 A 6 2 K Q 3 A 3 2 A J 5 2 93. 94. 95. 96. T 9 K 5 3 K Q 8 3 A 7 2 A Q J 5 K 7 A J A 9 4 A K 7 K J 9 3 2 A Q 9 6 K Q 5 3 2 J 6 5 4 A J 8 7 5 2 K 8 97. 98. 99. 100. A Q 6 4 2 A 7 2 A K 6 4 K J 8 3 A 4 2 J 7 5 A 9 5 9 6 3 A Q 5 A 9 4 A 7 6 2 A Q 5 4 A Q 6 5 K Q J 8 7 4 West hands: 1. 2. 3. 4. K J 7 5 A Q 8 7 J 8 7 4 A J 6 5 4 J 5 Q 6 4 K 9 7 3 J 8 2 K 9 6 4 J 9 8 7 2 T 8 7 4 Q 7 5 3 Q 7 Q 8 Q 5 5. 6. 7. 8. K 7 9 9 8 K 7 4 T 6 4 2 A J T 9 K T K 3 2 T 7 4 7 5 4 A Q 9 8 2 K 8 K J 3 2 Q J T 6 5 A Q 9 3 8 7 5 3 2 9. 10. 11. 12. T 7 5 4 9 8 6 5 4 7 6 A Q 8 5 4 2 Q J 6 5 T 6 J 8 2 A 8 6 K J 8 6 5 A K 2 Q J 9 2 K 6 3 A 9 8 7 4 Q T 2 13. 14. 15. 16. A J 5 A 7 6 5 Q 2 J 9 6 4 3 A K T 5 9 A 7 5 A J 6 2 Q 9 6 4 A K J T 2 K 4 7 5 2 A 7 5 K J 9 8 6 5 Q 6 2 17. 18. 19. 20. J 8 5 K T 9 5 K Q T 8 6 3 J 8 5 2 6 5 4 3 A 4 - K J 9 7 6 Q J 5 2 Q 9 3 9 2 A 2 K 3 A 8 5 2 Q 9 8 7 2 7 5 21. 22. 23. 24. A J T 8 6 5 2 Q 2 Q T 4 8 7 K T 6 5 K Q J 2 Q J 9 5 4 2 8 7 6 9 7 2 T A K 6 Q K J 9 7 K Q 8 6 5 2 A K 3 25. 26. 27. 28. A Q 8 3 A 7 5 9 7 6 4 3 J 8 7 T 8 6 J 9 5 4 A Q 3 2 9 7 T 7 4 J T 2 T 2 Q J 8 2 J 8 6 Q 7 5 K 5 Q J 6 3 29. 30. 31. 32. A Q 6 5 2 T 8 3 A T 2 Q 4 A Q 2 A 8 K T 9 4 3 J 7 5 Q 8 3 A J 7 4 3 8 8 7 5 4 T 6 A 6 4 T 9 5 3 A J T 5 33. 34. 35. 36. T 8 2 K 9 4 A Q J T 8 5 T 9 8 7 6 4 K Q 4 J T 9 T 6 3 A 8 J 9 7 3 K 9 6 4 J 5 4 K Q 4 J 9 7 J T 8 2 4 2 37. 38. 39. 40. Q J 2 T 6 2 Q A K 6 3 A 9 8 6 4 2 A T 7 6 5 Q J T 8 7 J 8 5 Q T 4 8 J 9 6 J 9 7 8 K Q 7 5 J 5 3 2 9 4 3 41. 42. 43. 44. A T 9 8 A 5 K J 7 4 9 7 5 J T 9 8 4 A 9 6 T 9 5 4 3 J 6 3 J 8 7 5 3 2 K T 7 A Q T 9 2 Q 5 3 9 8 5 3 5 2 45. 46. 47. 48. 8 J A T 9 7 Q 8 3 K Q T A K 9 5 7 5 4 3 J 3 2 T 9 7 6 5 4 J 6 5 4 7 3 5 4 K J 6 K J 6 5 K 6 5 A T 7 6 2 49. 50. 51. 52. A Q 7 2 A 6 4 3 T 5 A 3 A 5 2 T 4 2 A K Q Q 8 2 A K 8 9 6 5 2 Q J T 6 4 K J 7 2 J 5 4 K 6 Q T 3 K Q 9 8 53. 54. 55. 56. A 9 6 3 K 8 Q 9 7 5 K T 2 J 9 7 4 Q 8 T 8 Q T 5 K 6 Q T 6 5 4 K J T 7 2 T 6 5 8 7 3 T 7 3 2 Q 3 K 6 5 4 57. 58. 59. 60. K J 3 K T 9 4 2 A 7 5 4 Q 5 4 T 7 6 3 J 8 7 2 - K 9 6 K T 8 5 A J T 4 Q J 5 4 2 Q 9 6 4 4 2 - Q 8 4 2 T 4 2 61. 62. 63. 64. J T 9 6 8 7 A 9 5 A K J T 8 5 A 8 6 3 9 6 4 3 A T 6 4 2 T 5 4 3 A 5 2 8 6 4 T 8 7 5 Q 8 4 K J 8 2 7 3 J 65. 66. 67. 68. A 8 6 2 8 3 2 Q 8 5 4 A Q T 5 4 K 6 2 K Q 7 5 Q 6 2 T 7 5 4 K Q 9 J 8 7 A 9 5 K 6 2 Q 4 2 K 9 8 T 9 8 8 69. 70. 71. 72. - Q 4 3 4 3 T 6 9 8 7 6 5 3 2 K T 3 K 9 7 6 K J 9 A K T 6 K 9 8 7 3 J 9 7 6 Q 6 2 9 7 9 5 A T 7 J 5 4 3 2 73. 74. 75. 76. 8 4 A K Q T 8 4 2 A K T 9 5 2 Q J 8 4 K 4 2 5 A T Q J 8 7 6 5 9 2 J 3 2 9 8 5 Q 9 6 5 5 3 8 4 3 T 7 5 4 77. 78. 79. 80. A J T 3 A K 3 2 5 K J 9 3 2 Q T 9 3 8 6 J 3 5 3 Q T 9 3 9 6 5 4 3 T 8 7 6 3 J 8 4 T 3 K Q J 7 2 K T 7 2 81. 82. 83. 84. A T 9 5 4 8 5 3 K Q 6 4 2 A 5 4 K Q 6 T J 4 K 6 5 4 - K T 8 6 5 K 8 6 5 4 9 7 6 9 8 4 3 2 K J T 3 2 9 7 5 85. 86. 87. 88. T 7 6 4 A J 6 5 4 J 9 6 4 A K T 9 4 3 A J T 7 3 T 6 Q J 9 5 T 4 3 Q J 8 J T 7 4 K T 8 7 Q J 2 J 9 6 K T 89. 90. 91. 92. J A Q J 9 3 A Q 6 J 6 T 6 2 5 Q 7 4 3 Q J T 9 8 Q J 5 3 K 8 7 5 2 Q 6 3 6 2 K 8 7 5 3 A 2 K 7 5 K 9 8 6 93. 94. 95. 96. K Q J 5 2 7 A J T 9 4 K J T 9 K 7 4 Q J T 5 4 6 5 4 6 2 J 4 A T 4 J 8 3 J 6 4 K T 9 9 7 6 3 Q J Q J 9 3 97. 98. 99. 100. 2 J T 7 K Q T 5 7 T 9 7 6 K 9 7 3 K 9 6 3 K T 8 6 4 A K J T 2 K 8 6 7 6 5 K Q 8 T 9 6 9 8 7 5 2 K Q 5 3 Generated 5861 hands Produced 100 hands Initial random seed 1 Time needed 0.013 sec dealer/Examples/Refer.hm1dr2d0100644000076400001440000000026410056343411015166 0ustar henkuserse3352: 0 Frequency spades: 0 1137 1 15858 2 83005 3 0 Generated 8239386 hands Produced 100000 hands Initial random seed 1 Time needed 20.194 sec dealer/Examples/.cvsignore0100644000076400001440000000001110002574544014732 0ustar henkusersOutput.* dealer/Examples/test_dealer.pl0100755000076400001440000000117410056341125015574 0ustar henkusers#!/usr/bin/perl $exe = "../dealer"; # # Fixed seed so that the output should be the same from run to run # $seed = 1; foreach $input (`ls Descr.*`) { # Loop over all files that start with Descr. chop $input; print "------------------------------------------------------------------\n"; print "Now processing $input\n"; $output = $input; $output =~ s/Descr/Output/; $refer = $input; $refer =~ s/Descr/Refer/; system ("$exe -s $seed $input >$output"); print "Done, output in $output\n"; if (-e $refer) { print "Comparing against reference output from $refer\n"; print `diff $output $refer`; } } dealer/Examples/Refer.junkstayman0100644000076400001440000000062610056343413016275 0ustar henkusers4450,7d: 0.185185 4450,8d: 0.37037 4450,8M: 0.444444 Frequency : 0 15 1 12 Frequency : 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 10 8 11 9 5 10 1 11 0 12 0 13 0 Generated 1000000 hands Produced 27 hands Initial random seed 1 Time needed 2.123 sec dealer/Examples/Refer.weaktwo0100644000076400001440000000045410056343621015412 0ustar henkusersFrequency points: 5 1358 6 1501 7 2140 8 1948 9 2218 10 1920 11 2001 hearts: 2.32386 Ace of spades: 0.546233 Jack of spades: 0.465841 Heart fit: 0.137322 Generated 1000000 hands Produced 13086 hands Initial random seed 1 Time needed 1.891 sec dealer/Examples/Descr.blue_team0100644000076400001440000000107010002574544015657 0ustar henkusers# # This example creates hands to illustrate the Blue Team Club auction # 1C-1H, with 1C strong and 1H positive without 3 controls. # west1c = hcp(west)>16 east1h = hcp(east)>7 && control(east)<3 condition west1c and east1h produce 10 action printew, frequency (control(east), 0, 6), frequency (loser(east), 0, 13) # The output will look like: # # A Q 4 3 # A Q 9 7 6 # A K Q J T 3 2 8 # J 8 6 A Q T 9 7 4 # # leaving ample space to comment about the bidding after 1C-1H. # dealer/Examples/Refer.controls0100644000076400001440000000046310056343365015601 0ustar henkusersFrequency controls: 0 0 1 0 2 0 3 1 4 23 5 289 6 1615 7 3573 8 3467 9 965 10 67 11 0 12 0 Generated 1541279 hands Produced 10000 hands Initial random seed 1 Time needed 2.201 sec dealer/Examples/Descr.junkstayman0100644000076400001440000000106110002574544016266 0ustar henkusers#junk stayman east_notrump = shape(east, any 4333, any 4432, 2335, 3235, 3325, 2353, 3253, 3352) && hcp(east)>=12 && hcp(east)<=14 west_low = (hcp(west)<8) x3=shape(west,4450) d=diamonds(east)+diamonds(west) h=hearts(east)+hearts(west) s=spades(east)+spades(west) m8=((s==8) or (h==8)) condition (east_notrump and west_low and x3) generate 1000000 action average "4450,7d" ((d==7) and (not m8)), average "4450,8d" ((d>7) and (not m8)), average "4450,8M" m8, frequency (m8,0,1), frequency (d,0,13) dealer/pointcount.c0100644000076400001440000000141110002574544013527 0ustar henkusers#include "pointcount.h" int tblPointcount [idxEnd][13] = { /* 2 3 4 5 6 7 8 9 T J Q K A */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4}, /* hcp */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2}, /* controls */ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, /* tens */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, /* jacks */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, /* queens */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, /* kings */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* aces */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, /* top2 */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1}, /* top3 */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}, /* top4 */ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}, /* top5 */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6} /* c13 */ } ; dealer/pointcount.h0100644000076400001440000000060410002574545013540 0ustar henkusers#ifndef POINTCOUNT_H #define POINTCOUNT_H /* Indexes into the pointcount array */ enum idxPointcount { idxHcp = 0 , idxControls , idxTens , idxJacks , idxQueens , idxKings , idxAces , idxTop2 , idxTop3 , idxWinners = idxTop3 , idxTop4 , idxTop5 , idxC13 , idxEnd } ; /* the pointcount array itself */ extern int tblPointcount [idxEnd][13] ; #endif /* POINTCOUNT_H */ dealer/scan.c0100644000076400001440000016255110056357700012270 0ustar henkusers/* A lexical scanner generated by flex */ /* Scanner skeleton version: * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #include /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #ifdef __cplusplus #include #include /* Use prototypes in function declarations. */ #define YY_USE_PROTOS /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ #if __STDC__ #define YY_USE_PROTOS #define YY_USE_CONST #endif /* __STDC__ */ #endif /* ! __cplusplus */ #ifdef __TURBOC__ #pragma warn -rch #pragma warn -use #include #include #define YY_USE_CONST #define YY_USE_PROTOS #endif #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif #ifdef YY_USE_PROTOS #define YY_PROTO(proto) proto #else #define YY_PROTO(proto) () #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #define YY_BUF_SIZE 16384 typedef struct yy_buffer_state *YY_BUFFER_STATE; extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* The funky do-while in the following #define is used to turn the definition * int a single C statement (which needs a semi-colon terminator). This * avoids problems with code like: * * if ( condition_holds ) * yyless( 5 ); * else * do_something_else(); * * Prior to using the do-while the compiler would get upset at the * "else" because it interpreted the "if" statement as being all * done when it reached the ';' after the yyless() call. */ /* Return all but the first 'n' matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ *yy_cp = yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, yytext_ptr ) /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). */ typedef unsigned int yy_size_t; struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; static YY_BUFFER_STATE yy_current_buffer = 0; /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". */ #define YY_CURRENT_BUFFER yy_current_buffer /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; void yyrestart YY_PROTO(( FILE *input_file )); void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); void yy_load_buffer_state YY_PROTO(( void )); YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern char *yytext; #define yytext_ptr yytext static yy_state_type yy_get_previous_state YY_PROTO(( void )); static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); static int yy_get_next_buffer YY_PROTO(( void )); static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yytext_ptr = yy_bp; \ yyleng = (int) (yy_cp - yy_bp); \ yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; #define YY_NUM_RULES 106 #define YY_END_OF_BUFFER 107 static yyconst short int yy_accept[355] = { 0, 0, 0, 22, 22, 107, 105, 102, 103, 105, 5, 105, 17, 105, 15, 13, 14, 16, 100, 100, 19, 9, 105, 11, 18, 101, 101, 94, 101, 101, 105, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 105, 105, 22, 24, 23, 106, 103, 0, 8, 0, 97, 1, 21, 0, 100, 0, 95, 10, 7, 12, 101, 95, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 48, 46, 98, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 47, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 45, 43, 4, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 3, 0, 104, 22, 23, 23, 25, 0, 20, 100, 0, 72, 101, 49, 101, 2, 92, 101, 82, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 62, 101, 89, 101, 101, 101, 101, 101, 6, 101, 101, 101, 101, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 101, 101, 93, 101, 101, 101, 101, 64, 101, 101, 44, 101, 101, 96, 99, 99, 72, 101, 101, 101, 86, 57, 101, 101, 101, 101, 54, 101, 101, 101, 101, 62, 101, 89, 66, 70, 101, 50, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 64, 74, 76, 78, 80, 101, 101, 56, 99, 100, 101, 101, 101, 57, 101, 101, 101, 101, 101, 101, 101, 101, 59, 66, 70, 83, 53, 101, 101, 101, 35, 101, 101, 68, 88, 91, 55, 60, 87, 101, 34, 101, 101, 101, 101, 28, 101, 101, 101, 101, 101, 59, 83, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 68, 60, 87, 101, 101, 51, 101, 84, 58, 101, 101, 101, 90, 61, 101, 30, 101, 101, 41, 38, 101, 101, 27, 85, 101, 32, 101, 84, 58, 101, 101, 26, 61, 101, 36, 101, 101, 37, 101, 33, 101, 52, 101, 101, 101, 101, 101, 31, 101, 101, 29, 101, 101, 101, 42, 39, 40, 0 } ; static yyconst int yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 6, 7, 1, 8, 9, 1, 1, 1, 10, 11, 1, 12, 1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 1, 25, 26, 27, 28, 1, 29, 30, 31, 31, 32, 33, 30, 31, 30, 34, 35, 30, 30, 36, 33, 30, 37, 30, 38, 39, 30, 30, 40, 30, 30, 30, 1, 41, 1, 1, 42, 1, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 30, 1, 68, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst int yy_meta[69] = { 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 2, 1, 2, 1, 5, 5, 5, 6, 6, 5, 5, 5, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 1 } ; static yyconst short int yy_base[367] = { 0, 0, 505, 66, 69, 511, 513, 513, 513, 67, 484, 503, 513, 499, 513, 513, 513, 64, 441, 42, 513, 480, 479, 478, 513, 44, 0, 93, 463, 464, 445, 33, 80, 34, 40, 440, 452, 41, 443, 454, 445, 438, 60, 434, 69, 430, 436, 88, 43, 428, 443, 133, 421, 485, 0, 513, 110, 513, 513, 103, 513, 481, 513, 513, 513, 483, 419, 0, 513, 513, 513, 513, 0, 0, 0, 468, 102, 123, 141, 145, 150, 149, 454, 145, 107, 152, 156, 0, 0, 513, 130, 81, 127, 435, 464, 435, 416, 422, 434, 433, 414, 431, 0, 426, 416, 410, 412, 426, 410, 422, 410, 404, 140, 0, 0, 0, 413, 150, 194, 175, 417, 405, 418, 397, 416, 402, 399, 405, 401, 393, 209, 167, 513, 450, 513, 0, 223, 224, 513, 449, 513, 385, 0, 389, 398, 0, 403, 0, 0, 387, 0, 401, 401, 158, 390, 388, 380, 387, 381, 392, 393, 376, 376, 374, 381, 384, 385, 384, 368, 369, 372, 381, 370, 379, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 370, 376, 0, 362, 363, 358, 373, 357, 222, 372, 360, 353, 262, 0, 228, 513, 0, 357, 356, 369, 0, 350, 359, 349, 361, 350, 0, 361, 342, 344, 360, 0, 340, 0, 340, 339, 339, 0, 348, 334, 334, 348, 332, 330, 341, 335, 343, 342, 338, 340, 0, 0, 0, 0, 0, 333, 338, 0, 0, 238, 328, 320, 333, 0, 319, 323, 319, 322, 320, 329, 332, 314, 312, 0, 0, 311, 0, 316, 325, 326, 243, 323, 305, 305, 0, 0, 0, 295, 291, 291, 0, 271, 279, 274, 270, 0, 277, 266, 265, 258, 273, 0, 0, 260, 260, 262, 261, 257, 201, 257, 268, 264, 243, 0, 0, 0, 266, 246, 0, 250, 245, 244, 242, 258, 255, 0, 238, 235, 0, 243, 241, 0, 0, 248, 238, 0, 0, 249, 0, 236, 0, 0, 231, 222, 0, 0, 231, 0, 216, 219, 0, 218, 0, 228, 0, 208, 226, 217, 220, 220, 0, 219, 207, 0, 173, 159, 172, 0, 0, 0, 513, 328, 334, 202, 337, 343, 349, 354, 359, 172, 171, 140, 88 } ; static yyconst short int yy_def[367] = { 0, 354, 1, 355, 355, 354, 354, 354, 354, 354, 354, 356, 354, 354, 354, 354, 354, 354, 357, 357, 354, 354, 354, 354, 354, 358, 358, 358, 358, 358, 354, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 354, 359, 360, 354, 361, 354, 354, 354, 354, 356, 354, 354, 354, 362, 363, 364, 354, 354, 354, 354, 358, 358, 358, 358, 358, 358, 358, 358, 358, 27, 27, 27, 27, 27, 27, 358, 358, 354, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 130, 354, 359, 354, 360, 361, 361, 354, 362, 354, 365, 366, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 354, 354, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 354, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, 0, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354 } ; static yyconst short int yy_nxt[582] = { 0, 6, 7, 8, 9, 10, 11, 6, 12, 13, 14, 15, 16, 17, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 26, 25, 25, 29, 25, 27, 25, 26, 30, 6, 31, 26, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 26, 42, 43, 44, 45, 46, 47, 48, 26, 49, 50, 51, 26, 52, 55, 58, 59, 55, 68, 64, 73, 56, 65, 90, 56, 68, 98, 73, 100, 105, 99, 106, 91, 107, 92, 125, 57, 199, 57, 57, 94, 57, 93, 57, 57, 126, 57, 57, 127, 101, 102, 58, 59, 67, 74, 75, 76, 77, 78, 79, 80, 81, 112, 74, 75, 137, 113, 82, 138, 114, 95, 116, 83, 84, 117, 85, 118, 86, 121, 96, 145, 72, 97, 122, 74, 75, 76, 72, 146, 198, 123, 124, 130, 131, 131, 131, 131, 131, 131, 131, 130, 130, 74, 75, 76, 77, 74, 75, 76, 77, 78, 74, 75, 76, 77, 78, 79, 72, 147, 72, 142, 141, 143, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 144, 72, 148, 72, 167, 171, 197, 130, 168, 172, 169, 197, 206, 197, 66, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 353, 207, 352, 185, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 354, 137, 351, 354, 138, 235, 236, 237, 238, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 315, 350, 349, 348, 316, 347, 346, 345, 344, 343, 342, 341, 340, 196, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 290, 339, 291, 338, 292, 337, 336, 335, 334, 333, 332, 331, 330, 329, 293, 294, 328, 327, 326, 325, 324, 323, 322, 321, 320, 319, 318, 317, 314, 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, 303, 302, 301, 242, 54, 54, 54, 54, 54, 54, 61, 61, 61, 61, 61, 61, 72, 72, 72, 133, 133, 133, 133, 133, 133, 135, 300, 299, 135, 135, 136, 298, 136, 136, 136, 139, 139, 139, 139, 139, 139, 297, 296, 295, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 241, 240, 239, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 205, 204, 203, 202, 201, 200, 199, 140, 134, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 170, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 72, 74, 142, 140, 62, 134, 132, 129, 128, 120, 119, 115, 111, 110, 109, 108, 104, 103, 89, 88, 87, 71, 70, 69, 67, 63, 62, 60, 354, 53, 5, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354 } ; static yyconst short int yy_chk[582] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 9, 9, 4, 19, 17, 25, 3, 17, 31, 4, 19, 33, 25, 34, 37, 33, 37, 31, 37, 31, 48, 3, 366, 3, 4, 32, 4, 31, 3, 3, 48, 4, 4, 48, 34, 34, 59, 59, 19, 27, 27, 27, 27, 27, 27, 27, 27, 42, 76, 76, 56, 42, 27, 56, 42, 32, 44, 27, 27, 44, 27, 44, 27, 47, 32, 91, 84, 32, 47, 77, 77, 77, 84, 91, 365, 47, 47, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 78, 78, 78, 78, 79, 79, 79, 79, 79, 80, 80, 80, 80, 80, 80, 81, 92, 83, 364, 363, 90, 81, 83, 83, 85, 83, 81, 81, 86, 81, 85, 81, 85, 86, 86, 90, 86, 92, 86, 112, 117, 131, 51, 112, 117, 112, 131, 153, 131, 357, 117, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 119, 350, 153, 349, 119, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 136, 137, 348, 136, 137, 192, 192, 192, 192, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 243, 243, 243, 243, 243, 243, 243, 243, 243, 243, 292, 346, 345, 343, 292, 342, 341, 340, 339, 337, 335, 333, 332, 130, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 264, 330, 264, 327, 264, 326, 323, 321, 318, 317, 314, 313, 311, 310, 264, 264, 308, 307, 306, 305, 304, 303, 301, 300, 296, 295, 294, 293, 291, 290, 289, 288, 287, 284, 283, 282, 281, 280, 278, 277, 276, 275, 196, 355, 355, 355, 355, 355, 355, 356, 356, 356, 356, 356, 356, 358, 358, 358, 359, 359, 359, 359, 359, 359, 360, 273, 272, 360, 360, 361, 271, 361, 361, 361, 362, 362, 362, 362, 362, 362, 267, 266, 265, 263, 262, 261, 259, 256, 255, 254, 253, 252, 251, 250, 249, 248, 246, 245, 244, 240, 239, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 220, 219, 218, 216, 214, 213, 212, 211, 209, 208, 207, 206, 205, 203, 202, 201, 195, 194, 193, 191, 190, 189, 188, 187, 185, 184, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 152, 151, 149, 146, 144, 143, 141, 139, 133, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 116, 111, 110, 109, 108, 107, 106, 105, 104, 103, 101, 100, 99, 98, 97, 96, 95, 94, 93, 82, 75, 66, 65, 61, 53, 52, 50, 49, 46, 45, 43, 41, 40, 39, 38, 36, 35, 30, 29, 28, 23, 22, 21, 18, 13, 11, 10, 5, 2, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354 } ; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "scan.l" #define INITIAL 0 /* $Header: /home/henk/CVS/dealer/scan.l,v 1.8 1999/07/05 19:44:30 henk Exp $ */ #define COMMENT 1 /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap YY_PROTO(( void )); #else extern int yywrap YY_PROTO(( void )); #endif #endif #ifndef YY_NO_UNPUT static void yyunput YY_PROTO(( int c, char *buf_ptr )); #endif #ifndef yytext_ptr static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen YY_PROTO(( yyconst char * )); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput YY_PROTO(( void )); #else static int input YY_PROTO(( void )); #endif #endif #if YY_STACK_USED static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = 0; #ifndef YY_NO_PUSH_STATE static void yy_push_state YY_PROTO(( int new_state )); #endif #ifndef YY_NO_POP_STATE static void yy_pop_state YY_PROTO(( void )); #endif #ifndef YY_NO_TOP_STATE static int yy_top_state YY_PROTO(( void )); #endif #else #define YY_NO_PUSH_STATE 1 #define YY_NO_POP_STATE 1 #define YY_NO_TOP_STATE 1 #endif #ifdef YY_MALLOC_DECL YY_MALLOC_DECL #else #if __STDC__ #ifndef __cplusplus #include #endif #else /* Just try to get by without declaring the routines. This will fail * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) * or sizeof(void*) != sizeof(int). */ #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( yy_current_buffer->yy_is_interactive ) \ { \ int c = '*', n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL int yylex YY_PROTO(( void )) #endif /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ if ( yyleng > 0 ) \ yy_current_buffer->yy_at_bol = \ (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 3 "scan.l" if ( yy_init ) { yy_init = 0; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! yy_start ) yy_start = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_load_buffer_state(); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = yy_c_buf_p; /* Support of yytext. */ *yy_cp = yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = yy_start; yy_current_state += YY_AT_BOL(); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 355 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 513 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yy_hold_char; yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; goto yy_find_action; case 1: YY_RULE_SETUP #line 4 "scan.l" return(AND2); YY_BREAK case 2: YY_RULE_SETUP #line 5 "scan.l" return(AND2); YY_BREAK case 3: YY_RULE_SETUP #line 6 "scan.l" return(OR2); YY_BREAK case 4: YY_RULE_SETUP #line 7 "scan.l" return(OR2); YY_BREAK case 5: YY_RULE_SETUP #line 8 "scan.l" return(NOT); YY_BREAK case 6: YY_RULE_SETUP #line 9 "scan.l" return(NOT); YY_BREAK case 7: YY_RULE_SETUP #line 10 "scan.l" return(CMPEQ); YY_BREAK case 8: YY_RULE_SETUP #line 11 "scan.l" return(CMPNE); YY_BREAK case 9: YY_RULE_SETUP #line 12 "scan.l" return(CMPLT); YY_BREAK case 10: YY_RULE_SETUP #line 13 "scan.l" return(CMPLE); YY_BREAK case 11: YY_RULE_SETUP #line 14 "scan.l" return(CMPGT); YY_BREAK case 12: YY_RULE_SETUP #line 15 "scan.l" return(CMPGE); YY_BREAK case 13: YY_RULE_SETUP #line 16 "scan.l" return(ARPLUS); YY_BREAK case 14: YY_RULE_SETUP #line 17 "scan.l" return(ARMINUS); YY_BREAK case 15: YY_RULE_SETUP #line 18 "scan.l" return(ARTIMES); YY_BREAK case 16: YY_RULE_SETUP #line 19 "scan.l" return(ARDIVIDE); YY_BREAK case 17: YY_RULE_SETUP #line 20 "scan.l" return(ARMOD); YY_BREAK case 18: YY_RULE_SETUP #line 21 "scan.l" return(QUERY); YY_BREAK case 19: YY_RULE_SETUP #line 22 "scan.l" return(COLON); YY_BREAK case 20: YY_RULE_SETUP #line 23 "scan.l" {lino++;} YY_BREAK case 21: YY_RULE_SETUP #line 24 "scan.l" BEGIN(COMMENT); YY_BREAK case 22: YY_RULE_SETUP #line 25 "scan.l" YY_BREAK case 23: YY_RULE_SETUP #line 26 "scan.l" YY_BREAK case 24: YY_RULE_SETUP #line 27 "scan.l" lino++; YY_BREAK case YY_STATE_EOF(COMMENT): #line 28 "scan.l" yyerror("EOF found in comment"); YY_BREAK case 25: YY_RULE_SETUP #line 29 "scan.l" BEGIN(INITIAL); YY_BREAK case 26: YY_RULE_SETUP #line 30 "scan.l" return(GENERATE); YY_BREAK case 27: YY_RULE_SETUP #line 31 "scan.l" return(PRODUCE); YY_BREAK case 28: YY_RULE_SETUP #line 32 "scan.l" return(DEALER); YY_BREAK case 29: YY_RULE_SETUP #line 33 "scan.l" return(VULNERABLE); YY_BREAK case 30: YY_RULE_SETUP #line 34 "scan.l" return(PREDEAL); YY_BREAK case 31: YY_RULE_SETUP #line 35 "scan.l" return(POINTCOUNT); YY_BREAK case 32: YY_RULE_SETUP #line 36 "scan.l" return(ALTCOUNT); YY_BREAK case 33: YY_RULE_SETUP #line 37 "scan.l" return(CONDITION); YY_BREAK case 34: YY_RULE_SETUP #line 38 "scan.l" return(ACTION); YY_BREAK case 35: YY_RULE_SETUP #line 39 "scan.l" return(PRINT); YY_BREAK case 36: YY_RULE_SETUP #line 40 "scan.l" return(PRINTALL); YY_BREAK case 37: YY_RULE_SETUP #line 41 "scan.l" return(PRINTPBN); YY_BREAK case 38: YY_RULE_SETUP #line 42 "scan.l" return(PRINTEW); YY_BREAK case 39: YY_RULE_SETUP #line 43 "scan.l" return(PRINTCOMPACT); YY_BREAK case 40: YY_RULE_SETUP #line 44 "scan.l" return(PRINTONELINE); YY_BREAK case 41: YY_RULE_SETUP #line 45 "scan.l" return(PRINTES); YY_BREAK case 42: YY_RULE_SETUP #line 46 "scan.l" return(EVALCONTRACT); YY_BREAK case 43: YY_RULE_SETUP #line 47 "scan.l" { yylval.y_int = NON_VUL; return VULN; } YY_BREAK case 44: YY_RULE_SETUP #line 48 "scan.l" { yylval.y_int = VUL; return VULN; } YY_BREAK case 45: YY_RULE_SETUP #line 49 "scan.l" { yylval.y_int = VULNERABLE_NS; return VULNERABLE; } YY_BREAK case 46: YY_RULE_SETUP #line 50 "scan.l" { yylval.y_int = VULNERABLE_NS; return VULNERABLE; } YY_BREAK case 47: YY_RULE_SETUP #line 51 "scan.l" { yylval.y_int = VULNERABLE_EW; return VULNERABLE; } YY_BREAK case 48: YY_RULE_SETUP #line 52 "scan.l" { yylval.y_int = VULNERABLE_EW; return VULNERABLE; } YY_BREAK case 49: YY_RULE_SETUP #line 53 "scan.l" { yylval.y_int = VULNERABLE_ALL; return VULNERABLE; } YY_BREAK case 50: YY_RULE_SETUP #line 54 "scan.l" { yylval.y_int = VULNERABLE_NONE; return VULNERABLE; } YY_BREAK case 51: YY_RULE_SETUP #line 55 "scan.l" return(AVERAGE); YY_BREAK case 52: YY_RULE_SETUP #line 56 "scan.l" return(FREQUENCY); YY_BREAK case 53: YY_RULE_SETUP #line 57 "scan.l" { yylval.y_int = COMPASS_NORTH; return COMPASS; } YY_BREAK case 54: YY_RULE_SETUP #line 58 "scan.l" { yylval.y_int = COMPASS_EAST; return COMPASS; } YY_BREAK case 55: YY_RULE_SETUP #line 59 "scan.l" { yylval.y_int = COMPASS_SOUTH; return COMPASS; } YY_BREAK case 56: YY_RULE_SETUP #line 60 "scan.l" { yylval.y_int = COMPASS_WEST; return COMPASS; } YY_BREAK case 57: YY_RULE_SETUP #line 61 "scan.l" { yylval.y_int = SUIT_CLUB; return SUIT; } YY_BREAK case 58: YY_RULE_SETUP #line 62 "scan.l" { yylval.y_int = SUIT_DIAMOND; return SUIT; } YY_BREAK case 59: YY_RULE_SETUP #line 63 "scan.l" { yylval.y_int = SUIT_HEART; return SUIT; } YY_BREAK case 60: YY_RULE_SETUP #line 64 "scan.l" { yylval.y_int = SUIT_SPADE; return SUIT; } YY_BREAK case 61: YY_RULE_SETUP #line 65 "scan.l" return NOTRUMPS; YY_BREAK case 62: YY_RULE_SETUP #line 66 "scan.l" return(HCP); YY_BREAK case 63: YY_RULE_SETUP #line 67 "scan.l" return(PT0); YY_BREAK case 64: YY_RULE_SETUP #line 68 "scan.l" return(PT0); YY_BREAK case 65: YY_RULE_SETUP #line 69 "scan.l" return(PT1); YY_BREAK case 66: YY_RULE_SETUP #line 70 "scan.l" return(PT1); YY_BREAK case 67: YY_RULE_SETUP #line 71 "scan.l" return(PT2); YY_BREAK case 68: YY_RULE_SETUP #line 72 "scan.l" return(PT2); YY_BREAK case 69: YY_RULE_SETUP #line 73 "scan.l" return(PT3); YY_BREAK case 70: YY_RULE_SETUP #line 74 "scan.l" return(PT3); YY_BREAK case 71: YY_RULE_SETUP #line 75 "scan.l" return(PT4); YY_BREAK case 72: YY_RULE_SETUP #line 76 "scan.l" return(PT4); YY_BREAK case 73: YY_RULE_SETUP #line 77 "scan.l" return(PT5); YY_BREAK case 74: YY_RULE_SETUP #line 78 "scan.l" return(PT5); YY_BREAK case 75: YY_RULE_SETUP #line 79 "scan.l" return(PT6); YY_BREAK case 76: YY_RULE_SETUP #line 80 "scan.l" return(PT6); YY_BREAK case 77: YY_RULE_SETUP #line 81 "scan.l" return(PT7); YY_BREAK case 78: YY_RULE_SETUP #line 82 "scan.l" return(PT7); YY_BREAK case 79: YY_RULE_SETUP #line 83 "scan.l" return(PT8); YY_BREAK case 80: YY_RULE_SETUP #line 84 "scan.l" return(PT8); YY_BREAK case 81: YY_RULE_SETUP #line 85 "scan.l" return(PT9); YY_BREAK case 82: YY_RULE_SETUP #line 86 "scan.l" return(PT9); YY_BREAK case 83: YY_RULE_SETUP #line 87 "scan.l" return(LOSER); YY_BREAK case 84: YY_RULE_SETUP #line 88 "scan.l" return(CONTROL); YY_BREAK case 85: YY_RULE_SETUP #line 89 "scan.l" return(QUALITY); YY_BREAK case 86: YY_RULE_SETUP #line 90 "scan.l" return(CCCC); YY_BREAK case 87: YY_RULE_SETUP #line 91 "scan.l" return(TRICKS); YY_BREAK case 88: YY_RULE_SETUP #line 92 "scan.l" return(SCORE); YY_BREAK case 89: YY_RULE_SETUP #line 93 "scan.l" return(IMPS); YY_BREAK case 90: YY_RULE_SETUP #line 94 "scan.l" return(HASCARD); YY_BREAK case 91: YY_RULE_SETUP #line 95 "scan.l" return(SHAPE); YY_BREAK case 92: YY_RULE_SETUP #line 96 "scan.l" return(ANY); YY_BREAK case 93: YY_RULE_SETUP #line 97 "scan.l" return(RND); YY_BREAK case 94: YY_RULE_SETUP #line 98 "scan.l" { yylval.y_str = mystrcpy(yytext); return HOLDING; } YY_BREAK case 95: YY_RULE_SETUP #line 99 "scan.l" { yylval.y_int = make_card(yytext[0], yytext[1]); return(CARD); } YY_BREAK case 96: YY_RULE_SETUP #line 101 "scan.l" { yylval.y_int = make_contract(yytext[2], yytext[1]); return(CONTRACT);} YY_BREAK case 97: YY_RULE_SETUP #line 103 "scan.l" { yytext[yyleng-1] = 0; yylval.y_str = mystrcpy(yytext+1); return STRING; } YY_BREAK case 98: YY_RULE_SETUP #line 104 "scan.l" { yylval.y_str = mystrcpy("\n"); return STRING; } YY_BREAK case 99: YY_RULE_SETUP #line 105 "scan.l" { strncpy(yylval.y_distr, yytext, 4); return strchr(yytext, 'x') ? DISTR : DISTR_OR_NUMBER; } YY_BREAK case 100: YY_RULE_SETUP #line 107 "scan.l" { yylval.y_int = atoi(yytext); return NUMBER; } YY_BREAK /* AM990705: removed a production to fix unary-minus syntax glitch */ /* [-][0-9]+ { yylval.y_int = atoi(yytext); return NUMBER; } */ case 101: YY_RULE_SETUP #line 112 "scan.l" { yylval.y_str = mystrcpy(yytext); return IDENT; } YY_BREAK case 102: YY_RULE_SETUP #line 113 "scan.l" ; YY_BREAK case 103: YY_RULE_SETUP #line 114 "scan.l" { lino++; } YY_BREAK case 104: YY_RULE_SETUP #line 115 "scan.l" { lino++; } YY_BREAK case 105: YY_RULE_SETUP #line 116 "scan.l" return(yytext[0]); YY_BREAK case 106: YY_RULE_SETUP #line 118 "scan.l" ECHO; YY_BREAK case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between yy_current_buffer and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ yy_n_chars = yy_current_buffer->yy_n_chars; yy_current_buffer->yy_input_file = yyin; yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = yy_c_buf_p; goto yy_find_action; } } else switch ( yy_get_next_buffer() ) { case EOB_ACT_END_OF_FILE: { yy_did_buffer_switch_on_eof = 0; if ( yywrap() ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: yy_c_buf_p = &yy_current_buffer->yy_ch_buf[yy_n_chars]; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer() { register char *dest = yy_current_buffer->yy_ch_buf; register char *source = yytext_ptr; register int number_to_move, i; int ret_val; if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( yy_current_buffer->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ yy_current_buffer->yy_n_chars = yy_n_chars = 0; else { int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ #ifdef YY_USES_REJECT YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); #else /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = yy_current_buffer; int yy_c_buf_p_offset = (int) (yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yy_flex_realloc( (void *) b->yy_ch_buf, b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; #endif } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), yy_n_chars, num_to_read ); yy_current_buffer->yy_n_chars = yy_n_chars; } if ( yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; yy_current_buffer->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; yy_n_chars += number_to_move; yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state() { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = yy_start; yy_current_state += YY_AT_BOL(); for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 355 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ #ifdef YY_USE_PROTOS static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) #else static yy_state_type yy_try_NUL_trans( yy_current_state ) yy_state_type yy_current_state; #endif { register int yy_is_jam; register char *yy_cp = yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 355 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 354); return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_UNPUT #ifdef YY_USE_PROTOS static void yyunput( int c, register char *yy_bp ) #else static void yyunput( c, yy_bp ) int c; register char *yy_bp; #endif { register char *yy_cp = yy_c_buf_p; /* undo effects of setting up yytext */ *yy_cp = yy_hold_char; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = yy_n_chars + 2; register char *dest = &yy_current_buffer->yy_ch_buf[ yy_current_buffer->yy_buf_size + 2]; register char *source = &yy_current_buffer->yy_ch_buf[number_to_move]; while ( source > yy_current_buffer->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); yy_current_buffer->yy_n_chars = yy_n_chars = yy_current_buffer->yy_buf_size; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; yytext_ptr = yy_bp; yy_hold_char = *yy_cp; yy_c_buf_p = yy_cp; } #endif /* ifndef YY_NO_UNPUT */ #ifdef __cplusplus static int yyinput() #else static int input() #endif { int c; *yy_c_buf_p = yy_hold_char; if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) /* This was really a NUL. */ *yy_c_buf_p = '\0'; else { /* need more input */ int offset = yy_c_buf_p - yytext_ptr; ++yy_c_buf_p; switch ( yy_get_next_buffer() ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart( yyin ); /* fall through */ case EOB_ACT_END_OF_FILE: { if ( yywrap() ) return EOF; if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + offset; break; } } } c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ *yy_c_buf_p = '\0'; /* preserve yytext */ yy_hold_char = *++yy_c_buf_p; yy_current_buffer->yy_at_bol = (c == '\n'); return c; } #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) #else void yyrestart( input_file ) FILE *input_file; #endif { if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_init_buffer( yy_current_buffer, input_file ); yy_load_buffer_state(); } #ifdef YY_USE_PROTOS void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) #else void yy_switch_to_buffer( new_buffer ) YY_BUFFER_STATE new_buffer; #endif { if ( yy_current_buffer == new_buffer ) return; if ( yy_current_buffer ) { /* Flush out information for old buffer. */ *yy_c_buf_p = yy_hold_char; yy_current_buffer->yy_buf_pos = yy_c_buf_p; yy_current_buffer->yy_n_chars = yy_n_chars; } yy_current_buffer = new_buffer; yy_load_buffer_state(); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yy_did_buffer_switch_on_eof = 1; } #ifdef YY_USE_PROTOS void yy_load_buffer_state( void ) #else void yy_load_buffer_state() #endif { yy_n_chars = yy_current_buffer->yy_n_chars; yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; yyin = yy_current_buffer->yy_input_file; yy_hold_char = *yy_c_buf_p; } #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) #else YY_BUFFER_STATE yy_create_buffer( file, size ) FILE *file; int size; #endif { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer( b, file ); return b; } #ifdef YY_USE_PROTOS void yy_delete_buffer( YY_BUFFER_STATE b ) #else void yy_delete_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; if ( b == yy_current_buffer ) yy_current_buffer = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yy_flex_free( (void *) b->yy_ch_buf ); yy_flex_free( (void *) b ); } #ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE extern int isatty YY_PROTO(( int )); #endif #endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) #else void yy_init_buffer( b, file ) YY_BUFFER_STATE b; FILE *file; #endif { yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; #if YY_ALWAYS_INTERACTIVE b->yy_is_interactive = 1; #else #if YY_NEVER_INTERACTIVE b->yy_is_interactive = 0; #else b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif #endif } #ifdef YY_USE_PROTOS void yy_flush_buffer( YY_BUFFER_STATE b ) #else void yy_flush_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == yy_current_buffer ) yy_load_buffer_state(); } #ifndef YY_NO_SCAN_BUFFER #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) #else YY_BUFFER_STATE yy_scan_buffer( base, size ) char *base; yy_size_t size; #endif { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer( b ); return b; } #endif #ifndef YY_NO_SCAN_STRING #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) #else YY_BUFFER_STATE yy_scan_string( yy_str ) yyconst char *yy_str; #endif { int len; for ( len = 0; yy_str[len]; ++len ) ; return yy_scan_bytes( yy_str, len ); } #endif #ifndef YY_NO_SCAN_BYTES #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) #else YY_BUFFER_STATE yy_scan_bytes( bytes, len ) yyconst char *bytes; int len; #endif { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) yy_flex_alloc( n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < len; ++i ) buf[i] = bytes[i]; buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer( buf, n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #endif #ifndef YY_NO_PUSH_STATE #ifdef YY_USE_PROTOS static void yy_push_state( int new_state ) #else static void yy_push_state( new_state ) int new_state; #endif { if ( yy_start_stack_ptr >= yy_start_stack_depth ) { yy_size_t new_size; yy_start_stack_depth += YY_START_STACK_INCR; new_size = yy_start_stack_depth * sizeof( int ); if ( ! yy_start_stack ) yy_start_stack = (int *) yy_flex_alloc( new_size ); else yy_start_stack = (int *) yy_flex_realloc( (void *) yy_start_stack, new_size ); if ( ! yy_start_stack ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } yy_start_stack[yy_start_stack_ptr++] = YY_START; BEGIN(new_state); } #endif #ifndef YY_NO_POP_STATE static void yy_pop_state() { if ( --yy_start_stack_ptr < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN(yy_start_stack[yy_start_stack_ptr]); } #endif #ifndef YY_NO_TOP_STATE static int yy_top_state() { return yy_start_stack[yy_start_stack_ptr - 1]; } #endif #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif #ifdef YY_USE_PROTOS static void yy_fatal_error( yyconst char msg[] ) #else static void yy_fatal_error( msg ) char msg[]; #endif { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ yytext[yyleng] = yy_hold_char; \ yy_c_buf_p = yytext + n; \ yy_hold_char = *yy_c_buf_p; \ *yy_c_buf_p = '\0'; \ yyleng = n; \ } \ while ( 0 ) /* Internal utility routines. */ #ifndef yytext_ptr #ifdef YY_USE_PROTOS static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) #else static void yy_flex_strncpy( s1, s2, n ) char *s1; yyconst char *s2; int n; #endif { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN #ifdef YY_USE_PROTOS static int yy_flex_strlen( yyconst char *s ) #else static int yy_flex_strlen( s ) yyconst char *s; #endif { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif #ifdef YY_USE_PROTOS static void *yy_flex_alloc( yy_size_t size ) #else static void *yy_flex_alloc( size ) yy_size_t size; #endif { return (void *) malloc( size ); } #ifdef YY_USE_PROTOS static void *yy_flex_realloc( void *ptr, yy_size_t size ) #else static void *yy_flex_realloc( ptr, size ) void *ptr; yy_size_t size; #endif { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } #ifdef YY_USE_PROTOS static void yy_flex_free( void *ptr ) #else static void yy_flex_free( ptr ) void *ptr; #endif { free( ptr ); } #if YY_MAIN int main() { yylex(); return 0; } #endif #line 118 "scan.l" dealer/scan.l0100644000076400001440000001074710056340743012277 0ustar henkusers/* $Header: /home/henk/CVS/dealer/scan.l,v 1.8 1999/07/05 19:44:30 henk Exp $ */ %x COMMENT %% "&&" return(AND2); and return(AND2); "||" return(OR2); or return(OR2); "!" return(NOT); not return(NOT); "==" return(CMPEQ); "!=" return(CMPNE); "<" return(CMPLT); "<=" return(CMPLE); ">" return(CMPGT); ">=" return(CMPGE); "+" return(ARPLUS); "-" return(ARMINUS); "*" return(ARTIMES); "/" return(ARDIVIDE); "%" return(ARMOD); "?" return(QUERY); ":" return(COLON); "//".*\n {lino++;} "/*" BEGIN(COMMENT); [^*\n<>]* "*"+[^*/\n<]* \n lino++; <> yyerror("EOF found in comment"); "*"+"/" BEGIN(INITIAL); generate return(GENERATE); produce return(PRODUCE); dealer return(DEALER); vulnerable return(VULNERABLE); predeal return(PREDEAL); pointcount return(POINTCOUNT); altcount return(ALTCOUNT); condition return(CONDITION); action return(ACTION); print return(PRINT); printall return(PRINTALL); printpbn return(PRINTPBN); printew return(PRINTEW); printcompact return(PRINTCOMPACT); printoneline return(PRINTONELINE); printes return(PRINTES); evalcontract return(EVALCONTRACT); nv { yylval.y_int = NON_VUL; return VULN; } vul { yylval.y_int = VUL; return VULN; } ns { yylval.y_int = VULNERABLE_NS; return VULNERABLE; } NS { yylval.y_int = VULNERABLE_NS; return VULNERABLE; } ew { yylval.y_int = VULNERABLE_EW; return VULNERABLE; } EW { yylval.y_int = VULNERABLE_EW; return VULNERABLE; } all { yylval.y_int = VULNERABLE_ALL; return VULNERABLE; } none { yylval.y_int = VULNERABLE_NONE; return VULNERABLE; } average return(AVERAGE); frequency return(FREQUENCY); north { yylval.y_int = COMPASS_NORTH; return COMPASS; } east { yylval.y_int = COMPASS_EAST; return COMPASS; } south { yylval.y_int = COMPASS_SOUTH; return COMPASS; } west { yylval.y_int = COMPASS_WEST; return COMPASS; } clubs? { yylval.y_int = SUIT_CLUB; return SUIT; } diamonds? { yylval.y_int = SUIT_DIAMOND; return SUIT; } hearts? { yylval.y_int = SUIT_HEART; return SUIT; } spades? { yylval.y_int = SUIT_SPADE; return SUIT; } notrumps? return NOTRUMPS; hcps? return(HCP); pt0 return(PT0); tens? return(PT0); pt1 return(PT1); jacks? return(PT1); pt2 return(PT2); queens? return(PT2); pt3 return(PT3); kings? return(PT3); pt4 return(PT4); aces? return(PT4); pt5 return(PT5); top2 return(PT5); pt6 return(PT6); top3 return(PT6); pt7 return(PT7); top4 return(PT7); pt8 return(PT8); top5 return(PT8); pt9 return(PT9); c13 return(PT9); losers? return(LOSER); controls? return(CONTROL); quality return(QUALITY); cccc return(CCCC); tricks? return(TRICKS); score return(SCORE); imps? return(IMPS); hascard return(HASCARD); shape return(SHAPE); any return(ANY); rnd return(RND); [CDHS]A?K?Q?J?T?9?8?7?6?5?4?3?2? { yylval.y_str = mystrcpy(yytext); return HOLDING; } [2-9TJQKA][CDHS] { yylval.y_int = make_card(yytext[0], yytext[1]); return(CARD); } [x][1-7][CDHSN] { yylval.y_int = make_contract(yytext[2], yytext[1]); return(CONTRACT);} \"[^"]*\" { yytext[yyleng-1] = 0; yylval.y_str = mystrcpy(yytext+1); return STRING; } \\n { yylval.y_str = mystrcpy("\n"); return STRING; } [0-9x]{4} { strncpy(yylval.y_distr, yytext, 4); return strchr(yytext, 'x') ? DISTR : DISTR_OR_NUMBER; } [0-9]+ { yylval.y_int = atoi(yytext); return NUMBER; } /* AM990705: removed a production to fix unary-minus syntax glitch */ /* [-][0-9]+ { yylval.y_int = atoi(yytext); return NUMBER; } */ [a-zA-Z][a-zA-Z0-9_]* { yylval.y_str = mystrcpy(yytext); return IDENT; } [ \t] ; \r*\n { lino++; } ^\#.*\n { lino++; } . return(yytext[0]); dealer/tree.h0100644000076400001440000000713110056340755012302 0ustar henkusers#ifndef TREE_H #define TREE_H /* * decision tree and other expression stuff */ struct tree { int tr_type; struct tree *tr_leaf1, *tr_leaf2; int tr_int1; int tr_int2; int tr_int3; }; struct expr { struct tree* ex_tr; char* ex_ch; struct expr* next; }; #define NIL ((struct tree *) 0) #define SUIT_CLUB 0 #define SUIT_DIAMOND 1 #define SUIT_HEART 2 #define SUIT_SPADE 3 #define SUIT_NT 4 #define NSUITS 4 #define MAKECARD(suit, rank) ((card)(((suit)<<6)|(rank))) #define MAKECONTRACT(suit, tricks) (tricks*5+suit) #define C_SUIT(c) ((c)>>6) #define C_RANK(c) ((c)&0x3F) #define NO_CARD 0xFF #define COMPASS_NORTH 0 #define COMPASS_EAST 1 #define COMPASS_SOUTH 2 #define COMPASS_WEST 3 #define VULNERABLE_NONE 0 #define VULNERABLE_NS 1 #define VULNERABLE_EW 2 #define VULNERABLE_ALL 3 #define NON_VUL 0 #define VUL 1 #define TRT_NUMBER 0 #define TRT_AND2 1 #define TRT_OR2 2 #define TRT_CMPEQ 3 #define TRT_CMPNE 4 #define TRT_CMPLT 5 #define TRT_CMPLE 6 #define TRT_CMPGT 7 #define TRT_CMPGE 8 #define TRT_LENGTH 9 #define TRT_ARPLUS 10 #define TRT_ARMINUS 11 #define TRT_ARTIMES 12 #define TRT_ARDIVIDE 13 #define TRT_ARMOD 14 #define TRT_HCPTOTAL 15 #define TRT_HCP 16 #define TRT_SHAPE 17 #define TRT_NOT 18 #define TRT_HASCARD 19 #define TRT_IF 20 #define TRT_THENELSE 21 #define TRT_LOSERTOTAL 22 #define TRT_LOSER 23 #define TRT_TRICKS 24 #define TRT_RND 25 #define TRT_CONTROL 26 #define TRT_CONTROLTOTAL 27 #define TRT_SCORE 28 #define TRT_IMPS 29 #define TRT_CCCC 30 #define TRT_QUALITY 31 #define TRT_PT0TOTAL 32 #define TRT_PT0 33 #define TRT_PT1TOTAL 34 #define TRT_PT1 35 #define TRT_PT2TOTAL 36 #define TRT_PT2 37 #define TRT_PT3TOTAL 38 #define TRT_PT3 39 #define TRT_PT4TOTAL 40 #define TRT_PT4 41 #define TRT_PT5TOTAL 42 #define TRT_PT5 43 #define TRT_PT6TOTAL 44 #define TRT_PT6 45 #define TRT_PT7TOTAL 46 #define TRT_PT7 47 #define TRT_PT8TOTAL 48 #define TRT_PT8 49 #define TRT_PT9TOTAL 50 #define TRT_PT9 51 /* * Actions to be taken */ struct acuft{ long acuf_lowbnd; long acuf_highbnd; long acuf_uflow; long acuf_oflow; long*acuf_freqs; }; struct acuft2d{ long acuf_lowbnd_expr1; long acuf_highbnd_expr1; long acuf_lowbnd_expr2; long acuf_highbnd_expr2; long*acuf_freqs; }; struct action { struct action *ac_next; int ac_type; struct tree *ac_expr1; struct tree *ac_expr2; int ac_int1; char *ac_str1; union { struct acuft acu_f; struct acuft2d acu_f2d; } ac_u; }; #define ACT_PRINTALL 0 #define ACT_PRINT 1 #define ACT_AVERAGE 2 #define ACT_FREQUENCY 3 #define ACT_PRINTCOMPACT 4 #define ACT_EVALCONTRACT 5 #define ACT_PRINTPBN 6 #define ACT_PRINTEW 7 #define ACT_FREQUENCY2D 8 #define ACT_PRINTONELINE 9 #define ACT_PRINTES 10 /* Constants for CCCC and Quality */ #define RK_ACE 12 #define RK_KING 11 #define RK_QUEEN 10 #define RK_JACK 9 #define RK_TEN 8 #define RK_NINE 7 #define RK_EIGHT 6 #ifdef WIN32 #define bcopy(s,t,size) memcpy(t,s,size) #endif #endif /* TREE_H */ dealer/Post_Processors/0040755000076400001440000000000010002574544014336 5ustar henkusersdealer/Post_Processors/README0100644000076400001440000000006410002574544015213 0ustar henkusersThis directory contains post-processing programs. dealer/Post_Processors/pbn_to_ascii.pl0100755000076400001440000000242710002574544017331 0ustar henkusers#!/usr/bin/perl eval 'exec /usr/local/appl/bin/perl -S $0 ${1+"$@"}' if 0; # not running under some shell # dealpbn takes a PBN file and generates hands as ascii in square layout # relevant aspects of PBM format were quessed from the output of dealer # e.g. # dealer Descr.pbn | dealpbn # # Robin Barker (Robin.Barker@NPL.co.uk), 1999/03/10 use strict; local $/ = ''; # paragraph mode my $VERSION = 0.1; my $compass_char = "NESW"; my @compass_list = split //, $compass_char; my %compass_rank; @compass_rank{@compass_list} = 0 .. $#compass_list; my %hands; sub printhand { my $h = shift ; foreach my $i (@{$h}) { print "\t".($i || "--")."\n"} }; sub printhands { my($h1,$h2) = @_; foreach my $i (0..3){ printf "%-16s%s\n", $h1->[$i] || '--', $h2->[$i] || '--'; } } while( <> ) { die $_ unless /\A(\[\w+\s+"[^"]*"\]\s+)+\Z/; my %info; while( /\[(\w+)\s+"([^"]*)"\]/g ) { $info{$1} = $2; } die "No Deal\n$_" unless $_ = $info{Deal}; my $first = s/^([$compass_char]):// ? $1 : ($info{Dealer} || 'N'); my %hands; @hands{ map { $compass_list[($compass_rank{$first} + $_) % 4] } 0 .. 3 } = map { [ (split /\./, $_, 4) ] } split; printhand $hands{'N'}; printhands $hands{'W'}, $hands{'E'}; printhand $hands{'S'}; print "\n"; } dealer/.cvsignore0100644000076400001440000000004710002574543013164 0ustar henkusersdefs.c scan.c *.o dealer dealer.tar.gz