dealer/0000755000401600040160000000000013204633274010356 5ustar cbecbedealer/defs.y0000644000401600040160000004661512777464151011517 0ustar cbecbe%{ #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 %left COLON %left OR2 %left AND2 %left CMPEQ %left CMPNE %left CMPLT %left CMPLE %left CMPGT %left CMPGE %left ARPLUS %left ARMINUS %left ARTIMES %left ARDIVIDE %left ARMOD %nonassoc NOT %token GENERATE %token PRODUCE %token HCP %token SHAPE %token ANY %token EXCEPT %token CONDITION %token ACTION %token PRINT %token PRINTALL %token PRINTEW %token PRINTPBN %token PRINTCOMPACT %token PRINTONELINE %token AVERAGE %token HASCARD %token FREQUENCY %token PREDEAL %token POINTCOUNT %token ALTCOUNT %token CONTROL %token LOSER %token DEALER %token QUALITY %token CCCC %token TRICKS %token NOTRUMPS %token NORTHSOUTH %token EASTWEST %token EVALCONTRACT %token ALL %token NONE %token SCORE %token IMPS %token RND %token PT0 %token PT1 %token PT2 %token PT3 %token PT4 %token PT5 %token PT6 %token PT7 %token PT8 %token PT9 %token PRINTES %token NUMBER %token HOLDING %token STRING %token IDENT %token COMPASS %token VULNERABLE %token VULN %token SUIT %token CARD %token CONTRACT %token DISTR %token DISTR_OR_NUMBER %type expr %type number %type compass %type printlist %type shlprefix %type any %type 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/scan.c0000644000401600040160000020372412777467667011507 0ustar cbecbe #line 3 "" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 #define YY_FLEX_SUBMINOR_VERSION 0 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ #include #include #include #include /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! C99 */ #endif /* ! FLEXINT_H */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ /* C99 requires __STDC__ to be defined as 1. */ #if defined (__STDC__) #define YY_USE_CONST #endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #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. */ #ifndef YY_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k. * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. * Ditto for the __ia64__ case accordingly. */ #define YY_BUF_SIZE 32768 #else #define YY_BUF_SIZE 16384 #endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; #endif extern yy_size_t yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE 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. */ yy_size_t 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; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* 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 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* 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". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ yy_size_t yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 0; /* 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 (FILE *input_file ); void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); void yy_delete_buffer (YY_BUFFER_STATE b ); void yy_flush_buffer (YY_BUFFER_STATE b ); void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); void yypop_buffer_state (void ); static void yyensure_buffer_stack (void ); static void yy_load_buffer_state (void ); static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ); void *yyalloc (yy_size_t ); void *yyrealloc (void *,yy_size_t ); void yyfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern int yylineno; int yylineno = 1; extern char *yytext; #ifdef yytext_ptr #undef yytext_ptr #endif #define yytext_ptr yytext static yy_state_type yy_get_previous_state (void ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); static int yy_get_next_buffer (void ); #if defined(__GNUC__) && __GNUC__ >= 3 __attribute__((__noreturn__)) #endif static void yy_fatal_error (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 = (size_t) (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 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t 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 YY_CHAR 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 YY_CHAR 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 flex_uint16_t 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 flex_int16_t 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 flex_uint16_t 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 flex_int16_t 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; extern int yy_flex_debug; int yy_flex_debug = 0; /* 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" /* $Header: /home/henk/CVS/dealer/scan.l,v 1.8 1999/07/05 19:44:30 henk Exp $ */ #line 713 "" #define INITIAL 0 #define COMMENT 1 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif static int yy_init_globals (void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ int yylex_destroy (void ); int yyget_debug (void ); void yyset_debug (int debug_flag ); YY_EXTRA_TYPE yyget_extra (void ); void yyset_extra (YY_EXTRA_TYPE user_defined ); FILE *yyget_in (void ); void yyset_in (FILE * _in_str ); FILE *yyget_out (void ); void yyset_out (FILE * _out_str ); yy_size_t yyget_leng (void ); char *yyget_text (void ); int yyget_lineno (void ); void yyset_lineno (int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap (void ); #else extern int yywrap (void ); #endif #endif #ifndef YY_NO_UNPUT static void yyunput (int c,char *buf_ptr ); #endif #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void ); #else static int input (void ); #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #ifdef __ia64__ /* On IA-64, the buffer size is 16k, not 8k */ #define YY_READ_BUF_SIZE 16384 #else #define YY_READ_BUF_SIZE 8192 #endif /* __ia64__ */ #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 do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #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_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ size_t 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 \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(yyin); \ } \ }\ \ #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 /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 extern int yylex (void); #define YY_DECL int yylex (void) #endif /* !YY_DECL */ /* 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 /*LINTED*/break; #endif #define YY_RULE_SETUP \ if ( yyleng > 0 ) \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { yy_state_type yy_current_state; char *yy_cp, *yy_bp; int yy_act; if ( !(yy_init) ) { (yy_init) = 1; #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 ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ); } yy_load_buffer_state( ); } { #line 3 "scan.l" #line 937 "" while ( /*CONSTCOND*/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 { 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: /* rule 20 can match eol */ 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: /* rule 24 can match eol */ 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: /* rule 97 can match eol */ 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: /* rule 103 can match eol */ YY_RULE_SETUP #line 114 "scan.l" { lino++; } YY_BREAK case 104: /* rule 104 can match eol */ 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 #line 1539 "" 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_LVALUE->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_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->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_LVALUE->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_LVALUE->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 user's declarations */ } /* 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 (void) { char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = (yytext_ptr); yy_size_t number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->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 = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { yy_size_t 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. */ yyrealloc((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_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), num_to_read ); YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); } (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->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 (void) { yy_state_type yy_current_state; 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 ) { 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 ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { int yy_is_jam; char *yy_cp = (yy_c_buf_p); 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 static void yyunput (int c, char * yy_bp ) { char *yy_cp; yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ yy_size_t number_to_move = (yy_n_chars) + 2; char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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_INPUT #ifdef __cplusplus static int yyinput (void) #else static int input (void) #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_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ yy_size_t 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 ); /*FALLTHROUGH*/ 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_LVALUE->yy_at_bol = (c == '\n'); return c; } #endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void yyrestart (FILE * input_file ) { if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ); } yy_init_buffer(YY_CURRENT_BUFFER,input_file ); yy_load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (); 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_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } YY_CURRENT_BUFFER_LVALUE = 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; } static void yy_load_buffer_state (void) { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = (yy_size_t)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 *) yyalloc(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; } /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * */ void yy_delete_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yyfree((void *) b->yy_ch_buf ); yyfree((void *) b ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) { int oerrno = errno; yy_flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ void yy_flush_buffer (YY_BUFFER_STATE b ) { 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( ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) { if (new_buffer == NULL) return; yyensure_buffer_stack(); /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ void yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ static void yyensure_buffer_stack (void) { yy_size_t num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; // After all that talk, this was set to 1 anyways... (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } } /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { 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) yyalloc(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; } /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) { return yy_scan_bytes(yystr,strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; yy_size_t i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) yyalloc(n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_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; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif static void yy_fatal_error (yyconst char* msg ) { (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. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current line number. * */ int yyget_lineno (void) { return yylineno; } /** Get the input stream. * */ FILE *yyget_in (void) { return yyin; } /** Get the output stream. * */ FILE *yyget_out (void) { return yyout; } /** Get the length of the current token. * */ yy_size_t yyget_leng (void) { return yyleng; } /** Get the current token. * */ char *yyget_text (void) { return yytext; } /** Set the current line number. * @param _line_number line number * */ void yyset_lineno (int _line_number ) { yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. * @param _in_str A readable stream. * * @see yy_switch_to_buffer */ void yyset_in (FILE * _in_str ) { yyin = _in_str ; } void yyset_out (FILE * _out_str ) { yyout = _out_str ; } int yyget_debug (void) { return yy_flex_debug; } void yyset_debug (int _bdebug ) { yy_flex_debug = _bdebug ; } static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. * This function is called from yylex_destroy(), so don't allocate here. */ (yy_buffer_stack) = 0; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; (yy_c_buf_p) = (char *) 0; (yy_init) = 0; (yy_start) = 0; /* Defined in main.c */ #ifdef YY_STDINIT yyin = stdin; yyout = stdout; #else yyin = (FILE *) 0; yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by * yylex_init() */ return 0; } /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } /* Destroy the stack itself. */ yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * yylex() is called, initialization will occur. */ yy_init_globals( ); return 0; } /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *yyalloc (yy_size_t size ) { return (void *) malloc( size ); } void *yyrealloc (void * ptr, yy_size_t size ) { /* 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 ); } void yyfree (void * ptr ) { free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 118 "scan.l" dealer/Random/0000755000401600040160000000000013204633311011566 5ustar cbecbedealer/Random/srand.c0000644000401600040160000000202110002574543013040 0ustar cbecbe/* 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.lib0000644000401600040160000006130310002574543012707 0ustar cbecbe 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/ansidecl.h0000644000401600040160000000567110002574543013536 0ustar cbecbe/* 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/__random.c0000644000401600040160000003070710002574543013523 0ustar cbecbe/* 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/Random/README0000644000401600040160000000016210002574543012451 0ustar cbecbeThis directory contains the GNU random generator stuff. Please see the files GPL and GPL.lib for copyright info. dealer/Random/GPL0000644000401600040160000004311410002574543012142 0ustar cbecbe 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/.cvsignore0000644000401600040160000000001010002574543013561 0ustar cbecbe*.o *.a dealer/Random/Makefile0000644000401600040160000000074710002574543013242 0ustar cbecbeSRC = $(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/rand.c0000644000401600040160000000223710002574543012666 0ustar cbecbe/* 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/Examples/0000755000401600040160000000000013204633311012124 5ustar cbecbedealer/Examples/Refer.stayman0000644000401600040160000000015012777466003014601 0ustar cbecbefit: 0.602564 Generated 1000000 hands Produced 234 hands Initial random seed 9 Time needed 2.116 sec dealer/Examples/Descr.yarb0000644000401600040160000000042210002574544014046 0ustar cbecbe# # 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/Descr.junkstayman0000644000401600040160000000106110002574544015455 0ustar cbecbe#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/Examples/Descr.blue_team0000644000401600040160000000107010002574544015046 0ustar cbecbe# # 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.6c0000644000401600040160000000020412777466003013435 0ustar cbecbeking drops: 0.571138 finesse: 0.747458 Generated 1000000 hands Produced 110651 hands Initial random seed 1 Time needed 2.106 sec dealer/Examples/Descr.vvga20000644000401600040160000000041610002574544014141 0ustar cbecbe# # 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/test_dealer.pl0000755000401600040160000000121212777447545015005 0ustar cbecbe#!/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`; } $seed++; } dealer/Examples/Refer.test_dealer0000644000401600040160000004054112777466003015430 0ustar cbecbeFrequency HCP N: 0 36235 1 78951 2 134871 3 246499 4 384098 5 518458 6 655816 7 804508 8 889395 9 934708 10 941861 11 893818 12 803559 13 690922 14 569156 15 442863 16 330898 17 234858 18 160298 19 103806 20 64218 21 37736 22 21048 23 11246 24 5576 25 2665 26 1161 27 486 28 194 29 58 30 25 31 8 32 1 33 0 34 0 35 0 36 0 37 0 Frequency HCP E: 0 36117 1 78963 2 136114 3 246576 4 384913 5 518225 6 654966 7 802245 8 889102 9 936735 10 941336 11 893513 12 804378 13 691017 14 568552 15 443107 16 330137 17 235803 18 160378 19 103539 20 64155 21 37797 22 21067 23 11074 24 5618 25 2672 26 1161 27 491 28 160 29 59 30 17 31 12 32 1 33 0 34 0 35 0 36 0 37 0 Frequency HCP S: 0 36302 1 79218 2 135529 3 246239 4 385315 5 518198 6 653533 7 802807 8 890534 9 934613 10 940551 11 895356 12 802000 13 690888 14 568889 15 442592 16 331644 17 237596 18 160666 19 103330 20 63746 21 38199 22 20807 23 11224 24 5532 25 2632 26 1259 27 508 28 195 29 67 30 22 31 8 32 1 33 0 34 0 35 0 36 0 37 0 Frequency HCP W: 0 36179 1 79092 2 135174 3 246556 4 383948 5 517571 6 654798 7 802988 8 889771 9 936320 10 939577 11 894946 12 802416 13 692175 14 570399 15 442539 16 331198 17 236670 18 160194 19 103295 20 64201 21 37846 22 20835 23 11093 24 5602 25 2687 26 1142 27 493 28 192 29 67 30 30 31 5 32 1 33 0 34 0 35 0 36 0 37 0 Frequency Spades N: 0 126864 1 800571 2 2060932 3 2865216 4 2382907 5 1247930 6 414700 7 88099 8 11790 9 959 10 32 11 0 12 0 13 0 Frequency Spades E: 0 127805 1 800419 2 2060665 3 2864776 4 2383490 5 1246629 6 415771 7 87934 8 11540 9 932 10 36 11 3 12 0 13 0 Frequency Spades S: 0 127937 1 799620 2 2060540 3 2860858 4 2387124 5 1247056 6 416124 7 88109 8 11645 9 932 10 54 11 1 12 0 13 0 Frequency Spades W: 0 127416 1 800469 2 2059574 3 2859600 4 2388880 5 1247036 6 416262 7 88386 8 11450 9 890 10 36 11 1 12 0 13 0 Frequency Hearts N: 0 127768 1 800207 2 2056392 3 2865039 4 2385593 5 1247823 6 416134 7 88390 8 11736 9 878 10 40 11 0 12 0 13 0 Frequency Hearts E: 0 128446 1 800531 2 2059192 3 2862852 4 2385836 5 1246931 6 414968 7 88706 8 11563 9 930 10 44 11 1 12 0 13 0 Frequency Hearts S: 0 127827 1 801108 2 2058035 3 2865805 4 2385909 5 1245143 6 415491 7 88002 8 11691 9 946 10 42 11 1 12 0 13 0 Frequency Hearts W: 0 127455 1 801183 2 2058653 3 2862740 4 2386996 5 1246671 6 415919 7 87850 8 11591 9 901 10 41 11 0 12 0 13 0 Frequency Diamonds N: 0 127450 1 801306 2 2059301 3 2864721 4 2385231 5 1246176 6 415172 7 87968 8 11682 9 965 10 28 11 0 12 0 13 0 Frequency Diamonds E: 0 127253 1 799987 2 2058514 3 2864033 4 2386752 5 1246539 6 416240 7 88076 8 11630 9 947 10 28 11 1 12 0 13 0 Frequency Diamonds S: 0 127974 1 801776 2 2055826 3 2862722 4 2387064 5 1248394 6 415466 7 88038 8 11769 9 938 10 31 11 2 12 0 13 0 Frequency Diamonds W: 0 127101 1 800627 2 2059949 3 2864719 4 2385971 5 1245647 6 415670 7 87897 8 11474 9 897 10 48 11 0 12 0 13 0 Frequency Clubs N: 0 128379 1 799820 2 2059256 3 2862649 4 2386340 5 1247175 6 415677 7 88174 8 11559 9 925 10 45 11 1 12 0 13 0 Frequency Clubs E: 0 128420 1 800203 2 2058614 3 2861238 4 2387097 5 1247201 6 416549 7 87917 8 11771 9 956 10 32 11 2 12 0 13 0 Frequency Clubs S: 0 127947 1 800024 2 2058839 3 2864416 4 2387099 5 1245296 6 416101 7 87531 8 11761 9 940 10 44 11 2 12 0 13 0 Frequency Clubs W: 0 127801 1 802197 2 2057600 3 2863785 4 2384907 5 1246598 6 416393 7 88100 8 11607 9 982 10 28 11 2 12 0 13 0 Frequency Card N SA: 0 7501074 1 2498926 Frequency Card N SK: 0 7501609 1 2498391 Frequency Card N SQ: 0 7501750 1 2498250 Frequency Card N SJ: 0 7501227 1 2498773 Frequency Card N ST: 0 7496992 1 2503008 Frequency Card N S9: 0 7499575 1 2500425 Frequency Card N S8: 0 7500290 1 2499710 Frequency Card N S7: 0 7499925 1 2500075 Frequency Card N S6: 0 7499874 1 2500126 Frequency Card N S5: 0 7501089 1 2498911 Frequency Card N S4: 0 7499404 1 2500596 Frequency Card N S3: 0 7499455 1 2500545 Frequency Card N S2: 0 7500211 1 2499789 Frequency Card N HA: 0 7498578 1 2501422 Frequency Card N HK: 0 7499061 1 2500939 Frequency Card N HQ: 0 7498799 1 2501201 Frequency Card N HJ: 0 7499047 1 2500953 Frequency Card N HT: 0 7503345 1 2496655 Frequency Card N H9: 0 7498630 1 2501370 Frequency Card N H8: 0 7500044 1 2499956 Frequency Card N H7: 0 7500675 1 2499325 Frequency Card N H6: 0 7498769 1 2501231 Frequency Card N H5: 0 7499036 1 2500964 Frequency Card N H4: 0 7499693 1 2500307 Frequency Card N H3: 0 7497431 1 2502569 Frequency Card N H2: 0 7499573 1 2500427 Frequency Card N DA: 0 7499420 1 2500580 Frequency Card N DK: 0 7500430 1 2499570 Frequency Card N DQ: 0 7501529 1 2498471 Frequency Card N DJ: 0 7501744 1 2498256 Frequency Card N DT: 0 7499314 1 2500686 Frequency Card N D9: 0 7500881 1 2499119 Frequency Card N D8: 0 7496784 1 2503216 Frequency Card N D7: 0 7501671 1 2498329 Frequency Card N D6: 0 7499629 1 2500371 Frequency Card N D5: 0 7502907 1 2497093 Frequency Card N D4: 0 7497271 1 2502729 Frequency Card N D3: 0 7501208 1 2498792 Frequency Card N D2: 0 7499508 1 2500492 Frequency Card N CA: 0 7501331 1 2498669 Frequency Card N CK: 0 7499240 1 2500760 Frequency Card N CQ: 0 7499780 1 2500220 Frequency Card N CJ: 0 7499284 1 2500716 Frequency Card N CT: 0 7499110 1 2500890 Frequency Card N C9: 0 7499716 1 2500284 Frequency Card N C8: 0 7498742 1 2501258 Frequency Card N C7: 0 7501010 1 2498990 Frequency Card N C6: 0 7501626 1 2498374 Frequency Card N C5: 0 7500235 1 2499765 Frequency Card N C4: 0 7498913 1 2501087 Frequency Card N C3: 0 7501453 1 2498547 Frequency Card N C2: 0 7499508 1 2500492 Frequency Card E SA: 0 7499318 1 2500682 Frequency Card E SK: 0 7500453 1 2499547 Frequency Card E SQ: 0 7498175 1 2501825 Frequency Card E SJ: 0 7500427 1 2499573 Frequency Card E ST: 0 7502667 1 2497333 Frequency Card E S9: 0 7501875 1 2498125 Frequency Card E S8: 0 7499802 1 2500198 Frequency Card E S7: 0 7501194 1 2498806 Frequency Card E S6: 0 7499333 1 2500667 Frequency Card E S5: 0 7500682 1 2499318 Frequency Card E S4: 0 7500846 1 2499154 Frequency Card E S3: 0 7500982 1 2499018 Frequency Card E S2: 0 7499799 1 2500201 Frequency Card E HA: 0 7499386 1 2500614 Frequency Card E HK: 0 7499507 1 2500493 Frequency Card E HQ: 0 7501681 1 2498319 Frequency Card E HJ: 0 7501181 1 2498819 Frequency Card E HT: 0 7499478 1 2500522 Frequency Card E H9: 0 7500731 1 2499269 Frequency Card E H8: 0 7500151 1 2499849 Frequency Card E H7: 0 7500729 1 2499271 Frequency Card E H6: 0 7500514 1 2499486 Frequency Card E H5: 0 7498029 1 2501971 Frequency Card E H4: 0 7501225 1 2498775 Frequency Card E H3: 0 7499007 1 2500993 Frequency Card E H2: 0 7500836 1 2499164 Frequency Card E DA: 0 7502682 1 2497318 Frequency Card E DK: 0 7500565 1 2499435 Frequency Card E DQ: 0 7500388 1 2499612 Frequency Card E DJ: 0 7499987 1 2500013 Frequency Card E DT: 0 7498568 1 2501432 Frequency Card E D9: 0 7498006 1 2501994 Frequency Card E D8: 0 7499501 1 2500499 Frequency Card E D7: 0 7499098 1 2500902 Frequency Card E D6: 0 7498104 1 2501896 Frequency Card E D5: 0 7500749 1 2499251 Frequency Card E D4: 0 7500422 1 2499578 Frequency Card E D3: 0 7496992 1 2503008 Frequency Card E D2: 0 7499401 1 2500599 Frequency Card E CA: 0 7499406 1 2500594 Frequency Card E CK: 0 7500801 1 2499199 Frequency Card E CQ: 0 7502197 1 2497803 Frequency Card E CJ: 0 7499565 1 2500435 Frequency Card E CT: 0 7498596 1 2501404 Frequency Card E C9: 0 7498500 1 2501500 Frequency Card E C8: 0 7501586 1 2498414 Frequency Card E C7: 0 7498253 1 2501747 Frequency Card E C6: 0 7498988 1 2501012 Frequency Card E C5: 0 7500029 1 2499971 Frequency Card E C4: 0 7499120 1 2500880 Frequency Card E C3: 0 7500193 1 2499807 Frequency Card E C2: 0 7499401 1 2500599 Frequency Card S SA: 0 7500237 1 2499763 Frequency Card S SK: 0 7500480 1 2499520 Frequency Card S SQ: 0 7499418 1 2500582 Frequency Card S SJ: 0 7497659 1 2502341 Frequency Card S ST: 0 7501644 1 2498356 Frequency Card S S9: 0 7498159 1 2501841 Frequency Card S S8: 0 7501944 1 2498056 Frequency Card S S7: 0 7497202 1 2502798 Frequency Card S S6: 0 7500365 1 2499635 Frequency Card S S5: 0 7498074 1 2501926 Frequency Card S S4: 0 7501366 1 2498634 Frequency Card S S3: 0 7501886 1 2498114 Frequency Card S S2: 0 7498910 1 2501090 Frequency Card S HA: 0 7502455 1 2497545 Frequency Card S HK: 0 7501285 1 2498715 Frequency Card S HQ: 0 7499253 1 2500747 Frequency Card S HJ: 0 7500591 1 2499409 Frequency Card S HT: 0 7498647 1 2501353 Frequency Card S H9: 0 7501144 1 2498856 Frequency Card S H8: 0 7499381 1 2500619 Frequency Card S H7: 0 7499930 1 2500070 Frequency Card S H6: 0 7498820 1 2501180 Frequency Card S H5: 0 7502561 1 2497439 Frequency Card S H4: 0 7500039 1 2499961 Frequency Card S H3: 0 7501340 1 2498660 Frequency Card S H2: 0 7499177 1 2500823 Frequency Card S DA: 0 7498777 1 2501223 Frequency Card S DK: 0 7496773 1 2503227 Frequency Card S DQ: 0 7497896 1 2502104 Frequency Card S DJ: 0 7499863 1 2500137 Frequency Card S DT: 0 7500605 1 2499395 Frequency Card S D9: 0 7501205 1 2498795 Frequency Card S D8: 0 7501034 1 2498966 Frequency Card S D7: 0 7498260 1 2501740 Frequency Card S D6: 0 7502371 1 2497629 Frequency Card S D5: 0 7498241 1 2501759 Frequency Card S D4: 0 7502663 1 2497337 Frequency Card S D3: 0 7499252 1 2500748 Frequency Card S D2: 0 7500113 1 2499887 Frequency Card S CA: 0 7500306 1 2499694 Frequency Card S CK: 0 7500559 1 2499441 Frequency Card S CQ: 0 7498687 1 2501313 Frequency Card S CJ: 0 7498753 1 2501247 Frequency Card S CT: 0 7501232 1 2498768 Frequency Card S C9: 0 7502332 1 2497668 Frequency Card S C8: 0 7502274 1 2497726 Frequency Card S C7: 0 7499591 1 2500409 Frequency Card S C6: 0 7499112 1 2500888 Frequency Card S C5: 0 7500613 1 2499387 Frequency Card S C4: 0 7501311 1 2498689 Frequency Card S C3: 0 7496958 1 2503042 Frequency Card S C2: 0 7500113 1 2499887 Frequency Card W SA: 0 7499371 1 2500629 Frequency Card W SK: 0 7497458 1 2502542 Frequency Card W SQ: 0 7500657 1 2499343 Frequency Card W SJ: 0 7500687 1 2499313 Frequency Card W ST: 0 7498697 1 2501303 Frequency Card W S9: 0 7500391 1 2499609 Frequency Card W S8: 0 7497964 1 2502036 Frequency Card W S7: 0 7501679 1 2498321 Frequency Card W S6: 0 7500428 1 2499572 Frequency Card W S5: 0 7500155 1 2499845 Frequency Card W S4: 0 7498384 1 2501616 Frequency Card W S3: 0 7497677 1 2502323 Frequency Card W S2: 0 7501080 1 2498920 Frequency Card W HA: 0 7499581 1 2500419 Frequency Card W HK: 0 7500147 1 2499853 Frequency Card W HQ: 0 7500267 1 2499733 Frequency Card W HJ: 0 7499181 1 2500819 Frequency Card W HT: 0 7498530 1 2501470 Frequency Card W H9: 0 7499495 1 2500505 Frequency Card W H8: 0 7500424 1 2499576 Frequency Card W H7: 0 7498666 1 2501334 Frequency Card W H6: 0 7501897 1 2498103 Frequency Card W H5: 0 7500374 1 2499626 Frequency Card W H4: 0 7499043 1 2500957 Frequency Card W H3: 0 7502222 1 2497778 Frequency Card W H2: 0 7500414 1 2499586 Frequency Card W DA: 0 7499121 1 2500879 Frequency Card W DK: 0 7502232 1 2497768 Frequency Card W DQ: 0 7500187 1 2499813 Frequency Card W DJ: 0 7498406 1 2501594 Frequency Card W DT: 0 7501513 1 2498487 Frequency Card W D9: 0 7499908 1 2500092 Frequency Card W D8: 0 7502681 1 2497319 Frequency Card W D7: 0 7500971 1 2499029 Frequency Card W D6: 0 7499896 1 2500104 Frequency Card W D5: 0 7498103 1 2501897 Frequency Card W D4: 0 7499644 1 2500356 Frequency Card W D3: 0 7502548 1 2497452 Frequency Card W D2: 0 7500978 1 2499022 Frequency Card W CA: 0 7498957 1 2501043 Frequency Card W CK: 0 7499400 1 2500600 Frequency Card W CQ: 0 7499336 1 2500664 Frequency Card W CJ: 0 7502398 1 2497602 Frequency Card W CT: 0 7501062 1 2498938 Frequency Card W C9: 0 7499452 1 2500548 Frequency Card W C8: 0 7497398 1 2502602 Frequency Card W C7: 0 7501146 1 2498854 Frequency Card W C6: 0 7500274 1 2499726 Frequency Card W C5: 0 7499123 1 2500877 Frequency Card W C4: 0 7500656 1 2499344 Frequency Card W C3: 0 7501396 1 2498604 Frequency Card W C2: 0 7500978 1 2499022 Generated 10000000 hands Produced 10000000 hands Initial random seed 10 Time needed 123.425 sec dealer/Examples/Descr.hm1dr2d0000644000401600040160000000662610002574544014366 0ustar cbecbegenerate 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.notrump0000644000401600040160000000105610002574544014621 0ustar cbecbe# 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/Refer.evaluation0000644000401600040160000000171012777466003015277 0ustar cbecbe North hands: 1. K 2 6 5 A J 8 7 2 T 9 4 3 Losers: 8 S : 1 H : 2 D : 2 C : 3 HCP: 8 S : 3 H : 0 D : 5 C : 0 Control: 3 S : 1 H : 0 D : 2 C : 0 North hands: 1. K 2 6 5 A J 8 7 2 T 9 4 3 C4: 975 S : 60 H : 0 D : 250 C : 40 tens: 1 S : 0 H : 0 D : 0 C : 1 jacks: 1 S : 0 H : 0 D : 1 C : 0 North hands: 1. K 2 6 5 A J 8 7 2 T 9 4 3 queens: 0 S : 0 H : 0 D : 0 C : 0 kings: 1 S : 1 H : 0 D : 0 C : 0 aces: 1 S : 0 H : 0 D : 1 C : 0 North hands: 1. K 2 6 5 A J 8 7 2 T 9 4 3 top2: 2 S : 1 H : 0 D : 1 C : 0 top3: 2 S : 1 H : 0 D : 1 C : 0 top4: 3 S : 1 H : 0 D : 2 C : 0 North hands: 1. K 2 6 5 A J 8 7 2 T 9 4 3 top5: 4 S : 1 H : 0 D : 2 C : 1 c13: 11 S : 4 H : 0 D : 7 C : 0 North hands: 1. K 2 6 5 A J 8 7 2 T 9 4 3 Generated 1 hands Produced 1 hands Initial random seed 4 Time needed 0.001 sec dealer/Examples/Descr.stayman0000644000401600040160000000125510002574544014572 0ustar cbecbegenerate 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/Refer.blue_team0000644000401600040160000000300012777466003015057 0ustar cbecbeA 9 4 K T 6 5 A 6 4 2 Q 9 A Q 9 7 5 K 6 4 3 2 A 8 4 A J 7 5 4 Q T 8 A 9 K J 7 3 2 K 8 2 Q J T 7 A K 5 9 A 8 3 Q 7 A Q J 3 K T 5 4 A K Q 7 3 9 4 2 7 K 9 8 3 9 2 A Q T 8 7 5 3 A 4 9 5 A K Q T 7 J 9 3 A K 9 6 Q A Q 3 K J 6 4 A T 9 3 Q 6 A K J T 9 8 7 J T 5 3 K 2 A T 8 A K J 9 Q 8 7 4 3 K 8 6 A Q 7 5 3 Q 9 6 3 5 2 K T 8 3 A 7 5 9 5 3 Q T 7 A K 2 Q J T 9 6 A K 4 9 8 A 3 K Q J 9 4 2 A K 7 4 3 8 5 2 A K 5 4 Q 5 4 3 K 2 A J K Q 9 6 4 A J 8 6 5 - A 9 4 2 K J T 8 K T 7 5 4 3 A Q 3 K J 9 7 6 2 A Q T 6 K 5 A K 3 Q T 8 K J 7 5 3 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 2 7 4 8 3 9 1 10 0 11 0 12 0 13 0 Generated 569 hands Produced 10 hands Initial random seed 2 Time needed 0.002 sec dealer/Examples/Refer.junkstayman0000644000401600040160000000062212777466003015475 0ustar cbecbe4450,7d: 0.1 4450,8d: 0.466667 4450,8M: 0.433333 Frequency : 0 17 1 13 Frequency : 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 10 8 11 9 8 10 1 11 0 12 0 13 0 Generated 1000000 hands Produced 30 hands Initial random seed 6 Time needed 2.146 sec dealer/Examples/Descr.pbn0000644000401600040160000000042510002574544013673 0ustar cbecbe# # 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/Descr.you_hold0000644000401600040160000000141710002574544014740 0ustar cbecbe# # 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.vvga20000644000401600040160000000014512777466003014156 0ustar cbecbe3.08456 Generated 1000000 hands Produced 20187 hands Initial random seed 11 Time needed 1.345 sec dealer/Examples/Refer.yarb0000644000401600040160000000205112777466003014064 0ustar cbecbe North hands: 1. 2. 3. 4. 4 2 3 2 9 5 4 2 8 7 4 2 8 7 5 4 3 9 7 5 4 9 6 8 5 3 2 6 5 4 8 7 6 5 4 7 4 3 8 6 4 2 4 3 2 7 6 7 6 3 2 6 5. 6. 7. 8. 8 7 8 5 4 3 8 6 3 9 7 5 2 9 7 4 3 2 6 5 3 2 9 5 4 3 2 9 6 3 8 6 3 9 2 7 3 6 5 9 4 3 8 5 3 8 5 2 8 6 5 2 9. 10. 8 7 6 5 2 8 3 8 6 5 3 2 4 3 5 4 8 7 6 5 4 2 7 4 3 2 Frequency : 0 10 1 0 2 0 3 0 4 0 5 0 Generated 22189 hands Produced 10 hands Initial random seed 13 Time needed 0.036 sec dealer/Examples/Refer.you_hold0000644000401600040160000001554412777466003014764 0ustar cbecbe 1. K 9 3 T 8 7 6 A Q 5 4 2 J T 6 3 5 4 K J 8 7 A Q 9 2 K Q T 8 7 5 4 J 9 6 3 2 A - Q T 4 2 A K J 9 8 7 6 5 3 2. K 3 J 6 A Q 5 4 2 T 9 8 7 9 3 6 5 4 2 K J 8 7 A Q T A J T 9 5 4 7 6 3 2 K Q 8 J 9 5 T 8 7 4 3 A K Q 6 2 3. 8 3 T 7 A Q 5 4 2 K J 9 6 A 3 Q 9 6 5 4 2 K J 8 7 T K T 9 8 7 4 J 3 2 A Q 6 5 9 6 5 J 8 4 2 A K Q T 7 3 4. 9 8 3 J T A Q 5 4 2 K 7 6 T 9 6 5 4 K J 8 7 A Q 3 2 K Q J 8 6 5 T 7 4 3 2 A 9 7 4 Q J 6 3 2 A K T 9 8 5 5. T J 9 7 6 3 A Q 5 4 2 K 8 Q 4 A T 6 5 3 K J 8 7 9 2 K J T 9 7 5 4 - 3 2 A Q 8 6 9 8 7 T 6 4 A K Q J 5 3 2 6. 8 7 J T 6 3 A Q 5 4 2 K 9 T 2 Q 9 4 3 K J 8 7 A 6 5 A K T 7 6 4 J 9 3 2 Q 8 5 T 6 3 9 8 2 A K Q J 7 5 4 7. 9 3 7 6 A Q 5 4 2 K J T 8 Q 5 2 T 9 6 K J 8 7 A 4 3 A Q T 9 8 6 J 5 4 3 2 K 7 3 2 T 9 8 7 5 A K Q J 6 4 8. J 7 6 K 8 3 A Q 5 4 2 T 9 5 T 9 4 3 K J 8 7 A Q 6 2 K Q J T 9 7 4 6 5 3 2 A 8 6 2 J T 8 5 A K Q 9 7 4 3 9. 9 8 7 J T 3 A Q 5 4 2 K 6 A 9 5 Q 6 4 2 K J 8 7 T 3 Q 9 8 7 6 5 J T 3 2 A K 4 8 Q 6 4 3 A K J T 9 7 5 2 10. 8 T 9 7 3 A Q 5 4 2 K J 6 9 5 2 6 4 K J 8 7 A Q T 3 A K J 7 5 4 9 6 3 2 Q T 8 6 5 3 Q J 8 4 2 A K T 9 7 11. K 8 6 J 9 3 A Q 5 4 2 T 7 A T 6 Q 9 3 K J 8 7 5 4 2 Q T 9 8 6 5 7 3 2 A K J 4 2 T 8 7 6 5 4 A K Q J 9 3 12. 7 3 K J 8 A Q 5 4 2 T 9 6 Q T 9 6 4 K J 8 7 A 5 3 2 A T 9 8 7 6 5 J 4 3 2 K Q 9 7 4 J T 8 3 A K Q 6 5 2 13. K 7 3 T 9 8 6 A Q 5 4 2 J T 4 2 Q 9 6 3 K J 8 7 A 5 K 9 8 6 5 4 T 3 2 A Q J 7 2 6 5 4 3 A K Q J T 9 8 7 14. 6 3 8 7 A Q 5 4 2 K J T 9 Q T 6 4 3 2 K J 8 7 A 9 5 K J 8 7 6 4 9 5 3 2 A Q T Q J 6 9 8 7 5 4 A K T 3 2 15. K T 3 J 8 7 6 A Q 5 4 2 9 4 Q T 9 3 K J 8 7 A 6 5 2 A T 7 6 5 4 J 3 2 K Q 9 8 T 9 7 J 5 3 2 A K Q 8 6 4 16. K T 9 7 6 3 A Q 5 4 2 J 8 Q 5 2 9 6 4 3 K J 8 7 A T A T 9 8 7 4 J 5 3 2 K Q 6 J T 8 5 2 A K Q 9 7 6 4 3 17. 6 3 K 7 A Q 5 4 2 J T 9 8 Q 6 3 5 4 2 K J 8 7 A T 9 K Q T 7 6 5 8 4 3 2 A J 9 T 9 J 7 6 5 4 2 A K Q 8 3 18. 8 J T 7 6 A Q 5 4 2 K 9 3 T 5 4 9 6 3 K J 8 7 A Q 2 A K T 9 7 5 6 4 3 2 Q J 8 T 6 3 Q J 4 2 A K 9 8 7 5 19. 8 3 T 9 6 A Q 5 4 2 K J 7 6 3 A T 9 5 4 K J 8 7 Q 2 A K J T 7 5 4 9 6 3 2 Q 8 3 2 9 7 6 A K Q J T 8 5 4 20. 8 3 T 9 6 A Q 5 4 2 K J 7 A 9 3 T 6 4 2 K J 8 7 Q 5 K 9 8 7 5 4 Q 3 2 A J T 6 T 4 J 9 8 5 3 A K Q 7 6 2 21. K T 8 6 3 A Q 5 4 2 J 9 7 5 4 Q T 6 K J 8 7 A 9 3 2 A Q T 7 6 4 8 5 3 2 K J 9 J 7 5 9 6 4 3 2 A K Q T 8 22. J 8 3 9 7 6 A Q 5 4 2 K T A Q 9 6 5 4 3 K J 8 7 T 2 J T 8 7 6 5 4 Q 9 3 2 A K 4 3 T 8 A K Q J 9 7 6 5 2 23. 7 T 8 6 3 A Q 5 4 2 K J 9 Q T 9 5 2 K J 8 7 A 6 4 3 A Q T 9 8 7 4 J 6 5 3 2 K J 5 Q 8 6 2 A K T 9 7 4 3 24. 3 J T 9 8 A Q 5 4 2 K 7 6 Q 5 3 9 2 K J 8 7 A T 6 4 K J T 8 7 6 Q 9 5 4 3 2 A J 8 4 Q T 7 A K 9 6 5 3 2 25. 8 6 K T 7 A Q 5 4 2 J 9 3 T 6 3 9 5 2 K J 8 7 A Q 4 A K J T 9 7 5 4 3 2 Q 8 6 T 5 J 8 7 4 3 A K Q 9 6 2 Generated 8040 hands Produced 25 hands Initial random seed 14 Time needed 0.016 sec dealer/Examples/Descr.test_dealer0000644000401600040160000003336410002574544015417 0ustar cbecbe# # 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.6c0000644000401600040160000000131710002574544013425 0ustar cbecbe# 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.weaktwo0000644000401600040160000000045512777466003014616 0ustar cbecbeFrequency points: 5 1303 6 1566 7 2168 8 1911 9 2280 10 1942 11 1997 hearts: 2.32468 Ace of spades: 0.546518 Jack of spades: 0.472849 Heart fit: 0.141186 Generated 1000000 hands Produced 13167 hands Initial random seed 12 Time needed 2.114 sec dealer/Examples/.cvsignore0000644000401600040160000000001110002574544014121 0ustar cbecbeOutput.* dealer/Examples/Refer.hm1dr2d0000644000401600040160000000026412777466003014374 0ustar cbecbee3352: 0 Frequency spades: 0 1128 1 15986 2 82886 3 0 Generated 8248213 hands Produced 100000 hands Initial random seed 5 Time needed 18.933 sec dealer/Examples/Descr.weaktwo0000644000401600040160000000106110002574544014572 0ustar cbecbe# 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/convert.pl0000755000401600040160000000736412777451517014202 0ustar cbecbe#!/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 ("%5.2f ", $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/Makefile0000644000401600040160000000121612777450077013610 0ustar cbecbe# # 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 # 10 minutes to run. # DEALER = ../dealer 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/Descr.controls0000644000401600040160000000040310002574544014753 0ustar cbecbe# 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/Descr.evaluation0000644000401600040160000000543210002574544015266 0ustar cbecbe# 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/Refer.pbn0000644000401600040160000000612512777466003013714 0ustar cbecbe[Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "1"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:A963.5432.J972.A QJ752.J.KT3.Q753 .QT76.Q654.JT986 KT84.AK98.A8.K42"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "2"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:J42.8642.K.KJT86 T9.75.QJ764.AQ43 A8653.Q.T9532.75 KQ7.AKJT93.A8.92"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "3"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:QJT2.K73.T2.AT76 9.AQ92.QJ96.QJ53 8765.JT864.87.82 AK43.5.AK543.K94"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "4"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:J85.J9874.QT4.A7 K93.653.K92.QT94 Q74.KT.J875.J865 AT62.AQ2.A63.K32"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "5"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:KQ3.T863.983.963 J84.Q4.AJ52.T872 75.AJ972.764.Q54 AT962.K5.KQT.AKJ"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "6"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:KT87.2.Q9642.AQJ Q2.KJ643.K83.T94 J9643.T85.J5.865 A5.AQ97.AT7.K732"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "7"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:T953.KJ976.K7.76 A.Q52.QT9.QJ9852 QJ8742.8.6542.T3 K6.AT43.AJ83.AK4"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "8"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:JT87.QT5.A6.K853 52.J9.QT98.AJT96 64.8632.J542.Q74 AKQ93.AK74.K73.2"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "9"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:A2.AJ9872.864.A4 QJ74.T5.K2.KT862 9653.643.T97.J95 KT8.KQ.AQJ53.Q73"] [Declarer "?"] [Contract "?"] [Result "?"] [Event "Hand simulated by dealer with file Descr.pbn, seed 8"] [Site "-"] [Date "2016.10.12"] [Board "10"] [West "-"] [North "-"] [East "-"] [South "-"] [Dealer "N"] [Vulnerable "All"] [Deal "N:J73.Q72.K743.KJ7 QT86.5.AT5.QT985 4.KJT8643.J2.432 AK952.A9.Q986.A6"] [Declarer "?"] [Contract "?"] [Result "?"] Generated 1432 hands Produced 10 hands Initial random seed 8 Time needed 0.006 sec dealer/Examples/Refer.distribution0000644000401600040160000001753612777466003015664 0ustar cbecbeGenerated 1000000 hands HCP Distribution ================ # N E S W % diff % diff % diff % diff 0 0.36 0.00 0.36 -0.00 0.37 0.01 0.36 -0.00 0.36 1 0.79 -0.00 0.78 -0.01 0.79 -0.00 0.80 0.01 0.79 2 1.35 0.00 1.35 0.00 1.36 0.01 1.34 -0.01 1.35 3 2.48 0.02 2.48 0.02 2.47 0.01 2.48 0.02 2.46 4 3.85 0.00 3.84 -0.01 3.85 0.00 3.87 0.02 3.85 5 5.19 0.00 5.14 -0.05 5.17 -0.02 5.20 0.01 5.19 6 6.59 0.04 6.53 -0.02 6.60 0.05 6.57 0.02 6.55 7 8.00 -0.03 8.03 -0.00 7.95 -0.08 8.01 -0.02 8.03 8 8.92 0.03 8.89 0.00 8.90 0.01 8.83 -0.06 8.89 9 9.43 0.07 9.35 -0.01 9.38 0.02 9.35 -0.01 9.36 10 9.40 -0.01 9.41 0.00 9.39 -0.02 9.40 -0.01 9.41 11 8.91 -0.03 8.99 0.05 8.93 -0.01 8.95 0.01 8.94 12 7.98 -0.05 8.01 -0.02 8.05 0.02 8.04 0.01 8.03 13 6.92 0.01 6.92 0.01 6.91 -0.00 6.91 0.00 6.91 14 5.69 -0.00 5.69 0.00 5.69 -0.00 5.71 0.02 5.69 15 4.42 -0.00 4.44 0.02 4.42 0.00 4.42 0.00 4.42 16 3.29 -0.02 3.29 -0.02 3.32 0.01 3.32 0.01 3.31 17 2.35 -0.01 2.38 0.02 2.35 -0.01 2.36 -0.00 2.36 18 1.60 -0.01 1.63 0.02 1.62 0.01 1.61 -0.00 1.61 19 1.03 -0.01 1.03 -0.01 1.04 -0.00 1.03 -0.01 1.04 20 0.64 -0.00 0.66 0.02 0.65 0.01 0.64 -0.00 0.64 21 0.38 0.00 0.38 -0.00 0.38 -0.00 0.37 -0.01 0.38 22 0.22 0.01 0.21 0.00 0.21 0.00 0.22 0.01 0.21 23 0.11 0.00 0.12 0.01 0.11 0.00 0.11 0.00 0.11 24 0.05 -0.01 0.05 -0.01 0.06 -0.00 0.06 -0.00 0.06 25 0.03 -0.00 0.02 -0.01 0.03 -0.00 0.03 -0.00 0.03 26 0.01 0.00 0.01 0.00 0.01 0.00 0.01 0.00 0.01 27 0.01 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 28 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 29 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 30 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 31 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 32 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 33 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 34 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 35 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 36 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 37 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Spades Distribution ===================== # N E S W % diff % diff % diff % diff 0 1.27 -0.005 1.26 -0.013 1.26 -0.010 1.29 0.020 1.27 1 8.06 0.053 7.95 -0.055 7.96 -0.048 7.97 -0.040 8.01 2 20.62 0.025 20.62 0.028 20.59 0.004 20.56 -0.029 20.59 3 28.59 -0.041 28.69 0.057 28.64 0.009 28.74 0.107 28.63 4 23.86 -0.014 23.88 0.014 23.90 0.034 23.88 0.010 23.87 5 12.47 0.005 12.46 -0.010 12.48 0.013 12.40 -0.074 12.47 6 4.14 -0.017 4.13 -0.027 4.15 -0.006 4.16 -0.004 4.16 7 0.87 -0.008 0.88 -0.004 0.88 -0.000 0.88 0.004 0.88 8 0.11 -0.007 0.12 -0.001 0.12 -0.003 0.12 -0.003 0.12 9 0.01 -0.001 0.01 -0.000 0.01 -0.003 0.01 -0.001 0.01 10 0.00 0.000 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 Hearts Distribution ===================== # N E S W % diff % diff % diff % diff 0 1.28 0.009 1.27 -0.002 1.28 0.012 1.26 -0.008 1.27 1 7.98 -0.031 8.03 0.017 8.04 0.026 7.99 -0.019 8.01 2 20.61 0.016 20.52 -0.066 20.61 0.025 20.60 0.014 20.59 3 28.57 -0.061 28.70 0.069 28.63 0.005 28.64 0.005 28.63 4 23.86 -0.006 23.89 0.022 23.84 -0.035 23.91 0.038 23.87 5 12.52 0.045 12.46 -0.015 12.45 -0.016 12.44 -0.026 12.47 6 4.17 0.014 4.14 -0.022 4.13 -0.027 4.14 -0.017 4.16 7 0.89 0.005 0.87 -0.007 0.89 0.005 0.89 0.005 0.88 8 0.12 -0.001 0.12 -0.003 0.12 -0.003 0.12 -0.002 0.12 9 0.01 -0.000 0.01 -0.002 0.01 -0.002 0.01 -0.001 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 Diamonds Distribution ===================== # N E S W % diff % diff % diff % diff 0 1.28 0.014 1.27 0.001 1.28 0.008 1.28 0.008 1.27 1 8.00 -0.006 8.02 0.012 8.02 0.013 8.03 0.024 8.01 2 20.51 -0.076 20.61 0.016 20.60 0.006 20.58 -0.014 20.59 3 28.69 0.061 28.66 0.028 28.62 -0.013 28.57 -0.055 28.63 4 23.91 0.040 23.85 -0.024 23.85 -0.025 23.86 -0.006 23.87 5 12.43 -0.045 12.42 -0.050 12.46 -0.010 12.47 -0.004 12.47 6 4.17 0.012 4.17 0.012 4.18 0.015 4.19 0.033 4.16 7 0.88 0.004 0.87 -0.007 0.88 0.002 0.88 0.005 0.88 8 0.11 -0.012 0.12 0.002 0.12 -0.004 0.12 -0.001 0.12 9 0.01 -0.002 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.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 Clubs Distribution ===================== # N E S W % diff % diff % diff % diff 0 1.28 0.007 1.30 0.026 1.28 0.015 1.28 0.010 1.27 1 8.01 0.005 8.00 -0.015 8.01 -0.000 8.05 0.040 8.01 2 20.57 -0.020 20.58 -0.013 20.61 0.023 20.53 -0.058 20.59 3 28.65 0.021 28.60 -0.032 28.60 -0.026 28.67 0.042 28.63 4 23.88 0.005 23.83 -0.038 23.83 -0.045 23.85 -0.023 23.87 5 12.46 -0.010 12.55 0.081 12.43 -0.038 12.46 -0.010 12.47 6 4.15 -0.005 4.14 -0.019 4.21 0.052 4.15 -0.014 4.16 7 0.87 -0.008 0.88 0.000 0.89 0.009 0.88 0.005 0.88 8 0.11 -0.006 0.12 -0.002 0.12 0.000 0.12 -0.001 0.12 9 0.01 0.000 0.01 0.000 0.01 -0.001 0.01 -0.002 0.01 10 0.00 0.000 0.00 0.000 0.00 0.001 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 Individual Cards ================ Spades Hearts Diamonds Clubs # N E S W N E S W N E S W N E S W 2 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 3 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 4 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 5 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 6 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 7 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 8 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 9 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 T -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 J -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 Q -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 K -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 A -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 -25.00 dealer/Examples/Refer.controls0000644000401600040160000000046312777466003014777 0ustar cbecbeFrequency controls: 0 0 1 0 2 0 3 0 4 25 5 296 6 1683 7 3536 8 3414 9 967 10 79 11 0 12 0 Generated 1556485 hands Produced 10000 hands Initial random seed 3 Time needed 2.368 sec dealer/Examples/Test.distribution0000644000401600040160000000270712777452134015532 0ustar cbecbe# # 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), dealer/Examples/Refer.notrump0000644000401600040160000006152512777466003014646 0ustar cbecben 84.AQ42.T63.Q965 e QJ6.J75.AQJ.AJ83 s 32.KT86.K984.K72 w AKT975.93.752.T4 n J63.T876.J765.74 e A95.94.AKT.A8532 s QT2.AKJ52.Q3.QJ9 w K874.Q3.9842.KT6 n Q874.QT7.K74.862 e T5.AK53.AJ63.A95 s K93.J986.Q9.QJT4 w AJ62.42.T852.K73 n JT7.KJT93..Q7543 e AK2.Q6.QT9.A9862 s Q98654.A82.AJ2.T w 3.754.K876543.KJ n 763.KT97.T63.T74 e A95.A432.KQ2.KJ9 s JT84.QJ6.J94.AQ5 w KQ2.85.A875.8632 n T643.JT9.AK5.KT4 e K7.KQ5.QT94.AJ53 s Q982.86.J63.Q972 w AJ5.A7432.872.86 n J95.3.KT9654.742 e K72.KT64.Q832.AK s AT83.Q95.A.QJT96 w Q64.AJ872.J7.853 n A62.J764.92.9876 e T98.AQ5.Q64.AKT2 s Q74.T93.AKJ83.QJ w KJ53.K82.T75.543 n AJ85.92.AJT9.T92 e Q6.KQ43.Q86.AKJ7 s KT74.JT65.75.864 w 932.A87.K432.Q53 n J8753.T62.2.QJ32 e AK96.A9.J94.A964 s T4.K53.KQT53.K87 w Q2.QJ874.A876.T5 n J872.Q72.AK7.T93 e AT63.A83.T96.AK8 s KQ54.654.543.J65 w 9.KJT9.QJ82.Q742 n T3.843.742.QJT95 e AK74.AQ7.QJ96.74 s 986.K95.AK53.K32 w QJ52.JT62.T8.A86 n 9.Q82.KJ8632.K42 e AKJ.AJ9.95.QT973 s 87632.43.Q4.AJ86 w QT54.KT765.AT7.5 n K92.Q63.98.K8732 e AQJ8.KJ72.KQ4.T9 s 73.T954.AJT7.Q65 w T654.A8.6532.AJ4 n KT95.J62.QJ4.754 e A64.Q95.A963.AK3 s 832.AK743.7.J982 w QJ7.T8.KT852.QT6 n J4.J94.AJ74.A743 e Q83.AK75.KQ.K965 s AT965.8.T9862.J8 w K72.QT632.53.QT2 n 76.74.QJT932.Q32 e K94.AK5.AK64.T65 s J832.JT982.875.J w AQT5.Q63..AK9874 n QJ975.QT973.65.6 e T8.AKJ.AJT92.K75 s A42.854.K43.QJT4 w K63.62.Q87.A9832 n QJT7.A94.T75.T98 e 65.KJ2.AQ32.KQ43 s K9832.Q753.KJ4.7 w A4.T86.986.AJ652 n T974.J74.T7.QJ98 e Q5.AT2.Q853.AK63 s J8632.5.A942.742 w AK.KQ9863.KJ6.T5 n J653.A75.84.JT72 e QT.KJT6.AK5.A943 s 42.Q43.QJ973.K65 w AK987.982.T62.Q8 n 8.K432.J9752.AK6 e AKQ7.A987.T6.QT4 s JT.JT6.A83.97532 w 965432.Q5.KQ4.J8 n T652.K8.7432.T87 e KJ3.652.Q98.AKQ5 s 974.AQ974.T6.J62 w AQ8.JT3.AKJ5.943 n A64.K42.T8732.87 e K752.Q83.AQ4.A65 s J8.JT96.J65.Q432 w QT93.A75.K9.KJT9 n J85.KQJ65.KJ.A65 e KQ97.A87.AQ94.T4 s T63.932.62.QJ973 w A42.T4.T8753.K82 n J9532.J3.763.976 e AQ.852.AQJ8.QT53 s T64.K94.KT9542.2 w K87.AQT76..AKJ84 n K982.KQ7.K65.976 e 65.J43.AQ974.AKJ s AJT4.T5.T32.Q854 w Q73.A9862.J8.T32 n 74.T743.KJT.T432 e AK5.J52.54.AKJ97 s JT8.AQ96.Q2.Q865 w Q9632.K8.A98763. n T742.42.QJ7.8642 e K953.KJ3.K94.AJ7 s 86.A976.865.K953 w AQJ.QT85.AT32.QT n 985.A93.JT752.T9 e KQ42.KQ5.Q83.A63 s AJT6.J7642..KJ85 w 73.T8.AK964.Q742 n A72.T4.T87532.K6 e QT4.Q93.AK6.AJ87 s KJ86.A8752.9.Q94 w 953.KJ6.QJ4.T532 n JT9.AT6.KQJ5.984 e K843.KQ7.A84.KT2 s 765.85.T76.AQ765 w AQ2.J9432.932.J3 n 86.AQT976.92.T54 e K73.K5.Q876.AK86 s J954.J842.AKJ3.3 w AQT2.3.T54.QJ972 n 75.764.T74.QT843 e AJT4.Q32.AK52.J5 s Q863.KT9.J986.62 w K92.AJ85.Q3.AK97 n T3.J965.6.A98653 e AK96.A84.852.KJ7 s QJ82.QT2.AKT3.42 w 754.K73.QJ974.QT n T72.T65432.64.95 e K84.KJ8.KQJ8.QT3 s J953.A97.732.AJ4 w AQ6.Q.AT95.K8762 n J4.QJ95.9742.Q53 e AT9.A8.AJ63.A642 s 873.K764.K85.KJ7 w KQ652.T32.QT.T98 n KJ6432.T4.K6.Q43 e AQT5.Q5.A432.AT2 s 7.976.QT95.98765 w 98.AKJ832.J87.KJ n 732.832.53.AT965 e Q65.QJ7.AJ6.KQ32 s KT98.95.982.J874 w AJ4.AKT64.KQT74. n 86432.AJ7.J.KQ94 e AK95.854.A9.AJ86 s J.963.KT6532.T72 w QT7.KQT2.Q874.53 n A63.QT86.KQ6.T42 e KQJT.AJ4.A32.Q93 s 852.K732.T854.J7 w 974.95.J97.AK865 n K943.Q5.Q95.J984 e A752.T97.AK3.KQ7 s J8.J8632.T876.T6 w QT6.AK4.J42.A532 n 76542.J963.T4.KJ e AK3.Q8.KJ6.A9863 s QJ8.K752.Q97.QT2 w T9.AT4.A8532.754 n AKT864.3.642.AT4 e 72.KQ86.KQ85.KQ7 s QJ953.JT72.J93.3 w .A954.AT7.J98652 n Q63.KJ.JT97.Q863 e JT82.A84.AKQ.JT2 s A95.9653.8632.A9 w K74.QT72.54.K754 n QJ43.654.AJ4.953 e A6.KQ83.Q985.AQ4 s T72.AT72.KT32.87 w K985.J9.76.KJT62 n T97.J852.864.AK5 e A2.K763.AKJ5.JT8 s KQ53.94.T73.Q943 w J864.AQT.Q92.762 n 9.Q9852.T873.J32 e 8543.AKT.AQ54.A6 s AKQJT2.6.96.K854 w 76.J743.KJ2.QT97 n Q53.AJ95.J7.JT94 e A9.KT2.AK85.K753 s KJ87.Q8764.T32.6 w T642.3.Q964.AQ82 n K3.K87.A7642.K75 e AQJ6.Q962.Q9.AJT s T8754.54.J5.Q842 w 92.AJT3.KT83.963 n KT82.KQJ95.Q6.96 e A943.T4.AK95.A84 s J7.872.84.KJT732 w Q65.A63.JT732.Q5 n J7.72.QJT643.K52 e AK53.A63.A85.T63 s 62.KQ84.K7.Q9874 w QT984.JT95.92.AJ n JT2.AQ94.Q9.A873 e A83.85.AK73.KQT6 s Q974.J762.82.J42 w K65.KT3.JT654.95 n T876.963.532.AQ8 e J3.KQJ.KQJT.KJ94 s 952.T85.9876.763 w AKQ4.A742.A4.T52 n 64.KQ4.J9876.J83 e K92.A952.Q5.AQT5 s QT8.T83.T43.K742 w AJ753.J76.AK2.96 n KT72.963.QT543.4 e AQ6.82.A96.AJ765 s 98543.K74.7.T983 w J.AQJT5.KJ82.KQ2 n AJ97532.87.76.J8 e Q84.KT92.KJ9.AQ6 s T.J6543.T843.K92 w K6.AQ.AQ52.T7543 n T8764.943.JT9.J3 e J93.KJ5.KQ8.AQ92 s AKQ.QT72.A54.874 w 52.A86.7632.KT65 n T632.J62.QT762.T e AQ8.KQ5.543.A832 s J954.T874.KJ.974 w K7.A93.A98.KQJ65 n 2.KJ986.K954.QT5 e QJ87.AT2.Q8.AK42 s T53.3.AJT76.J863 w AK964.Q754.32.97 n J87.87632.Q75.KT e 9632.AQJ.A3.A973 s K4.KT5.KJ642.J86 w AQT5.94.T98.Q542 n 2.A9.QT985.KJ752 e AKJ5.T42.K72.AQ3 s Q987643.Q853..T4 w T.KJ76.AJ643.986 n 9.KT2.KQJT64.943 e K4.A74.A532.A762 s AQT8762.Q953.97. w J53.J86.8.KQJT85 n Q53.QJ863.KJ.A43 e A8.AK92.Q82.Q987 s 962.T7.654.KJT52 w KJT74.54.AT973.6 n J3.642.J64.QT873 e K75.AK83.Q93.K54 s AQT86.Q95.A72.92 w 942.JT7.KT85.AJ6 n Q98.742.J94.T874 e AT64.AK6.A876.52 s 752.J8.KQ5.AKQ93 w KJ3.QT953.T32.J6 n 965.972.9853.Q73 e J3.KQT.J76.AKJ64 s KQ42.AJ.KQT.T952 w AT87.86543.A42.8 n KT9.J3.J64.T7632 e AQ52.Q75.Q72.AK5 s J8763.K.A853.Q98 w 4.AT98642.KT9.J4 n K9854.A.AT42.Q85 e AQT2.K76.Q8.A963 s 763.Q5432.3.JT42 w J.JT98.KJ9765.K7 n Q98.A763.QT953.6 e 642.QJ8.AKJ62.AJ s AKJ73.T9.84.T952 w T5.K542.7.KQ8743 n A9432.K6.A.QJ985 e KQ86.AJT.KT9.A63 s 75.854.Q6542.T74 w JT.Q9732.J873.K2 n QJ8.982.752.K863 e AK96.KQ54.KQ3.T7 s 5.AJT76.AT986.54 w T7432.3.J4.AQJ92 n AT9876.K.KJ73.J3 e KQ5.Q94.A4.A7654 s 2.JT72.QT98.QT82 w J43.A8653.652.K9 n K863..A43.K86542 e AJ.AQT3.QJ9.J973 s 95.KJ8764.K865.T w QT742.952.T72.AQ n Q82.J73.Q742.863 e AK74.AQ85.T95.KT s 9653.T4.AK3.A974 w JT.K962.J86.QJ52 n JT76.J7.953.KT64 e A8.Q98.AJ64.AQ98 s K943.65432.Q8.52 w Q52.AKT.KT72.J73 n 8753.K53.72.9873 e AJ42.A64.Q65.KJ4 s KQ.QJ9872.JT8.52 w T96.T.AK943.AQT6 n KT6.JT42.J9832.4 e A743.K86.AKQ6.95 s 9852.Q95.T54.J72 w QJ.A73.7.AKQT863 n 65.JT32.T.AKQT85 e A7.AK4.AJ872.976 s J9843.65.K543.J4 w KQT2.Q987.Q96.32 n K9732.4.T862.A32 e T4.AK75.KJ73.KQ5 s QJ6.93.AQ954.T84 w A85.QJT862..J976 n T9843.J532.76.72 e AK76.A86.QJ.QJT9 s 52.QT974.8.AK865 w QJ.K.AKT95432.43 n JT64.KQJ3.K96.K6 e AK3.T8.JT52.AQJ9 s Q752.7654.Q8.T82 w 98.A92.A743.7543 n 9873.T2.A762.T96 e AK4.A86.KT85.Q82 s QJ2.Q4.J9.AJ7543 w T65.KJ9753.Q43.K n J754.T9.5.AJT974 e AT3.Q76.AKT9.K82 s KQ96.AJ3.J7632.6 w 82.K8542.Q84.Q53 n T.J642.JT432.Q97 e Q64.A73.AKQ87.T2 s AJ752.KT9.65.AJ5 w K983.Q85.9.K8643 n KT987.J75.J96.KQ e J3.K92.AK2.A8532 s A54.QT86.543.J64 w Q62.A43.QT87.T97 n AT.Q753.QT753.84 e J854.AK94.KJ9.A2 s K932.JT86.A.7653 w Q76.2.8642.KQJT9 n A98.865.KQ642.42 e KJT2.J743.A8.AQ9 s Q7643.KQT9.JT7.3 w 5.A2.953.KJT8765 n 9862.53.AJ87.T73 e AKJ.98.KQ654.KJ6 s QT7.AJ642.T3.Q42 w 543.KQT7.92.A985 n 987432.J8.K52.J4 e KJ5.A75.Q73.AQ83 s A6.K9642.T94.K95 w QT.QT3.AJ86.T762 n 98532.T5.T94.654 e AK7.QJ6.63.AQJT3 s 4.AK874.A75.K972 w QJT6.932.KQJ82.8 n Q54.654.J3.AT976 e 97.AJ83.AKT4.KJ4 s KJT8632.QT.52.Q3 w A.K972.Q9876.852 n JT3.65.K96.QT943 e 985.AJ.AQJ54.A65 s Q764.KQT732.2.K8 w AK2.984.T873.J72 n 875.32.Q652.K974 e AQJ3.AKQ4.98.T62 s T.J9765.A4.AQJ53 w K9642.T8.KJT73.8 n 3.A85.QJT9872.K5 e AK82.JT6.AK65.86 s T764.9432.3.J942 w QJ95.KQ7.4.AQT73 n KT986.K.94.AQJ52 e AQ5.74.AKQ65.864 s J732.QJ9832.T8.3 w 4.AT65.J732.KT97 n 9752.K86.AJ986.4 e AQJT.AJ52.Q42.Q9 s 4.Q94.T5.J876532 w K863.T73.K73.AKT n AQT54.98.KQ983.9 e KJ3.J64.AJT.KQT5 s 6.T7.7654.J76432 w 9872.AKQ532.2.A8 n JT87.T97.T.K9874 e A32.6432.AK32.AJ s 965.A8.J9875.Q62 w KQ4.KQJ5.Q64.T53 n 53.84.AJ832.KT73 e KQ87.AK92.65.A86 s AT964.Q6.Q9.J952 w J2.JT753.KT74.Q4 East hands: 1. 2. 3. 4. Q J 6 A 9 5 T 5 A K 2 J 7 5 9 4 A K 5 3 Q 6 A Q J A K T A J 6 3 Q T 9 A J 8 3 A 8 5 3 2 A 9 5 A 9 8 6 2 5. 6. 7. 8. A 9 5 K 7 K 7 2 T 9 8 A 4 3 2 K Q 5 K T 6 4 A Q 5 K Q 2 Q T 9 4 Q 8 3 2 Q 6 4 K J 9 A J 5 3 A K A K T 2 9. 10. 11. 12. Q 6 A K 9 6 A T 6 3 A K 7 4 K Q 4 3 A 9 A 8 3 A Q 7 Q 8 6 J 9 4 T 9 6 Q J 9 6 A K J 7 A 9 6 4 A K 8 7 4 13. 14. 15. 16. A K J A Q J 8 A 6 4 Q 8 3 A J 9 K J 7 2 Q 9 5 A K 7 5 9 5 K Q 4 A 9 6 3 K Q Q T 9 7 3 T 9 A K 3 K 9 6 5 17. 18. 19. 20. K 9 4 T 8 6 5 Q 5 A K 5 A K J K J 2 A T 2 A K 6 4 A J T 9 2 A Q 3 2 Q 8 5 3 T 6 5 K 7 5 K Q 4 3 A K 6 3 21. 22. 23. 24. Q T A K Q 7 K J 3 K 7 5 2 K J T 6 A 9 8 7 6 5 2 Q 8 3 A K 5 T 6 Q 9 8 A Q 4 A 9 4 3 Q T 4 A K Q 5 A 6 5 25. 26. 27. 28. K Q 9 7 A Q 6 5 A K 5 A 8 7 8 5 2 J 4 3 J 5 2 A Q 9 4 A Q J 8 A Q 9 7 4 5 4 T 4 Q T 5 3 A K J A K J 9 7 29. 30. 31. 32. K 9 5 3 K Q 4 2 Q T 4 K 8 4 3 K J 3 K Q 5 Q 9 3 K Q 7 K 9 4 Q 8 3 A K 6 A 8 4 A J 7 A 6 3 A J 8 7 K T 2 33. 34. 35. 36. K 7 3 A J T 4 A K 9 6 K 8 4 K 5 Q 3 2 A 8 4 K J 8 Q 8 7 6 A K 5 2 8 5 2 K Q J 8 A K 8 6 J 5 K J 7 Q T 3 37. 38. 39. 40. A T 9 A Q T 5 Q 6 5 A K 9 5 A 8 Q 5 Q J 7 8 5 4 A J 6 3 A 4 3 2 A J 6 A 9 A 6 4 2 A T 2 K Q 3 2 A J 8 6 41. 42. 43. 44. K Q J T A 7 5 2 A K 3 7 2 A J 4 T 9 7 Q 8 K Q 8 6 A 3 2 A K 3 K J 6 K Q 8 5 Q 9 3 K Q 7 A 9 8 6 3 K Q 7 45. 46. 47. 48. J T 8 2 A 6 A 2 8 5 4 3 A 8 4 K Q 8 3 K 7 6 3 A K T A K Q Q 9 8 5 A K J 5 A Q 5 4 J T 2 A Q 4 J T 8 A 6 49. 50. 51. 52. A 9 A Q J 6 A 9 4 3 A K 5 3 K T 2 Q 9 6 2 T 4 A 6 3 A K 8 5 Q 9 A K 9 5 A 8 5 K 7 5 3 A J T A 8 4 T 6 3 53. 54. 55. 56. A 8 3 J 3 K 9 2 A Q 6 8 5 K Q J A 9 5 2 8 2 A K 7 3 K Q J T Q 5 A 9 6 K Q T 6 K J 9 4 A Q T 5 A J 7 6 5 57. 58. 59. 60. Q 8 4 J 9 3 A Q 8 Q J 8 7 K T 9 2 K J 5 K Q 5 A T 2 K J 9 K Q 8 5 4 3 Q 8 A Q 6 A Q 9 2 A 8 3 2 A K 4 2 61. 62. 63. 64. 9 6 3 2 A K J 5 K 4 A 8 A Q J T 4 2 A 7 4 A K 9 2 A 3 K 7 2 A 5 3 2 Q 8 2 A 9 7 3 A Q 3 A 7 6 2 Q 9 8 7 65. 66. 67. 68. K 7 5 A T 6 4 J 3 A Q 5 2 A K 8 3 A K 6 K Q T Q 7 5 Q 9 3 A 8 7 6 J 7 6 Q 7 2 K 5 4 5 2 A K J 6 4 A K 5 69. 70. 71. 72. A Q T 2 6 4 2 K Q 8 6 A K 9 6 K 7 6 Q J 8 A J T K Q 5 4 Q 8 A K J 6 2 K T 9 K Q 3 A 9 6 3 A J A 6 3 T 7 73. 74. 75. 76. K Q 5 A J A K 7 4 A 8 Q 9 4 A Q T 3 A Q 8 5 Q 9 8 A 4 Q J 9 T 9 5 A J 6 4 A 7 6 5 4 J 9 7 3 K T A Q 9 8 77. 78. 79. 80. A J 4 2 A 7 4 3 A 7 T 4 A 6 4 K 8 6 A K 4 A K 7 5 Q 6 5 A K Q 6 A J 8 7 2 K J 7 3 K J 4 9 5 9 7 6 K Q 5 81. 82. 83. 84. A K 7 6 A K 3 A K 4 A T 3 A 8 6 T 8 A 8 6 Q 7 6 Q J J T 5 2 K T 8 5 A K T 9 Q J T 9 A Q J 9 Q 8 2 K 8 2 85. 86. 87. 88. Q 6 4 J 3 J 8 5 4 K J T 2 A 7 3 K 9 2 A K 9 4 J 7 4 3 A K Q 8 7 A K 2 K J 9 A 8 T 2 A 8 5 3 2 A 2 A Q 9 89. 90. 91. 92. A K J K J 5 A K 7 9 7 9 8 A 7 5 Q J 6 A J 8 3 K Q 6 5 4 Q 7 3 6 3 A K T 4 K J 6 A Q 8 3 A Q J T 3 K J 4 93. 94. 95. 96. 9 8 5 A Q J 3 A K 8 2 A Q 5 A J A K Q 4 J T 6 7 4 A Q J 5 4 9 8 A K 6 5 A K Q 6 5 A 6 5 T 6 2 8 6 8 6 4 97. 98. 99. 100. A Q J T K J 3 A 3 2 K Q 8 7 A J 5 2 J 6 4 6 4 3 2 A K 9 2 Q 4 2 A J T A K 3 2 6 5 Q 9 K Q T 5 A J A 8 6 West hands: 1. 2. 3. 4. A K T 9 7 5 K 8 7 4 A J 6 2 3 9 3 Q 3 4 2 7 5 4 7 5 2 9 8 4 2 T 8 5 2 K 8 7 6 5 4 3 T 4 K T 6 K 7 3 K J 5. 6. 7. 8. K Q 2 A J 5 Q 6 4 K J 5 3 8 5 A 7 4 3 2 A J 8 7 2 K 8 2 A 8 7 5 8 7 2 J 7 T 7 5 8 6 3 2 8 6 8 5 3 5 4 3 9. 10. 11. 12. 9 3 2 Q 2 9 Q J 5 2 A 8 7 Q J 8 7 4 K J T 9 J T 6 2 K 4 3 2 A 8 7 6 Q J 8 2 T 8 Q 5 3 T 5 Q 7 4 2 A 8 6 13. 14. 15. 16. Q T 5 4 T 6 5 4 Q J 7 K 7 2 K T 7 6 5 A 8 T 8 Q T 6 3 2 A T 7 6 5 3 2 K T 8 5 2 5 3 5 A J 4 Q T 6 Q T 2 17. 18. 19. 20. A Q T 5 K 6 3 A 4 A K Q 6 3 6 2 T 8 6 K Q 9 8 6 3 - Q 8 7 9 8 6 K J 6 A K 9 8 7 4 A 9 8 3 2 A J 6 5 2 T 5 21. 22. 23. 24. A K 9 8 7 9 6 5 4 3 2 A Q 8 Q T 9 3 9 8 2 Q 5 J T 3 A 7 5 T 6 2 K Q 4 A K J 5 K 9 Q 8 J 8 9 4 3 K J T 9 25. 26. 27. 28. A 4 2 K 8 7 Q 7 3 Q 9 6 3 2 T 4 A Q T 7 6 A 9 8 6 2 K 8 T 8 7 5 3 - J 8 A 9 8 7 6 3 K 8 2 A K J 8 4 T 3 2 - 29. 30. 31. 32. A Q J 7 3 9 5 3 A Q 2 Q T 8 5 T 8 K J 6 J 9 4 3 2 A T 3 2 A K 9 6 4 Q J 4 9 3 2 Q T Q 7 4 2 T 5 3 2 J 3 33. 34. 35. 36. A Q T 2 K 9 2 7 5 4 A Q 6 3 A J 8 5 K 7 3 Q T 5 4 Q 3 Q J 9 7 4 A T 9 5 Q J 9 7 2 A K 9 7 Q T K 8 7 6 2 37. 38. 39. 40. K Q 6 5 2 9 8 A J 4 Q T 7 T 3 2 A K J 8 3 2 A K T 6 4 K Q T 2 Q T J 8 7 K Q T 7 4 Q 8 7 4 T 9 8 K J - 5 3 41. 42. 43. 44. 9 7 4 Q T 6 T 9 - 9 5 A K 4 A T 4 A 9 5 4 J 9 7 J 4 2 A 8 5 3 2 A T 7 A K 8 6 5 A 5 3 2 7 5 4 J 9 8 6 5 2 45. 46. 47. 48. K 7 4 K 9 8 5 J 8 6 4 7 6 Q T 7 2 J 9 A Q T J 7 4 3 5 4 7 6 Q 9 2 K J 2 K 7 5 4 K J T 6 2 7 6 2 Q T 9 7 49. 50. 51. 52. T 6 4 2 9 2 Q 6 5 Q T 9 8 4 3 A J T 3 A 6 3 J T 9 5 Q 9 6 4 K T 8 3 J T 7 3 2 9 2 A Q 8 2 9 6 3 Q 5 A J 53. 54. 55. 56. K 6 5 A K Q 4 A J 7 5 3 J K T 3 A 7 4 2 J 7 6 A Q J T 5 J T 6 5 4 A 4 A K 2 K J 8 2 9 5 T 5 2 9 6 K Q 2 57. 58. 59. 60. K 6 5 2 K 7 A K 9 6 4 A Q A 8 6 A 9 3 Q 7 5 4 A Q 5 2 7 6 3 2 A 9 8 3 2 T 7 5 4 3 K T 6 5 K Q J 6 5 9 7 61. 62. 63. 64. A Q T 5 T J 5 3 K J T 7 4 9 4 K J 7 6 J 8 6 5 4 T 9 8 A J 6 4 3 8 A T 9 7 3 Q 5 4 2 9 8 6 K Q J T 8 5 6 65. 66. 67. 68. 9 4 2 K J 3 A T 8 7 4 J T 7 Q T 9 5 3 8 6 5 4 3 A T 9 8 6 4 2 K T 8 5 T 3 2 A 4 2 K T 9 A J 6 J 6 8 J 4 69. 70. 71. 72. J T 5 J T T 7 4 3 2 J T 9 8 K 5 4 2 Q 9 7 3 2 3 K J 9 7 6 5 7 J 8 7 3 J 4 K 7 K Q 8 7 4 3 K 2 A Q J 9 2 73. 74. 75. 76. J 4 3 Q T 7 4 2 J T Q 5 2 A 8 6 5 3 9 5 2 K 9 6 2 A K T 6 5 2 T 7 2 J 8 6 K T 7 2 K 9 A Q Q J 5 2 J 7 3 77. 78. 79. 80. T 9 6 Q J K Q T 2 A 8 5 T A 7 3 Q 9 8 7 Q J T 8 6 2 A K 9 4 3 7 Q 9 6 - A Q T 6 A K Q T 8 6 3 3 2 J 9 7 6 81. 82. 83. 84. Q J 9 8 T 6 5 8 2 K A 9 2 K J 9 7 5 3 K 8 5 4 2 A K T 9 5 4 3 2 A 7 4 3 Q 4 3 Q 8 4 4 3 7 5 4 3 K Q 5 3 85. 86. 87. 88. K 9 8 3 Q 6 2 Q 7 6 5 Q 8 5 A 4 3 2 A 2 9 Q T 8 7 8 6 4 2 9 5 3 K 8 6 4 3 T 9 7 K Q J T 9 K J T 8 7 6 5 89. 90. 91. 92. 5 4 3 Q T Q J T 6 A K Q T 7 Q T 3 9 3 2 K 9 7 2 9 2 A J 8 6 K Q J 8 2 Q 9 8 7 6 A 9 8 5 T 7 6 2 8 8 5 2 93. 94. 95. 96. A K 2 K 9 6 4 2 Q J 9 5 4 9 8 4 T 8 K Q 7 A T 6 5 T 8 7 3 K J T 7 3 4 J 7 3 2 J 7 2 8 A Q T 7 3 K T 9 7 97. 98. 99. 100. K 8 6 3 9 8 7 2 K Q 4 J 2 T 7 3 A K Q 5 3 2 K Q J 5 J T 7 5 3 K 7 3 2 Q 6 4 K T 7 4 A K T A 8 T 5 3 Q 4 Generated 5440 hands Produced 100 hands Initial random seed 7 Time needed 0.015 sec dealer/getopt.c0000644000401600040160000004426410002574545012034 0ustar cbecbe/* 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/Post_Processors/0000755000401600040160000000000013204633311013515 5ustar cbecbedealer/Post_Processors/README0000644000401600040160000000006410002574544014402 0ustar cbecbeThis directory contains post-processing programs. dealer/Post_Processors/pbn_to_ascii.pl0000755000401600040160000000242710002574544016520 0ustar cbecbe#!/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/test0000644000401600040160000000116612127203707011261 0ustar cbecbedealer north ((hcp(north)>=20) && (hcp(north)<=21) &&shape(north, any 4333 + any 54xx + 3262 + 2263 + 2362 + 2236 + 3226 + 2326 - any 0xxx - any 1xxx) &&hcp(south)>=6 &&hcp(south)<=13 &&shape(south, any 44xx + any 54xx + xx5x + xxx5)) or ((hcp(north)>=22) && (hcp(north)<=23) &&shape(north, any 4333 + any 54xx + 3262 + 2263 + 2362 + 2236 + 3226 + 2326 - any 0xxx any 1xxx) &&hcp(south)>=4 &&shape(south, any 44xx + any 54xx + xx5x + xxx5)) or ((hcp(north)>=24) &&shape(north, any 4333 + any 54xx + 3262 + 2263 + 2362 + 2236 + 3226 + 2326 - any 0xxx - any 1xxx) &&shape(south, any 44xx + any 54xx + xx5x + xxx5)) dealer/c4.c0000644000401600040160000001001210055167647011031 0ustar cbecbe/* 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/pbn.c0000644000401600040160000000451610002574544011304 0ustar cbecbe/* 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/defs.c0000644000401600040160000026337112777467667011510 0ustar cbecbe/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2015 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 3 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, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Copy the first part of user declarations. */ #line 1 "defs.y" /* yacc.c:339 */ #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 107 "y.tab.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus # define YY_NULLPTR nullptr # else # define YY_NULLPTR 0 # endif # endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif #if YYDEBUG extern int yydebug; #endif /* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { QUERY = 258, COLON = 259, OR2 = 260, AND2 = 261, CMPEQ = 262, CMPNE = 263, CMPLT = 264, CMPLE = 265, CMPGT = 266, CMPGE = 267, ARPLUS = 268, ARMINUS = 269, ARTIMES = 270, ARDIVIDE = 271, ARMOD = 272, NOT = 273, GENERATE = 274, PRODUCE = 275, HCP = 276, SHAPE = 277, ANY = 278, EXCEPT = 279, CONDITION = 280, ACTION = 281, PRINT = 282, PRINTALL = 283, PRINTEW = 284, PRINTPBN = 285, PRINTCOMPACT = 286, PRINTONELINE = 287, AVERAGE = 288, HASCARD = 289, FREQUENCY = 290, PREDEAL = 291, POINTCOUNT = 292, ALTCOUNT = 293, CONTROL = 294, LOSER = 295, DEALER = 296, QUALITY = 297, CCCC = 298, TRICKS = 299, NOTRUMPS = 300, NORTHSOUTH = 301, EASTWEST = 302, EVALCONTRACT = 303, ALL = 304, NONE = 305, SCORE = 306, IMPS = 307, RND = 308, PT0 = 309, PT1 = 310, PT2 = 311, PT3 = 312, PT4 = 313, PT5 = 314, PT6 = 315, PT7 = 316, PT8 = 317, PT9 = 318, PRINTES = 319, NUMBER = 320, HOLDING = 321, STRING = 322, IDENT = 323, COMPASS = 324, VULNERABLE = 325, VULN = 326, SUIT = 327, CARD = 328, CONTRACT = 329, DISTR = 330, DISTR_OR_NUMBER = 331 }; #endif /* Tokens. */ #define QUERY 258 #define COLON 259 #define OR2 260 #define AND2 261 #define CMPEQ 262 #define CMPNE 263 #define CMPLT 264 #define CMPLE 265 #define CMPGT 266 #define CMPGE 267 #define ARPLUS 268 #define ARMINUS 269 #define ARTIMES 270 #define ARDIVIDE 271 #define ARMOD 272 #define NOT 273 #define GENERATE 274 #define PRODUCE 275 #define HCP 276 #define SHAPE 277 #define ANY 278 #define EXCEPT 279 #define CONDITION 280 #define ACTION 281 #define PRINT 282 #define PRINTALL 283 #define PRINTEW 284 #define PRINTPBN 285 #define PRINTCOMPACT 286 #define PRINTONELINE 287 #define AVERAGE 288 #define HASCARD 289 #define FREQUENCY 290 #define PREDEAL 291 #define POINTCOUNT 292 #define ALTCOUNT 293 #define CONTROL 294 #define LOSER 295 #define DEALER 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 VULNERABLE 325 #define VULN 326 #define SUIT 327 #define CARD 328 #define CONTRACT 329 #define DISTR 330 #define DISTR_OR_NUMBER 331 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { #line 43 "defs.y" /* yacc.c:355 */ int y_int; char *y_str; struct tree *y_tree; struct action *y_action; struct expr *y_expr; char y_distr[4]; #line 305 "y.tab.c" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif extern YYSTYPE yylval; int yyparse (void); /* Copy the second part of user declarations. */ #line 322 "y.tab.c" /* yacc.c:358 */ #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #else typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ # define YY_(Msgid) Msgid # endif #endif #ifndef YY_ATTRIBUTE # if (defined __GNUC__ \ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C # define YY_ATTRIBUTE(Spec) __attribute__(Spec) # else # define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif #ifndef YY_ATTRIBUTE_PURE # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) #endif #ifndef YY_ATTRIBUTE_UNUSED # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif #if !defined _Noreturn \ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) # if defined _MSC_VER && 1200 <= _MSC_VER # define _Noreturn __declspec (noreturn) # else # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) #else # define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's 'empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 574 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 81 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 25 /* YYNRULES -- Number of rules. */ #define YYNRULES 120 /* YYNSTATES -- Number of states. */ #define YYNSTATES 292 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 331 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 78, 79, 2, 2, 80, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 77, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 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, 68, 69, 70, 71, 72, 73, 74, 75, 76 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 145, 145, 147, 151, 153, 155, 159, 163, 164, 164, 166, 165, 167, 169, 171, 173, 178, 179, 183, 183, 184, 188, 190, 194, 197, 196, 204, 209, 214, 216, 219, 220, 226, 227, 233, 234, 236, 241, 242, 245, 250, 251, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365, 367, 372, 374, 376, 378, 383, 385, 388, 391, 395, 399, 403, 406, 409, 412, 415, 418, 421, 424, 426, 430, 441, 442, 446, 448 }; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "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", "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", "VULNERABLE", "VULN", "SUIT", "CARD", "CONTRACT", "DISTR", "DISTR_OR_NUMBER", "'='", "'('", "')'", "','", "$accept", "defs", "def", "$@1", "$@2", "predealargs", "predealarg", "$@3", "holdings", "pointcountargs", "$@4", "compass", "vulnerable", "shlprefix", "any", "number", "shape", "shapelistel", "shapelist", "expr", "exprlist", "actionlist", "action", "optstring", "printlist", YY_NULLPTR }; #endif # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 61, 40, 41, 44 }; # endif #define YYPACT_NINF -101 #define yypact_value_is_default(Yystate) \ (!!((Yystate) == (-101))) #define YYTABLE_NINF -1 #define yytable_value_is_error(Yytable_value) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { -101, 138, -101, -27, 453, 10, 10, -38, -7, 453, 326, 9, -46, -101, 10, 34, 41, 133, 58, 77, 129, 137, 203, 241, 260, 274, 282, 284, 288, 290, 291, 297, 298, 299, -101, 37, 147, 300, -101, 453, -101, -101, 541, -101, -101, -101, -101, -101, 133, 133, 541, 302, -101, -101, -101, 303, 304, 305, 305, -101, 306, -101, 307, 310, -101, 308, -46, -101, 10, -101, 133, 133, -101, -101, 133, 133, 133, 314, 453, 453, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 453, -101, -101, 133, 134, 453, 453, 453, 453, 453, 453, 453, 453, 453, 453, 453, 453, 453, 453, -6, 315, 325, 453, 453, -101, 453, 318, 349, 326, 317, 333, 351, -101, -101, -101, 10, 38, 74, 338, 345, 346, 348, 219, 244, 82, 86, 89, 91, 104, 106, 108, 125, 132, 139, 541, 350, -101, 118, 279, 552, 229, 19, 45, 301, 67, 51, 75, 92, 204, 413, -101, -101, 359, -8, -101, 198, 294, 319, 541, 453, -101, 541, 200, -101, 360, -101, 352, 355, 10, -101, -101, 364, -101, 365, 366, -101, -18, 368, -101, -101, -101, 367, -101, 374, -101, 375, -101, 376, -101, 377, -101, 378, -101, 379, -101, 393, -101, 398, -101, 400, -101, 453, 397, -101, -101, -101, 455, -101, -10, -101, 411, -101, -101, 5, -101, 401, 402, 416, 476, -101, 405, 406, 407, 409, 410, 414, 412, 419, 420, 423, 424, 438, 440, 441, 445, 451, 258, -101, -101, 245, -101, -101, -101, 10, -101, 541, -101, -101, 425, -101, -101, -101, -101, -101, 453, -101, -101, -101, -101, -101, -101, -101, -101, -101, -101, -101, -101, -101, 462, -101, 334, 10, -101, 285, -101, 453, 36, 10, 463, 10, 491, -101 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 103, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 44, 0, 0, 37, 0, 3, 43, 14, 36, 44, 95, 4, 5, 0, 0, 13, 0, 104, 105, 109, 107, 108, 117, 117, 111, 0, 16, 101, 0, 19, 0, 8, 17, 24, 11, 0, 0, 27, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 118, 0, 0, 0, 103, 0, 0, 0, 18, 10, 25, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 80, 0, 88, 87, 81, 82, 83, 84, 85, 86, 89, 90, 91, 92, 93, 46, 0, 31, 119, 0, 0, 0, 114, 0, 98, 97, 0, 102, 0, 22, 20, 0, 24, 12, 70, 0, 68, 0, 0, 72, 0, 0, 79, 96, 48, 0, 50, 0, 52, 0, 54, 0, 56, 0, 58, 0, 60, 0, 62, 0, 64, 0, 66, 0, 45, 0, 0, 30, 32, 29, 33, 41, 31, 106, 0, 112, 113, 0, 110, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 94, 47, 34, 0, 74, 42, 120, 0, 100, 99, 75, 23, 0, 71, 69, 73, 77, 76, 0, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 38, 39, 40, 0, 21, 0, 0, 78, 0, 115, 0, 0, 0, 0, 0, 0, 116 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -101, -101, -101, -101, -101, -101, 505, -101, -101, -100, -101, 452, -101, -101, -101, -5, -101, 354, -101, -2, -101, 456, -101, 515, -101 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 1, 40, 68, 125, 66, 67, 120, 176, 123, 178, 73, 92, 216, 249, 41, 277, 217, 218, 42, 172, 61, 62, 115, 165 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint16 yytable[] = { 46, 47, 45, 213, 214, 213, 214, 50, 95, 69, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 64, 3, 179, 65, 233, 100, 101, 102, 103, 104, 105, 106, 107, 108, 94, 43, 95, 48, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 234, 101, 102, 103, 104, 105, 106, 107, 108, 124, 104, 105, 106, 107, 108, 250, 215, 49, 215, 161, 162, 34, 132, 133, 229, 103, 104, 105, 106, 107, 108, 253, 38, 63, 144, 105, 106, 107, 108, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 106, 107, 108, 166, 167, 70, 168, 90, 171, 287, 180, 181, 71, 124, 95, 211, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 74, 95, 2, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 3, 182, 183, 75, 4, 5, 6, 7, 8, 190, 191, 9, 10, 192, 193, 223, 194, 195, 196, 197, 11, 124, 12, 13, 14, 15, 16, 17, 18, 19, 20, 198, 199, 200, 201, 202, 203, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 72, 34, 204, 205, 35, 76, 36, 246, 37, 206, 207, 146, 38, 77, 39, 91, 208, 209, 107, 108, 95, 255, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 95, 278, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 280, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 283, 219, 220, 224, 225, 78, 288, 286, 290, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 95, 188, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 102, 103, 104, 105, 106, 107, 108, 79, 275, 276, 95, 189, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 95, 80, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 81, 51, 52, 53, 54, 55, 56, 57, 82, 58, 83, 3, 284, 285, 84, 4, 85, 86, 7, 8, 114, 221, 59, 87, 88, 89, 93, 119, 111, 112, 113, 11, 117, 131, 121, 118, 15, 16, 60, 18, 19, 20, 164, 163, 169, 174, 222, 175, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 282, 34, 3, 170, 44, 184, 4, 177, 37, 7, 8, 185, 38, 186, 39, 187, 210, 108, 212, 227, 226, 228, 11, 230, 231, 232, 236, 15, 16, 235, 18, 19, 20, 237, 238, 239, 240, 241, 242, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 243, 34, 3, 254, 44, 244, 4, 245, 37, 7, 8, 247, 38, 248, 39, 252, 256, 257, 258, 259, 260, 261, 11, 262, 263, 279, 265, 15, 16, 264, 18, 19, 20, 266, 267, 109, 110, 268, 269, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 270, 34, 271, 272, 44, 126, 127, 273, 37, 128, 129, 130, 38, 274, 39, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 281, 289, 95, 145, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 291, 122, 251, 116, 173 }; static const yytype_uint16 yycheck[] = { 5, 6, 4, 13, 14, 13, 14, 9, 3, 14, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 69, 14, 125, 72, 45, 9, 10, 11, 12, 13, 14, 15, 16, 17, 39, 65, 3, 78, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 72, 10, 11, 12, 13, 14, 15, 16, 17, 68, 13, 14, 15, 16, 17, 79, 80, 78, 80, 79, 80, 65, 78, 79, 178, 12, 13, 14, 15, 16, 17, 80, 76, 78, 90, 14, 15, 16, 17, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 15, 16, 17, 112, 113, 78, 115, 77, 117, 80, 79, 80, 78, 125, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 78, 3, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 14, 79, 80, 78, 18, 19, 20, 21, 22, 79, 80, 25, 26, 79, 80, 169, 79, 80, 79, 80, 34, 178, 36, 37, 38, 39, 40, 41, 42, 43, 44, 79, 80, 79, 80, 79, 80, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 69, 65, 79, 80, 68, 78, 70, 211, 72, 79, 80, 79, 76, 78, 78, 70, 79, 80, 16, 17, 3, 225, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 3, 253, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 264, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 281, 79, 80, 79, 80, 78, 287, 285, 289, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 3, 79, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 11, 12, 13, 14, 15, 16, 17, 78, 75, 76, 3, 79, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 3, 78, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 78, 27, 28, 29, 30, 31, 32, 33, 78, 35, 78, 14, 79, 80, 78, 18, 78, 78, 21, 22, 67, 79, 48, 78, 78, 78, 78, 69, 78, 78, 78, 34, 78, 71, 78, 80, 39, 40, 64, 42, 43, 44, 69, 80, 78, 80, 79, 66, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 79, 65, 14, 67, 68, 80, 18, 69, 72, 21, 22, 79, 76, 80, 78, 80, 79, 17, 72, 80, 73, 79, 34, 72, 72, 72, 72, 39, 40, 74, 42, 43, 44, 72, 72, 72, 72, 72, 72, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 72, 65, 14, 67, 68, 72, 18, 72, 72, 21, 22, 79, 76, 23, 78, 69, 79, 66, 7, 79, 79, 79, 34, 79, 79, 65, 79, 39, 40, 80, 42, 43, 44, 79, 79, 48, 49, 79, 79, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 79, 65, 79, 79, 68, 70, 71, 79, 72, 74, 75, 76, 76, 79, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 80, 80, 3, 93, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 79, 66, 218, 58, 118 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 82, 0, 14, 18, 19, 20, 21, 22, 25, 26, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 68, 70, 72, 76, 78, 83, 96, 100, 65, 68, 100, 96, 96, 78, 78, 100, 27, 28, 29, 30, 31, 32, 33, 35, 48, 64, 102, 103, 78, 69, 72, 86, 87, 84, 96, 78, 78, 69, 92, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 77, 70, 93, 78, 100, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 92, 92, 78, 78, 78, 67, 104, 104, 78, 80, 69, 88, 78, 87, 90, 96, 85, 92, 92, 92, 92, 92, 71, 100, 100, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 100, 92, 79, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 79, 80, 80, 69, 105, 100, 100, 100, 78, 67, 100, 101, 102, 80, 66, 89, 69, 91, 90, 79, 80, 79, 80, 80, 79, 80, 80, 79, 79, 79, 80, 79, 80, 79, 80, 79, 80, 79, 80, 79, 80, 79, 80, 79, 80, 79, 80, 79, 80, 79, 4, 72, 13, 14, 80, 94, 98, 99, 79, 80, 79, 79, 100, 79, 80, 73, 80, 79, 90, 72, 72, 72, 45, 72, 74, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 100, 79, 23, 95, 79, 98, 69, 80, 67, 100, 79, 66, 7, 79, 79, 79, 79, 79, 80, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 75, 76, 97, 96, 65, 100, 80, 79, 96, 79, 80, 100, 80, 96, 80, 96, 79 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 81, 82, 82, 83, 83, 83, 83, 83, 84, 83, 85, 83, 83, 83, 83, 83, 86, 86, 88, 87, 87, 89, 89, 90, 91, 90, 92, 93, 94, 94, 94, 94, 95, 95, 96, 96, 96, 97, 97, 98, 99, 99, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 101, 101, 101, 101, 102, 102, 102, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 104, 104, 105, 105 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 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 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (yylen); \ yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) /* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT # define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*----------------------------------------. | Print this symbol's value on YYOUTPUT. | `----------------------------------------*/ static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { FILE *yyo = yyoutput; YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], &(yyvsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyssp, yyvsp, Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T yystrlen (const char *yystr) { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * yystpcpy (char *yydest, const char *yysrc) { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) { YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ int yyparse (void) { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: 'yyss': related to states. 'yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (); } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 4: #line 152 "defs.y" /* yacc.c:1646 */ { extern int maxgenerate; if(!maxgenerate) maxgenerate = (yyvsp[0].y_int); } #line 1658 "y.tab.c" /* yacc.c:1646 */ break; case 5: #line 154 "defs.y" /* yacc.c:1646 */ { extern int maxproduce; if(!maxproduce) maxproduce = (yyvsp[0].y_int); } #line 1664 "y.tab.c" /* yacc.c:1646 */ break; case 6: #line 156 "defs.y" /* yacc.c:1646 */ { extern int maxdealer; maxdealer = (yyvsp[0].y_int); } #line 1672 "y.tab.c" /* yacc.c:1646 */ break; case 7: #line 160 "defs.y" /* yacc.c:1646 */ { extern int maxvuln; maxvuln = (yyvsp[0].y_int); } #line 1680 "y.tab.c" /* yacc.c:1646 */ break; case 9: #line 164 "defs.y" /* yacc.c:1646 */ { clearpointcount(); pointcount_index=12;} #line 1686 "y.tab.c" /* yacc.c:1646 */ break; case 11: #line 166 "defs.y" /* yacc.c:1646 */ { clearpointcount_alt((yyvsp[0].y_int)); pointcount_index=12;} #line 1692 "y.tab.c" /* yacc.c:1646 */ break; case 13: #line 168 "defs.y" /* yacc.c:1646 */ { extern struct tree *decisiontree; decisiontree = (yyvsp[0].y_tree); } #line 1698 "y.tab.c" /* yacc.c:1646 */ break; case 14: #line 170 "defs.y" /* yacc.c:1646 */ { extern struct tree *decisiontree; decisiontree = (yyvsp[0].y_tree); } #line 1704 "y.tab.c" /* yacc.c:1646 */ break; case 15: #line 172 "defs.y" /* yacc.c:1646 */ { new_var((yyvsp[-2].y_str), (yyvsp[0].y_tree)); } #line 1710 "y.tab.c" /* yacc.c:1646 */ break; case 16: #line 174 "defs.y" /* yacc.c:1646 */ { extern struct action *actionlist; actionlist = (yyvsp[0].y_action); } #line 1716 "y.tab.c" /* yacc.c:1646 */ break; case 19: #line 183 "defs.y" /* yacc.c:1646 */ { predeal_compass = (yyvsp[0].y_int);} #line 1722 "y.tab.c" /* yacc.c:1646 */ break; case 21: #line 184 "defs.y" /* yacc.c:1646 */ {bias_deal((yyvsp[-5].y_int),(yyvsp[-3].y_int),(yyvsp[0].y_int));} #line 1728 "y.tab.c" /* yacc.c:1646 */ break; case 22: #line 189 "defs.y" /* yacc.c:1646 */ { predeal_holding(predeal_compass, (yyvsp[0].y_str)); } #line 1734 "y.tab.c" /* yacc.c:1646 */ break; case 23: #line 191 "defs.y" /* yacc.c:1646 */ { predeal_holding(predeal_compass, (yyvsp[0].y_str)); } #line 1740 "y.tab.c" /* yacc.c:1646 */ break; case 25: #line 197 "defs.y" /* yacc.c:1646 */ { pointcount(pointcount_index, (yyvsp[0].y_int)); pointcount_index--; } #line 1748 "y.tab.c" /* yacc.c:1646 */ break; case 27: #line 205 "defs.y" /* yacc.c:1646 */ { extern int use_compass[NSUITS]; use_compass[(yyvsp[0].y_int)] = 1; (yyval.y_int)= (yyvsp[0].y_int); } #line 1754 "y.tab.c" /* yacc.c:1646 */ break; case 28: #line 210 "defs.y" /* yacc.c:1646 */ { extern int use_vulnerable[NSUITS]; use_vulnerable[(yyvsp[0].y_int)] = 1; (yyval.y_int)= (yyvsp[0].y_int); } #line 1760 "y.tab.c" /* yacc.c:1646 */ break; case 29: #line 215 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = 0; } #line 1766 "y.tab.c" /* yacc.c:1646 */ break; case 30: #line 217 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = 0; } #line 1772 "y.tab.c" /* yacc.c:1646 */ break; case 31: #line 219 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = 0; } #line 1778 "y.tab.c" /* yacc.c:1646 */ break; case 32: #line 221 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = 1; } #line 1784 "y.tab.c" /* yacc.c:1646 */ break; case 33: #line 226 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = 0; } #line 1790 "y.tab.c" /* yacc.c:1646 */ break; case 34: #line 228 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = 1; } #line 1796 "y.tab.c" /* yacc.c:1646 */ break; case 36: #line 235 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = - (yyvsp[0].y_int); } #line 1802 "y.tab.c" /* yacc.c:1646 */ break; case 37: #line 237 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = d2n((yyvsp[0].y_distr)); } #line 1808 "y.tab.c" /* yacc.c:1646 */ break; case 40: #line 246 "defs.y" /* yacc.c:1646 */ { insertshape((yyvsp[0].y_distr), (yyvsp[-1].y_int), (yyvsp[-2].y_int)); } #line 1814 "y.tab.c" /* yacc.c:1646 */ break; case 43: #line 256 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_NUMBER, NIL, NIL, (yyvsp[0].y_int), 0); } #line 1820 "y.tab.c" /* yacc.c:1646 */ break; case 44: #line 258 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = var_lookup((yyvsp[0].y_str), 1); } #line 1826 "y.tab.c" /* yacc.c:1646 */ break; case 45: #line 260 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_LENGTH, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1832 "y.tab.c" /* yacc.c:1646 */ break; case 46: #line 262 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_HCPTOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1838 "y.tab.c" /* yacc.c:1646 */ break; case 47: #line 264 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_HCP, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1844 "y.tab.c" /* yacc.c:1646 */ break; case 48: #line 266 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT0TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1850 "y.tab.c" /* yacc.c:1646 */ break; case 49: #line 268 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT0, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1856 "y.tab.c" /* yacc.c:1646 */ break; case 50: #line 270 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT1TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1862 "y.tab.c" /* yacc.c:1646 */ break; case 51: #line 272 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT1, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1868 "y.tab.c" /* yacc.c:1646 */ break; case 52: #line 274 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT2TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1874 "y.tab.c" /* yacc.c:1646 */ break; case 53: #line 276 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT2, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1880 "y.tab.c" /* yacc.c:1646 */ break; case 54: #line 278 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT3TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1886 "y.tab.c" /* yacc.c:1646 */ break; case 55: #line 280 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT3, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1892 "y.tab.c" /* yacc.c:1646 */ break; case 56: #line 282 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT4TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1898 "y.tab.c" /* yacc.c:1646 */ break; case 57: #line 284 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT4, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1904 "y.tab.c" /* yacc.c:1646 */ break; case 58: #line 286 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT5TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1910 "y.tab.c" /* yacc.c:1646 */ break; case 59: #line 288 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT5, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1916 "y.tab.c" /* yacc.c:1646 */ break; case 60: #line 290 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT6TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1922 "y.tab.c" /* yacc.c:1646 */ break; case 61: #line 292 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT6, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1928 "y.tab.c" /* yacc.c:1646 */ break; case 62: #line 294 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT7TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1934 "y.tab.c" /* yacc.c:1646 */ break; case 63: #line 296 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT7, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1940 "y.tab.c" /* yacc.c:1646 */ break; case 64: #line 298 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT8TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1946 "y.tab.c" /* yacc.c:1646 */ break; case 65: #line 300 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT8, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1952 "y.tab.c" /* yacc.c:1646 */ break; case 66: #line 302 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT9TOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1958 "y.tab.c" /* yacc.c:1646 */ break; case 67: #line 304 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_PT9, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1964 "y.tab.c" /* yacc.c:1646 */ break; case 68: #line 306 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_LOSERTOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1970 "y.tab.c" /* yacc.c:1646 */ break; case 69: #line 308 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_LOSER, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1976 "y.tab.c" /* yacc.c:1646 */ break; case 70: #line 310 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_CONTROLTOTAL, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1982 "y.tab.c" /* yacc.c:1646 */ break; case 71: #line 312 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_CONTROL, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 1988 "y.tab.c" /* yacc.c:1646 */ break; case 72: #line 314 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_CCCC, NIL, NIL, (yyvsp[-1].y_int), 0); } #line 1994 "y.tab.c" /* yacc.c:1646 */ break; case 73: #line 316 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_QUALITY, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 2000 "y.tab.c" /* yacc.c:1646 */ break; case 74: #line 318 "defs.y" /* yacc.c:1646 */ { (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; } } #line 2012 "y.tab.c" /* yacc.c:1646 */ break; case 75: #line 326 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_HASCARD, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 2018 "y.tab.c" /* yacc.c:1646 */ break; case 76: #line 328 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_TRICKS, NIL, NIL, (yyvsp[-3].y_int), (yyvsp[-1].y_int)); } #line 2024 "y.tab.c" /* yacc.c:1646 */ break; case 77: #line 330 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_TRICKS, NIL, NIL, (yyvsp[-3].y_int), 4); } #line 2030 "y.tab.c" /* yacc.c:1646 */ break; case 78: #line 332 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_SCORE, (yyvsp[-1].y_tree), NIL, (yyvsp[-5].y_int), (yyvsp[-3].y_int)); } #line 2036 "y.tab.c" /* yacc.c:1646 */ break; case 79: #line 334 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_IMPS, (yyvsp[-1].y_tree), NIL, 0, 0); } #line 2042 "y.tab.c" /* yacc.c:1646 */ break; case 80: #line 336 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = (yyvsp[-1].y_tree); } #line 2048 "y.tab.c" /* yacc.c:1646 */ break; case 81: #line 338 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_CMPEQ, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2054 "y.tab.c" /* yacc.c:1646 */ break; case 82: #line 340 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_CMPNE, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2060 "y.tab.c" /* yacc.c:1646 */ break; case 83: #line 342 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_CMPLT, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2066 "y.tab.c" /* yacc.c:1646 */ break; case 84: #line 344 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_CMPLE, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2072 "y.tab.c" /* yacc.c:1646 */ break; case 85: #line 346 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_CMPGT, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2078 "y.tab.c" /* yacc.c:1646 */ break; case 86: #line 348 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_CMPGE, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2084 "y.tab.c" /* yacc.c:1646 */ break; case 87: #line 350 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_AND2, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2090 "y.tab.c" /* yacc.c:1646 */ break; case 88: #line 352 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_OR2, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2096 "y.tab.c" /* yacc.c:1646 */ break; case 89: #line 354 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_ARPLUS, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2102 "y.tab.c" /* yacc.c:1646 */ break; case 90: #line 356 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_ARMINUS, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2108 "y.tab.c" /* yacc.c:1646 */ break; case 91: #line 358 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_ARTIMES, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2114 "y.tab.c" /* yacc.c:1646 */ break; case 92: #line 360 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_ARDIVIDE, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2120 "y.tab.c" /* yacc.c:1646 */ break; case 93: #line 362 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_ARMOD, (yyvsp[-2].y_tree), (yyvsp[0].y_tree), 0, 0); } #line 2126 "y.tab.c" /* yacc.c:1646 */ break; case 94: #line 364 "defs.y" /* yacc.c:1646 */ { (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); } #line 2132 "y.tab.c" /* yacc.c:1646 */ break; case 95: #line 366 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_NOT, (yyvsp[0].y_tree), NIL, 0, 0); } #line 2138 "y.tab.c" /* yacc.c:1646 */ break; case 96: #line 368 "defs.y" /* yacc.c:1646 */ { (yyval.y_tree) = newtree(TRT_RND, (yyvsp[-1].y_tree), NIL, 0, 0); } #line 2144 "y.tab.c" /* yacc.c:1646 */ break; case 97: #line 373 "defs.y" /* yacc.c:1646 */ { (yyval.y_expr) = newexpr((yyvsp[0].y_tree), 0, 0); } #line 2150 "y.tab.c" /* yacc.c:1646 */ break; case 98: #line 375 "defs.y" /* yacc.c:1646 */ { (yyval.y_expr) = newexpr(0, (yyvsp[0].y_str), 0); } #line 2156 "y.tab.c" /* yacc.c:1646 */ break; case 99: #line 377 "defs.y" /* yacc.c:1646 */ { (yyval.y_expr) = newexpr((yyvsp[0].y_tree), 0, (yyvsp[-2].y_expr)); } #line 2162 "y.tab.c" /* yacc.c:1646 */ break; case 100: #line 379 "defs.y" /* yacc.c:1646 */ { (yyval.y_expr) = newexpr(0, (yyvsp[0].y_str), (yyvsp[-2].y_expr)); } #line 2168 "y.tab.c" /* yacc.c:1646 */ break; case 101: #line 384 "defs.y" /* yacc.c:1646 */ { (yyval.y_action) = (yyvsp[0].y_action); } #line 2174 "y.tab.c" /* yacc.c:1646 */ break; case 102: #line 386 "defs.y" /* yacc.c:1646 */ { (yyval.y_action) = (yyvsp[-2].y_action); (yyval.y_action)->ac_next = (yyvsp[0].y_action); } #line 2180 "y.tab.c" /* yacc.c:1646 */ break; case 103: #line 388 "defs.y" /* yacc.c:1646 */ { (yyval.y_action) = 0; } #line 2186 "y.tab.c" /* yacc.c:1646 */ break; case 104: #line 392 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action) = newaction(ACT_PRINTALL, NIL, (char *) 0, 0, NIL); } #line 2194 "y.tab.c" /* yacc.c:1646 */ break; case 105: #line 396 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action) = newaction(ACT_PRINTEW, NIL, (char *) 0, 0, NIL); } #line 2202 "y.tab.c" /* yacc.c:1646 */ break; case 106: #line 400 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action) = newaction(ACT_PRINT, NIL, (char *) 0, (yyvsp[-1].y_int), NIL); } #line 2210 "y.tab.c" /* yacc.c:1646 */ break; case 107: #line 404 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action)=newaction(ACT_PRINTCOMPACT,NIL,0,0, NIL);} #line 2217 "y.tab.c" /* yacc.c:1646 */ break; case 108: #line 407 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action) = newaction(ACT_PRINTONELINE, NIL, 0, 0, NIL);} #line 2224 "y.tab.c" /* yacc.c:1646 */ break; case 109: #line 410 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action)=newaction(ACT_PRINTPBN,NIL,0,0, NIL);} #line 2231 "y.tab.c" /* yacc.c:1646 */ break; case 110: #line 413 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action)=newaction(ACT_PRINTES,(struct tree*)(yyvsp[-1].y_expr),0,0, NIL); } #line 2238 "y.tab.c" /* yacc.c:1646 */ break; case 111: #line 416 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action)=newaction(ACT_EVALCONTRACT,0,0,0, NIL);} #line 2245 "y.tab.c" /* yacc.c:1646 */ break; case 112: #line 419 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action)=newaction(ACT_PRINTCOMPACT,(yyvsp[-1].y_tree),0,0, NIL);} #line 2252 "y.tab.c" /* yacc.c:1646 */ break; case 113: #line 422 "defs.y" /* yacc.c:1646 */ { will_print++; (yyval.y_action)=newaction(ACT_PRINTONELINE,(yyvsp[-1].y_tree),0,0, NIL);} #line 2259 "y.tab.c" /* yacc.c:1646 */ break; case 114: #line 425 "defs.y" /* yacc.c:1646 */ { (yyval.y_action) = newaction(ACT_AVERAGE, (yyvsp[0].y_tree), (yyvsp[-1].y_str), 0, NIL); } #line 2265 "y.tab.c" /* yacc.c:1646 */ break; case 115: #line 427 "defs.y" /* yacc.c:1646 */ { (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);} #line 2273 "y.tab.c" /* yacc.c:1646 */ break; case 116: #line 431 "defs.y" /* yacc.c:1646 */ { (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); } #line 2285 "y.tab.c" /* yacc.c:1646 */ break; case 117: #line 441 "defs.y" /* yacc.c:1646 */ { (yyval.y_str) = (char *) 0; } #line 2291 "y.tab.c" /* yacc.c:1646 */ break; case 118: #line 443 "defs.y" /* yacc.c:1646 */ { (yyval.y_str) = (yyvsp[0].y_str); } #line 2297 "y.tab.c" /* yacc.c:1646 */ break; case 119: #line 447 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = (1<<(yyvsp[0].y_int)); } #line 2303 "y.tab.c" /* yacc.c:1646 */ break; case 120: #line 449 "defs.y" /* yacc.c:1646 */ { (yyval.y_int) = (yyvsp[-2].y_int)|(1<<(yyvsp[0].y_int)); } #line 2309 "y.tab.c" /* yacc.c:1646 */ break; #line 2313 "y.tab.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*--------------------------------------. | yyerrlab -- here on detecting error. | `--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif return yyresult; } #line 451 "defs.y" /* yacc.c:1906 */ 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/c4.h0000644000401600040160000000063210055167525011040 0ustar cbecbe#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/dealer.c0000644000401600040160000015146410056343327011770 0ustar cbecbe#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/Manual/0000755000401600040160000000000013204633311011563 5ustar cbecbedealer/Manual/input.html0000644000401600040160000005672210002574543013630 0ustar cbecbe 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/preproc.html0000644000401600040160000002126710002574543014137 0ustar cbecbe 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/running.html0000644000401600040160000000205210002574543014134 0ustar cbecbe 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/manual.html0000644000401600040160000000404510002574543013735 0ustar cbecbe 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.html0000644000401600040160000000163210002574543014017 0ustar cbecbe 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/index.gif0000644000401600040160000000026410002574543013367 0ustar cbecbeGIF89a+ooo[!,+0ڋV"Qy ʒ5q Lׯ5=kUb"+^p8L &yybW+w[oUbw\左]a_)gƃtǥC4hز()⁙ٹ*:Z;dealer/Manual/disclaimers.html0000644000401600040160000000237410002574543014762 0ustar cbecbe 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/command.html0000644000401600040160000000357710002574543014107 0ustar cbecbe 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/Manual/perf.html0000644000401600040160000000316210002574543013413 0ustar cbecbe 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/prev.gif0000644000401600040160000000033410002574543013232 0ustar cbecbeGIF89a?ooo[!,?I޼j~㕶.Lq6z Hir"?$`)|J{Č\vSUM߬95[0Er5WxEWeCxhyfFfY)'#؈:+H4{[3 , 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/bugs.html0000644000401600040160000001170310002574543013417 0ustar cbecbe 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/download.html0000644000401600040160000001100210055170540014253 0ustar cbecbe 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/authors.html0000644000401600040160000000274610002574543014153 0ustar cbecbe Authors

    Authors

    Code maintainer

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

    dealer/Manual/next.gif0000644000401600040160000000025410002574543013235 0ustar cbecbeGIF89a%ooo[!,%}ڋ2bUbK +7nj:f#a)gy5Nq+d]͈^fbjۜXL$XBXr8c)9IYi`Y;dealer/Manual/index.html0000644000401600040160000000516510002574543013573 0ustar cbecbe 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/getopt.h0000644000401600040160000000743610002574545012041 0ustar cbecbe/* 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/pointcount.h0000644000401600040160000000060410002574545012727 0ustar cbecbe#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/README0000644000401600040160000000241710055170250011231 0ustar cbecbeThis 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/scan.l0000644000401600040160000001074710056340743011466 0ustar cbecbe/* $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/.cvsignore0000644000401600040160000000004710002574543012353 0ustar cbecbedefs.c scan.c *.o dealer dealer.tar.gz dealer/check.txt0000644000401600040160000000033712215510245012170 0ustar cbecbe produce 28 action average "N" hcp(north), average "E" hcp(east), average "S" hcp(south), average "W" hcp(west), average "NS" hcp(north)+hcp(south), average "EW" hcp(east)+hcp(west) dealer/pointcount.c0000644000401600040160000000141110002574544012716 0ustar cbecbe#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/MSDOS/0000755000401600040160000000000013204633311011233 5ustar cbecbedealer/MSDOS/ddostest.bat0000644000401600040160000000047310002574544013565 0ustar cbecbe @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.txt0000644000401600040160000000522610002574545014266 0ustar cbecbeFrom: 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/Makefile-MSDOS0000644000401600040160000000222710002574545013567 0ustar cbecbe# $Header: /home/henk/CVS/dealer/MSDOS/Makefile-MSDOS,v 1.2 1999/07/03 19:59:56 henk Exp $ CC = gcc CFLAGS = -Wall -pedantic -O2 -I. -DNDEBUG -DMSDOS -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} ${MAKE} -C Examples clean ${MAKE} -C Random clean tarclean: clean 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 dealer/MSDOS/VC++6_project_files.zip0000644000401600040160000001052210002574545015421 0ustar cbecbePKfq&&{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/dostest.bat0000644000401600040160000000047410002574544013422 0ustar cbecbe @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/README0000644000401600040160000000207110002574545012121 0ustar cbecbe 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/VC++5_project_files.zip0000644000401600040160000001100110002574544015410 0ustar cbecbePKB&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 getopt.o: getopt.h pointcount.o: pointcount.h dealer/Pre_Processors/0000755000401600040160000000000013204633311013316 5ustar cbecbedealer/Pre_Processors/README.dpp0000644000401600040160000001773710002574545015005 0ustar cbecbe### 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/Pre_Processors/dpp0000755000401600040160000000130110002574545014030 0ustar cbecbe#!/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.pm0000644000401600040160000002441110002574545014567 0ustar cbecbe############################################################ ## 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/dealer.h0000644000401600040160000000357512005747744012003 0ustar cbecbe#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)) #define printlin(d) (fprintlin(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/dealer_dev.html0000644000401600040160000000102310002574544013327 0ustar cbecbe 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/tree.h0000644000401600040160000000713110056340755011471 0ustar cbecbe#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/pbn.h0000644000401600040160000000011210002574544011275 0ustar cbecbe#ifndef PBN_H #define PBN_H int printpbn (int, deal); #endif /* PBN_H */ dealer/check.pl0000755000401600040160000000015012215513114011756 0ustar cbecbe#!/usr/bin/perl for ($i=0; $i<40; $i++) { $out=system("./dealer -s ".$i. " check.txt | grep NS: ") }