|
|
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: 1873 (0x751)
Types: TextFile
Names: »progaux.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Nobs/progaux.c«
/*
* nobs - auxiliary program strategy functions.
* G. L. Sicherman.
*/
#include "defs.h"
#include "globs.h"
#include "logglobs.h"
float evaldiscard();
bestdis(hand, mydeal, aw, bw)
CARD hand[];
int mydeal;
int *aw, *bw;
{
float best, new;
int a, b;
best = -999.0;
for (a=0; a<5; a++) for (b=a+1; b<6; b++) {
new = evaldiscard(hand, mydeal, a, b);
if (new>best) {
best=new;
*aw=a;
*bw=b;
}
}
}
float
evaldiscard(hand, mydeal, j1, j2)
CARD hand[6];
int mydeal, j1, j2;
{
float retval, disval;
CARD holdhand[5], *hp;
int k, m, v;
int cutrank;
/*
* Evaluate the remaining hand.
*/
retval = 0.0;
hp=holdhand;
for (k=0; k<6; k++) if (k!=j1 && k!=j2) *hp++ = hand[k];
for (cutrank=ACE; cutrank<=KING; cutrank++) {
holdhand[4] = MAKECARD(cutrank, CABBAGE);
v = evalhand(holdhand, 1, -1);
retval += 4 * v;
for (m=0; m<6; m++)
if (SAMERANK(hand[m], holdhand[4])) retval -= v;
}
retval /= 46;
disval = distable[mydeal][cindex(hand[j1],hand[j2])];
if (!mydeal) disval= -disval;
retval += disval;
return retval;
}
/*
* This isn't supposed to be a world-class strategy.
*/
int
evalplay(c)
CARD c;
{
int v;
v = rankvalue[RANK(c)];
/*
* Are we setting human up for a 15?
*/
if (count+v == 5) return -11;
/*
* Are we setting human up for a 31?
*/
if (count+v == 21) return -9;
if (count+v == 15 || count+v == 31) return 20;
if (gocount && RANK(go[gocount-1])==RANK(c)) {
if (gocount>1 && RANK(go[gocount-2])==RANK(c)) return 30;
if (gocount>3 || randint(5)) return 15;
}
if (gocount > 1 &&
isrun(RANK(go[gocount-1]),RANK(go[gocount-2]), RANK(c))) return 25;
/*
* Are we setting human up for a run?
*/
if (gocount && 2==abs(RANK(c)-RANK(go[gocount-1]))) return -10;
if (count+v <= 4) return 10+count+v;
if (count>20) return v;
return 0;
}
int
isrun(a,b,c)
int a,b,c;
{
return 4==abs(a-b)+abs(a-c)+abs(b-c);
}