|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T t
Length: 5405 (0x151d) Types: TextFile Names: »tactics.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Cubes/tactics.c«
/* vi:set sw=4 ts=4: */ #ifndef lint static char sccsid[] = "@(#)tactics.c 5.1 (G.M. Paris) 89/01/22"; #endif lint /* ** ** cubes 5.1 Copyright 1989 Gregory M. Paris ** Permission granted to redistribute on a no charge basis. ** All other rights are reserved. ** */ #include "cubes.h" /* ** nosingle: discard excess singles of a certain variety */ nosingles(pd, comb) register diceset *pd; combination comb; { register int d; register int singles; register int aces = 0; register int fives = 0; register int jokers = 0; if(pd->d_best == Nothing) return; for(d = 0;d < NDICE;++d) { switch(pd->d_comb[d]) { case Ace: ++aces; break; case Five: ++fives; break; case Joker: ++jokers; break; default: break; } } switch(comb) { case Ace: if((singles = aces) == 0) return; break; case Five: if((singles = fives) == 0) return; break; case Joker: if((singles = jokers) == 0) return; break; default: return; } if(pd->d_best == comb) { switch(comb) { case Ace: if(fives > 0) { pd->d_best = Five; break; } /* fall */ case Five: if(jokers > 0) { pd->d_best = Joker; break; } /* fall */ case Joker: if(--singles == 0) return; break; } } /* ** Alternate zapping LtoR and RtoL. */ if(randint(2) == 1) { for(d = 0;singles > 0 && d < NDICE;++d) { if(pd->d_comb[d] == comb) { pd->d_comb[d] = Nothing; pd->d_stat[d] = Free; ++pd->d_rolling; --singles; } } } else { for(d = NDICE-1;singles > 0 && d >= 0;--d) { if(pd->d_comb[d] == comb) { pd->d_comb[d] = Nothing; pd->d_stat[d] = Free; ++pd->d_rolling; --singles; } } } } /* ** noaces, nofives, nojokers: calls to nosingles routine */ noaces(pd) diceset *pd; { nosingles(pd, Ace); } nofives(pd) diceset *pd; { nosingles(pd, Five); } nojokers(pd) diceset *pd; { nosingles(pd, Joker); } /* ** no3okind: zap 3o'kind in specified denomination ** If face is BADFACE, zaps any denomination 3o'kind found. ** Assumes only Aces, Fives, and Jokers will fit in ** the same hand as a Three_of_a_kind. */ no3okind(pd, face) register diceset *pd; int face; { register int d; boolean present; combination nextbest; if(pd->d_best != Three_of_a_kind) return; /* ** Look for the 3o'kind and the highest single. */ present = False; nextbest = Nothing; for(d = 0;d < NDICE;++d) { switch(pd->d_comb[d]) { case Three_of_a_kind: if(face != BADFACE && pd->d_face[d] != face) return; present = True; switch(pd->d_face[d]) { case ACE: nextbest = Ace; break; case FIVE: if(nextbest == Nothing || nextbest == Joker) nextbest = Five; break; case JOKER: if(nextbest == Nothing) nextbest = Joker; break; default: break; } break; case Ace: nextbest = Ace; break; case Five: if(nextbest == Nothing || nextbest == Joker) nextbest = Five; break; case Joker: if(nextbest == Nothing) nextbest = Joker; break; default: break; } } /* ** If we didn't find an appropriate 3o'kind or if there ** would be no scoring dice left if we zapped it, we're done. */ if(present == False || nextbest == Nothing) return; /* ** Obliterate 3o'kind. If it's in a scoring denomination, ** do the appropriate conversion and count on a later call ** to noaces, nofives, or nojokers to finish the job. */ for(d = 0;d < NDICE;++d) { if(pd->d_comb[d] != Three_of_a_kind) continue; switch(pd->d_face[d]) { case ACE: pd->d_comb[d] = Ace; break; case FIVE: pd->d_comb[d] = Five; break; case JOKER: pd->d_comb[d] = Joker; break; default: pd->d_comb[d] = Nothing; pd->d_stat[d] = Free; ++pd->d_rolling; break; } } pd->d_best = nextbest; } /* ** no3deuce, no3three, no3any: calls to no3okind routine */ no3deuce(pd) diceset *pd; { no3okind(pd, DEUCE); } no3three(pd) diceset *pd; { no3okind(pd, THREE); } no3any(pd) diceset *pd; { no3okind(pd, BADFACE); } /* ** nosmall: discard Small_straight, retaining imbeded ace or five ** Assumes only singles fit in a hand with a Small_straight. */ nosmall(pd) register diceset *pd; { register int d; boolean present; combination nextbest; if(pd->d_best != Small_straight) return; present = False; nextbest = Nothing; for(d = 0;d < NDICE;++d) { switch(pd->d_comb[d]) { case Small_straight: present = True; switch(pd->d_face[d]) { case ACE: pd->d_comb[d] = Ace; nextbest = Ace; break; case FIVE: pd->d_comb[d] = Five; if(nextbest == Nothing || nextbest == Joker) nextbest = Five; break; default: pd->d_comb[d] = Nothing; pd->d_stat[d] = Free; ++pd->d_rolling; break; } break; case Ace: nextbest = Ace; break; case Five: if(nextbest == Nothing || nextbest == Joker) nextbest = Five; break; case Joker: if(nextbest == Nothing) nextbest = Joker; break; default: break; } } if(present == True) pd->d_best = nextbest; } /* ** noacesmall: discard only Small_straights that contain an imbedded ace */ noacesmall(pd) register diceset *pd; { register int d; if(pd->d_best != Small_straight) return; for(d = 0;d < NDICE;++d) { if(pd->d_comb[d] == Small_straight) { switch(pd->d_face[d]) { case ACE: /* imbedded ace */ nosmall(pd); /* dump it */ return; /* all done */ case FIVE: /* imbedded five */ return; /* keep it */ } } } }