|
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 p
Length: 2213 (0x8a5) Types: TextFile Names: »program.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Nobs/program.c«
/* * The program's strategy. */ #include "defs.h" #include "globs.h" #include "logglobs.h" #include "window.h" float evaldiscard(); programdiscard(ehand, mydeal) CARD ehand[]; int mydeal; { int aw, bw; bestdis(ehand, mydeal, &aw, &bw); makediscard(ehand, aw, bw); mvwaddch(Programhand, 0, 5*4, '\n'); mvwprintw(Crib, 0, 0, "XXX XXX\n"); wrefresh(Programhand); wrefresh(Crib); } programplay() { int t, u, v; int bestplay, bestval; /* * Case I: It's the human's go. Sit tight. */ if (whosego == !whoseturn) return; /* * Case II: It's my go, and I can't play. Just score the * go and reset. */ if (whosego==whoseturn && goodgo(whoseturn)) { /* * If I have cards and human does not, explain to human. */ if (nleft[whoseturn] && !nleft[!whoseturn]) { mvwprintw(Prompt, 1, 0, "That's a Go\n"); wrefresh(Prompt); sleep(1); } SCOREUP(whoseturn, 1); handover = !nleft[0] && !nleft[1]; if (!handover) resetgo(); return; } /* * Case III: It's nobody's go yet, and I can't play. * Human still has cards, or we shouldn't be here. * Say "go". */ if (goodgo(whoseturn)) { whosego = !whoseturn; /* * If I have no cards, there's no need to say "go." */ if (nleft[whoseturn]) { mvwprintw(Prompt, 0, 11, "Go.\n"); wrefresh(Prompt); sleep(1); } return; } /* * I can play. Pick an appropriate play. */ bestval = -999; for (t=0; t<4; t++) if (goodplay(whoseturn, t)) { if ((v=evalplay(hand[whoseturn][t])) > bestval) { bestval=v; bestplay=t; } } makeprogplay(bestplay); } makeprogplay(t) int t; { int sco; nleft[whoseturn] -= 1; played[whoseturn][t]=1; count += rankvalue[RANK(hand[whoseturn][t])]; go[gocount++] = hand[whoseturn][t]; sco = playscore(); showpplay(whoseturn, t, sco); if (sco) SCOREUP(whoseturn, sco); /* * Say Go to myself? */ if (!nleft[whoseturn]) { /* That was my last card. */ handover = !nleft[!whoseturn]; if (handover && count != 31) SCOREUP(whoseturn, 1); if (!handover && (whosego==whoseturn || count==31)) resetgo(); return; } if (!nleft[!whoseturn]) whosego=whoseturn; /* Human out of cards */ if (whosego != whoseturn) { if (count==31) resetgo(); return; /* Give human a chance */ } }