196
latestTrickSuit[handStore[dl.first][2]]=dl.currentTrickSuit[2];
197
latestTrickRank[handStore[dl.first][2]]=dl.currentTrickRank[2];
198
latestTrickSuit[handStore[dl.first][1]]=dl.currentTrickSuit[1];
199
latestTrickRank[handStore[dl.first][1]]=dl.currentTrickRank[1];
212
latestTrickSuit[handId(dl.first, 2)]=dl.currentTrickSuit[2];
213
latestTrickRank[handId(dl.first, 2)]=dl.currentTrickRank[2];
214
latestTrickSuit[handId(dl.first, 1)]=dl.currentTrickSuit[1];
215
latestTrickRank[handId(dl.first, 1)]=dl.currentTrickRank[1];
200
216
latestTrickSuit[dl.first]=dl.currentTrickSuit[0];
201
217
latestTrickRank[dl.first]=dl.currentTrickRank[0];
222
238
for (k=0; k<=3; k++) {
223
if (game.suit[handStore[dl.first][3]][k]!=0) {
224
latestTrickSuit[handStore[dl.first][3]]=k;
225
latestTrickRank[handStore[dl.first][3]]=
226
InvBitMapRank(game.suit[handStore[dl.first][3]][k]);
239
if (game.suit[handId(dl.first, 3)][k]!=0) {
240
latestTrickSuit[handId(dl.first, 3)]=k;
241
latestTrickRank[handId(dl.first, 3)]=
242
InvBitMapRank(game.suit[handId(dl.first, 3)][k]);
230
latestTrickSuit[handStore[dl.first][1]]=dl.currentTrickSuit[1];
231
latestTrickRank[handStore[dl.first][1]]=dl.currentTrickRank[1];
246
latestTrickSuit[handId(dl.first, 1)]=dl.currentTrickSuit[1];
247
latestTrickRank[handId(dl.first, 1)]=dl.currentTrickRank[1];
232
248
latestTrickSuit[dl.first]=dl.currentTrickSuit[0];
233
249
latestTrickRank[dl.first]=dl.currentTrickRank[0];
254
270
for (k=0; k<=3; k++) {
255
if (game.suit[handStore[dl.first][3]][k]!=0) {
256
latestTrickSuit[handStore[dl.first][3]]=k;
257
latestTrickRank[handStore[dl.first][3]]=
258
InvBitMapRank(game.suit[handStore[dl.first][3]][k]);
271
if (game.suit[handId(dl.first, 3)][k]!=0) {
272
latestTrickSuit[handId(dl.first, 3)]=k;
273
latestTrickRank[handId(dl.first, 3)]=
274
InvBitMapRank(game.suit[handId(dl.first, 3)][k]);
262
278
for (k=0; k<=3; k++) {
263
if (game.suit[handStore[dl.first][2]][k]!=0) {
264
latestTrickSuit[handStore[dl.first][2]]=k;
265
latestTrickRank[handStore[dl.first][2]]=
266
InvBitMapRank(game.suit[handStore[dl.first][2]][k]);
279
if (game.suit[handId(dl.first, 2)][k]!=0) {
280
latestTrickSuit[handId(dl.first, 2)]=k;
281
latestTrickRank[handId(dl.first, 2)]=
282
InvBitMapRank(game.suit[handId(dl.first, 2)][k]);
287
303
for (k=0; k<=3; k++) {
288
if (game.suit[handStore[dl.first][3]][k]!=0) {
289
latestTrickSuit[handStore[dl.first][3]]=k;
290
latestTrickRank[handStore[dl.first][3]]=
291
InvBitMapRank(game.suit[handStore[dl.first][3]][k]);
295
for (k=0; k<=3; k++) {
296
if (game.suit[handStore[dl.first][2]][k]!=0) {
297
latestTrickSuit[handStore[dl.first][2]]=k;
298
latestTrickRank[handStore[dl.first][2]]=
299
InvBitMapRank(game.suit[handStore[dl.first][2]][k]);
303
for (k=0; k<=3; k++) {
304
if (game.suit[handStore[dl.first][1]][k]!=0) {
305
latestTrickSuit[handStore[dl.first][1]]=k;
306
latestTrickRank[handStore[dl.first][1]]=
307
InvBitMapRank(game.suit[handStore[dl.first][1]][k]);
304
if (game.suit[handId(dl.first, 3)][k]!=0) {
305
latestTrickSuit[handId(dl.first, 3)]=k;
306
latestTrickRank[handId(dl.first, 3)]=
307
InvBitMapRank(game.suit[handId(dl.first, 3)][k]);
311
for (k=0; k<=3; k++) {
312
if (game.suit[handId(dl.first, 2)][k]!=0) {
313
latestTrickSuit[handId(dl.first, 2)]=k;
314
latestTrickRank[handId(dl.first, 2)]=
315
InvBitMapRank(game.suit[handId(dl.first, 2)][k]);
319
for (k=0; k<=3; k++) {
320
if (game.suit[handId(dl.first, 1)][k]!=0) {
321
latestTrickSuit[handId(dl.first, 1)]=k;
322
latestTrickRank[handId(dl.first, 1)]=
323
InvBitMapRank(game.suit[handId(dl.first, 1)][k]);
314
game.contract=100+10*(dl.trump+1);
330
/*game.contract=100+10*(dl.trump+1);*/
315
332
game.first=dl.first;
317
334
game.noOfCards=cardCount;
413
430
nodeSetSizeLimit=NINIT;
414
431
lenSetSizeLimit=LINIT;
415
432
allocmem=(WINIT+1)*sizeof(struct winCardType);
416
allocmem+=(NINIT+1)*sizeof(struct nodeCardsType);
417
allocmem+=(LINIT+1)*sizeof(struct posSearchType);
433
allocmem+=(NINIT+1)*sizeof(struct nodeCardsType);
434
allocmem+=(LINIT+1)*sizeof(struct posSearchType);
421
wcount=0; ncount=0; lcount=0;
438
wcount=0; ncount=0; lcount=0;
422
439
InitGame(0, FALSE, first, handRelFirst);
440
457
MoveGen(&lookAheadPos, iniDepth);
441
458
if (movePly[iniDepth].last==0) {
447
futp->suit[0]=movePly[iniDepth].move[0].suit;
448
futp->rank[0]=movePly[iniDepth].move[0].rank;
464
futp->suit[0]=movePly[iniDepth].move[0].suit;
465
futp->rank[0]=movePly[iniDepth].move[0].rank;
450
467
movePly[iniDepth].move[0].sequence<<2;
455
472
if ((target==0)&&(solutions<3)) {
456
473
MoveGen(&lookAheadPos, iniDepth);
459
476
futp->totalNodes=0;
461
478
for (k=0; k<=movePly[iniDepth].last; k++) {
699
716
mv=bestMove[game.noOfCards-4];
700
717
hiwinSetSize=Max(hiwinSetSize, winSetSize);
701
718
hinodeSetSize=Max(hinodeSetSize, nodeSetSize);
702
hilenSetSize=Max(hilenSetSize, lenSetSize);
719
hilenSetSize=Max(hilenSetSize, lenSetSize);
703
720
if (nodeSetSize>MaxnodeSetSize)
704
721
MaxnodeSetSize=nodeSetSize;
705
722
if (winSetSize>MaxwinSetSize)
993
994
if (ttStore==NULL)
996
rel = (struct relRanksType *)calloc(16384, sizeof(struct relRanksType));
997
/*rel = new relRanksType[16384];*/
997
rel = (struct relRanksType *)calloc(8192/*16384*/, sizeof(struct relRanksType));
998
/*rel = new relRanksType[8192];*/
1002
highestRank = (int *)calloc(8192, sizeof(int));
1003
if (highestRank==NULL)
1007
for (k=1; k<8192; k++) {
1008
for (r=14; r>=2; r--) {
1009
if ((k & bitMapRank[r])!=0) {
1016
/* The use of the counttable to give the number of bits set to
1017
one in an integer follows an implementation by Thomas Andrews. */
1019
counttable = (int *)calloc(8192, sizeof(int));
1020
if (counttable==NULL)
1023
for (i=0; i<8192; i++) {
1025
for (j=0; j<13; j++) {
1026
if (i & (1<<j)) {counttable[i]++;}
1030
adaptWins = (struct adaptWinRanksType *)calloc(8192,
1031
sizeof(struct adaptWinRanksType));
1033
for (i=0; i<8192; i++)
1034
for (j=0; j<14; j++) {
1037
adaptWins[i].winRanks[j]=0;
1040
for (r=14; r>=2; r--) {
1041
if ((i & bitMapRank[r])!=0) {
1050
adaptWins[i].winRanks[j]=res;
1001
1054
/*fp2=fopen("dyn.txt", "w");
1011
1064
void InitGame(int gameNo, int moveTreeFlag, int first, int handRelFirst) {
1013
int k, s, h, r, cardFound, currHand=0, order, m, temp1, temp2;
1067
unsigned int topBitRank=1;
1014
1068
unsigned short int ind;
1015
unsigned short int rankInSuit[4][4];
1017
/*int points[4], tricks;
1018
int addNS, addEW, addMAX, trumpNS, trumpEW;
1019
struct gameInfo gm;*/
1022
1071
fp2=fopen("stat.txt","w");
1034
for (k=0; k<=3; k++)
1035
for (m=0; m<=3; m++)
1036
iniPosition.rankInSuit[k][m]=game.suit[k][m];
1086
/* Initialization of the rel structure is implemented
1087
according to a solution given by Thomas Andrews */
1089
for (k=0; k<=3; k++)
1090
for (m=0; m<=3; m++)
1091
iniPosition.rankInSuit[k][m]=game.suit[k][m];
1093
for (s=0; s<4; s++) {
1094
rel[0].aggrRanks[s]=0;
1095
rel[0].winMask[s]=0;
1098
for (ind=1; ind<8192; ind++) {
1099
if (ind>=(topBitRank+topBitRank)) {
1104
rel[ind]=rel[ind ^ topBitRank];
1106
for (s=0; s<4; s++) {
1107
for (h=0; h<4; h++) {
1108
if (game.suit[h][s] & topBitRank) {
1109
rel[ind].aggrRanks[s]=
1110
(rel[ind].aggrRanks[s]>>2)|(h<<24);
1111
rel[ind].winMask[s]=
1112
(rel[ind].winMask[s]>>2)|(3<<24);
1038
1120
iniPosition.first[game.noOfCards-4]=first;
1039
1121
iniPosition.handRelFirst=handRelFirst;
1040
1122
lookAheadPos=iniPosition;
1043
for (ind=0; ind<=16383; ind++) {
1044
for (s=0; s<=3; s++) {
1045
rel[ind].aggrRanks[s]=0;
1046
for (h=0; h<=3; h++) {
1050
for (r=2; r<=14; r++) {
1051
for (h=0; h<=3; h++) {
1052
if ((ind & game.suit[h][s] & bitMapRank[r])!=0) {
1053
rankInSuit[h][s]=rankInSuit[h][s] | bitMapRank[r];
1063
for (h=0; h<=3; h++) {
1064
if ((rankInSuit[h][s] & bitMapRank[k])!=0) {
1070
if (cardFound==FALSE) {
1074
orderCode=currHand << (26-order-order);
1075
rel[ind].aggrRanks[s]|=orderCode;
1076
orderCode=3 << (26-order-order);
1077
rel[ind].winMask[s]|=orderCode;
1085
temp1=game.contract/100;
1086
temp2=game.contract-100*temp1;
1088
1124
if ((trump<4)&&(trump>=0))
1089
1125
trumpContract=TRUE;
1091
1127
trumpContract=FALSE;
1093
/*start: tricksest */
1096
if (game.leadRank!=0)
1097
gm.suit[gm.leadHand][gm.leadSuit]=
1098
gm.suit[gm.leadHand][gm.leadSuit] | bitMapRank[gm.leadRank];
1100
for (h=0; h<=3; h++)
1103
for (h=0; h<=3; h++)
1104
for (s=0; s<=3; s++) {
1105
if ((gm.suit[h][s] & bitMapRank[14])!=0)
1106
points[h]=points[h]+4;
1107
if ((gm.suit[h][s] & bitMapRank[13])!=0)
1108
points[h]=points[h]+3;
1109
if ((gm.suit[h][s] & bitMapRank[12])!=0)
1110
points[h]=points[h]+2;
1111
if ((gm.suit[h][s] & bitMapRank[11])!=0)
1112
points[h]=points[h]+1;
1113
if (trumpContract) {
1114
if ((CountOnes(gm.suit[h][s])<=2) &&
1115
(gm.suit[h][s]<bitMapRank[14]) &&
1116
(gm.suit[h][s]>bitMapRank[10]))
1118
if (CountOnes(gm.suit[h][s])==0)
1119
points[h]=points[h]+3;
1120
else if (CountOnes(gm.suit[h][s])==1)
1121
points[h]=points[h]+2;
1122
else if (CountOnes(gm.suit[h][s])==2)
1123
points[h]=points[h]+1;
1126
if (trumpContract) {
1127
trumpNS=CountOnes(gm.suit[0][trump])+CountOnes(gm.suit[2][trump]);
1128
trumpEW=CountOnes(gm.suit[1][trump])+CountOnes(gm.suit[3][trump]);
1135
addNS=points[0]+points[2];
1136
addEW=points[1]+points[3];
1137
addNS=addNS+trumpNS-trumpEW;
1138
addEW=addEW+trumpEW-trumpNS;
1139
addMAX=Max(addNS, addEW);
1142
else if (addMAX>=33)
1144
else if ((addMAX>=29) && trumpContract)
1146
else if ((addMAX>=31) && (!trumpContract))
1148
else if ((addMAX>=26) && trumpContract)
1150
else if ((addMAX>=29) && (!trumpContract))
1152
else if ((addMAX>=25) && trumpContract)
1154
else if ((addMAX>=26) && (!trumpContract))
1156
else if (addMAX>=24)
1158
else if (addMAX>=22)
1164
estTricks[0]=tricks;
1165
estTricks[2]=tricks;
1166
estTricks[1]=13-tricks;
1167
estTricks[3]=13-tricks;
1170
estTricks[1]=tricks;
1171
estTricks[3]=tricks;
1172
estTricks[0]=13-tricks;
1173
estTricks[2]=13-tricks;
1176
1129
estTricks[1]=6;
1177
1130
estTricks[3]=6;
1178
1131
estTricks[0]=7;
1179
1132
estTricks[2]=7;
1183
1135
fprintf(fp2, "Estimated tricks for hand to play:\n");
1194
1146
void InitSearch(struct pos * posPoint, int depth, struct moveType startMoves[], int first, int mtd) {
1196
int s, d, h, max, hmax=0, handRelFirst;
1148
int s, d, h, /*max, hmax=0, */handRelFirst, maxAgg, maxHand=0;
1197
1149
int k, noOfStartMoves; /* Number of start moves in the 1st trick */
1198
1150
int hand[3], suit[3], rank[3];
1199
1151
struct moveType move;
1200
1152
unsigned short int startMovesBitMap[4][4]; /* Indices are hand and suit */
1153
unsigned short int aggHand[4][4];
1202
1155
for (h=0; h<=3; h++)
1203
1156
for (s=0; s<=3; s++)
1274
1226
for (s=0; s<=3; s++) /* Suit */
1275
1227
for (h=0; h<=3; h++) /* Hand */
1276
posPoint->removedRanks[s]=posPoint->removedRanks[s] |
1228
posPoint->removedRanks[s]|=
1277
1229
posPoint->rankInSuit[h][s];
1278
1230
for (s=0; s<=3; s++)
1279
1231
posPoint->removedRanks[s]=~(posPoint->removedRanks[s]);
1281
1233
for (s=0; s<=3; s++) /* Suit */
1282
1234
for (h=0; h<=3; h++) /* Hand */
1283
posPoint->removedRanks[s]=posPoint->removedRanks[s] &
1235
posPoint->removedRanks[s]&=
1284
1236
(~startMovesBitMap[h][s]);
1286
1238
for (s=0; s<=3; s++)
1291
1243
posPoint->winRanks[d][s]=0;
1294
/* Initialize winning rank */
1295
for (s=0; s<=3; s++) {
1296
posPoint->winner[s].rank=0;
1297
posPoint->winner[s].hand=0;
1300
if (noOfStartMoves>=1) {
1301
for (k=noOfStartMoves; k>=0; k--) {
1302
s=movePly[depth+k].move[0].suit;
1303
if (movePly[depth+k].move[0].rank>posPoint->winner[s].rank)
1304
posPoint->winner[s].rank=movePly[depth+k].move[0].rank;
1308
for (s=0; s<=3; s++) {
1309
k=posPoint->winner[s].rank;
1312
for (h=0; h<=3; h++) {
1313
if ((posPoint->rankInSuit[h][s] & bitMapRank[k]) != 0) {
1321
posPoint->winner[s].rank=max;
1322
posPoint->winner[s].hand=hmax;
1325
/* Initialize second best rank */
1326
for (s=0; s<=3; s++) {
1327
posPoint->secondBest[s].rank=0;
1328
posPoint->secondBest[s].hand=0;
1331
if (noOfStartMoves>=1) {
1332
for (k=noOfStartMoves; k>=0; k--) {
1333
s=movePly[depth+k].move[0].suit;
1334
if ((movePly[depth+k].move[0].rank>posPoint->secondBest[s].rank)&&
1335
(movePly[depth+k].move[0].rank<posPoint->winner[s].rank))
1336
posPoint->secondBest[s].rank=movePly[depth+k].move[0].rank;
1340
for (s=0; s<=3; s++) {
1341
k=posPoint->secondBest[s].rank;
1344
for (h=0; h<=3; h++) {
1345
if (((posPoint->rankInSuit[h][s] & bitMapRank[k]) != 0)&&
1346
(k<posPoint->winner[s].rank)) {
1354
posPoint->secondBest[s].rank=max;
1355
posPoint->secondBest[s].hand=hmax;
1246
/* Initialize winning and second best ranks */
1247
for (s=0; s<=3; s++) {
1249
for (h=0; h<=3; h++) {
1250
aggHand[h][s]=startMovesBitMap[h][s] | game.suit[h][s];
1251
if (aggHand[h][s]>maxAgg) {
1252
maxAgg=aggHand[h][s];
1257
posPoint->winner[s].hand=maxHand;
1258
k=highestRank[aggHand[maxHand][s]];
1259
posPoint->winner[s].rank=k;
1262
for (h=0; h<=3; h++) {
1263
aggHand[h][s]&=(~bitMapRank[k]);
1264
if (aggHand[h][s]>maxAgg) {
1265
maxAgg=aggHand[h][s];
1270
posPoint->secondBest[s].hand=maxHand;
1271
posPoint->secondBest[s].rank=highestRank[aggHand[maxHand][s]];
1274
posPoint->secondBest[s].hand=-1;
1275
posPoint->secondBest[s].rank=0;
1279
posPoint->winner[s].hand=-1;
1280
posPoint->winner[s].rank=0;
1281
posPoint->secondBest[s].hand=-1;
1282
posPoint->secondBest[s].rank=0;
1358
1287
for (s=0; s<=3; s++)
1359
1288
for (h=0; h<=3; h++)
1360
1289
posPoint->length[h][s]=
1361
(unsigned char)CountOnes(posPoint->rankInSuit[h][s]);
1290
(unsigned char)counttable[posPoint->rankInSuit[h][s]];
1364
1293
for (d=0; d<=49; d++) {
1375
1304
for (k=0; k<=13; k++) {
1376
for (h=0; h<=3; h++) {
1377
rootnp[k][h]=&posSearch[lenSetSize];
1378
posSearch[lenSetSize].suitLengths=0;
1379
posSearch[lenSetSize].posSearchPoint=NULL;
1380
posSearch[lenSetSize].left=NULL;
1381
posSearch[lenSetSize].right=NULL;
1305
for (h=0; h<=3; h++) {
1306
rootnp[k][h]=&posSearch[lenSetSize];
1307
posSearch[lenSetSize].suitLengths=0;
1308
posSearch[lenSetSize].posSearchPoint=NULL;
1309
posSearch[lenSetSize].left=NULL;
1310
posSearch[lenSetSize].right=NULL;
1636
1559
cardsP=FindSOP(posPoint, np, hand, target, tricks, &scoreFlag);
1638
if ((cardsP!=NULL)&&(depth!=iniDepth)) {
1561
if ((cardsP!=NULL)/*&&(depth!=iniDepth)*/) {
1639
1562
if (scoreFlag==1) {
1640
WinAdapt(posPoint, depth, cardsP, aggr);
1563
for (ss=0; ss<=3; ss++)
1564
posPoint->winRanks[depth][ss]=
1565
adaptWins[aggr[ss]].winRanks[(int)cardsP->leastWin[ss]];
1642
1567
if (cardsP->bestMoveRank!=0) {
1643
1568
bestMove[depth].suit=cardsP->bestMoveSuit;
2036
1967
firstHand=posPoint->first[depth];
2037
1968
r=movePly[depth].current;
2039
if (posPoint->handRelFirst==3) { /* This hand is last hand */
2040
mo1=movePly[depth].move[r];
2041
mo2=posPoint->move[depth+1];
2042
if (mo1.suit==mo2.suit) {
2043
if (mo1.rank>mo2.rank) {
2044
posPoint->move[depth]=mo1;
2045
posPoint->high[depth]=handStore[firstHand][3];
2048
posPoint->move[depth]=posPoint->move[depth+1];
1970
if (posPoint->handRelFirst==3) { /* This hand is last hand */
1971
mo1=movePly[depth].move[r];
1972
mo2=posPoint->move[depth+1];
1973
if (mo1.suit==mo2.suit) {
1974
if (mo1.rank>mo2.rank) {
1975
posPoint->move[depth]=mo1;
1976
posPoint->high[depth]=handId(firstHand, 3);
1979
posPoint->move[depth]=posPoint->move[depth+1];
2049
1980
posPoint->high[depth]=posPoint->high[depth+1];
2052
else if (trumpContract && (mo1.suit==trump)) {
2053
posPoint->move[depth]=mo1;
2054
posPoint->high[depth]=handStore[firstHand][3];
1983
else if (trumpContract && (mo1.suit==trump)) {
1984
posPoint->move[depth]=mo1;
1985
posPoint->high[depth]=handId(firstHand, 3);
2057
1988
posPoint->move[depth]=posPoint->move[depth+1];
2058
1989
posPoint->high[depth]=posPoint->high[depth+1];
2073
2003
posPoint->first[depth-1]=posPoint->high[depth]; /* Defines who is first
2074
2004
in the next move */
2076
t=handStore[firstHand][3];
2006
t=handId(firstHand, 3);
2077
2007
posPoint->handRelFirst=0; /* Hand pointed to by posPoint->first
2078
2008
will lead the next trick */
2081
2011
for (s=3; s>=0; s--) {
2082
q=handStore[firstHand][3-s];
2012
q=handId(firstHand, 3-s);
2083
2013
/* Add the moves to removed ranks */
2084
2014
r=movePly[depth+s].current;
2085
2015
w=movePly[depth+s].move[r].rank;
2086
2016
u=movePly[depth+s].move[r].suit;
2087
posPoint->removedRanks[u]=posPoint->removedRanks[u] | bitMapRank[w];
2017
posPoint->removedRanks[u]|=bitMapRank[w];
2090
posPoint->rankInSuit[t][u]=posPoint->rankInSuit[t][u] &
2020
posPoint->rankInSuit[t][u]&=(~bitMapRank[w]);
2093
2022
if (w==posPoint->winner[u].rank)
2094
2023
UpdateWinner(posPoint, u);
2117
2045
r=movePly[depth].current;
2118
2046
u=movePly[depth].move[r].suit;
2119
2047
w=movePly[depth].move[r].rank;
2120
posPoint->rankInSuit[t][u]=posPoint->rankInSuit[t][u] &
2048
posPoint->rankInSuit[t][u]&=(~bitMapRank[w]);
2124
2051
mo1=movePly[depth].move[r];
2125
2052
mo2=posPoint->move[depth+1];
2053
r=movePly[depth].current;
2054
u=movePly[depth].move[r].suit;
2055
w=movePly[depth].move[r].rank;
2126
2056
if (mo1.suit==mo2.suit) {
2127
2057
if (mo1.rank>mo2.rank) {
2128
2058
posPoint->move[depth]=mo1;
2129
posPoint->high[depth]=handStore[firstHand][posPoint->handRelFirst];
2059
posPoint->high[depth]=handId(firstHand, posPoint->handRelFirst);
2132
2062
posPoint->move[depth]=posPoint->move[depth+1];
2136
2066
else if (trumpContract && (mo1.suit==trump)) {
2137
2067
posPoint->move[depth]=mo1;
2138
posPoint->high[depth]=handStore[firstHand][posPoint->handRelFirst];
2068
posPoint->high[depth]=handId(firstHand, posPoint->handRelFirst);
2141
2071
posPoint->move[depth]=posPoint->move[depth+1];
2142
2072
posPoint->high[depth]=posPoint->high[depth+1];
2145
t=handStore[firstHand][posPoint->handRelFirst];
2075
t=handId(firstHand, posPoint->handRelFirst);
2146
2076
posPoint->handRelFirst++; /* Current hand is stepped */
2147
2077
posPoint->first[depth-1]=firstHand; /* First hand is not changed in
2149
r=movePly[depth].current;
2150
u=movePly[depth].move[r].suit;
2151
w=movePly[depth].move[r].rank;
2152
posPoint->rankInSuit[t][u]=posPoint->rankInSuit[t][u] &
2080
posPoint->rankInSuit[t][u]&=(~bitMapRank[w]);
2156
2083
posPoint->length[t][u]--;
2187
2114
r=movePly[depth+s].current;
2188
2115
w=movePly[depth+s].move[r].rank;
2189
2116
u=movePly[depth+s].move[r].suit;
2190
posPoint->removedRanks[u]=posPoint->removedRanks[u] & (~bitMapRank[w]);
2117
posPoint->removedRanks[u]&= (~bitMapRank[w]);
2192
2119
if (w>posPoint->winner[u].rank) {
2193
2120
posPoint->secondBest[u].rank=posPoint->winner[u].rank;
2194
2121
posPoint->secondBest[u].hand=posPoint->winner[u].hand;
2195
2122
posPoint->winner[u].rank=w;
2196
posPoint->winner[u].hand=handStore[firstHand][3-s];
2123
posPoint->winner[u].hand=handId(firstHand, 3-s);
2198
2125
else if (w>posPoint->secondBest[u].rank) {
2199
2126
posPoint->secondBest[u].rank=w;
2200
posPoint->secondBest[u].hand=handStore[firstHand][3-s];
2127
posPoint->secondBest[u].hand=handId(firstHand, 3-s);
2203
t=handStore[firstHand][3];
2130
t=handId(firstHand, 3);
2206
2133
if (nodeTypeStore[posPoint->first[depth-1]]==MAXNODE) /* First hand
2209
2136
posPoint->tricksMAX--;
2212
t=handStore[firstHand][posPoint->handRelFirst];
2139
t=handId(firstHand, posPoint->handRelFirst);
2213
2140
r=movePly[depth].current;
2214
2141
u=movePly[depth].move[r].suit;
2215
2142
w=movePly[depth].move[r].rank;
2143
/*posPoint->removedRanks[u]&= (~bitMapRank[w]);*/
2218
posPoint->rankInSuit[t][u]=posPoint->rankInSuit[t][u] |
2146
posPoint->rankInSuit[t][u]|=bitMapRank[w];
2221
2148
posPoint->length[t][u]++;
2300
2227
void UpdateWinner(struct pos * posPoint, int suit) {
2301
int k, h, hmax=0, flag;
2229
unsigned short int sb, sbmax;
2303
2231
posPoint->winner[suit]=posPoint->secondBest[suit];
2305
k=posPoint->secondBest[suit].rank-1;
2308
for (h=0; h<=3; h++)
2309
if ((posPoint->rankInSuit[h][suit] & bitMapRank[k]) != 0) {
2320
posPoint->secondBest[suit].rank=0;
2321
posPoint->secondBest[suit].hand=0;
2324
posPoint->secondBest[suit].rank=k;
2325
posPoint->secondBest[suit].hand=hmax;
2234
for (h=0; h<=3; h++) {
2235
sb=posPoint->rankInSuit[h][suit] & (~bitMapRank[posPoint->winner[suit].rank]);
2241
k=highestRank[sbmax];
2243
posPoint->secondBest[suit].hand=hmax;
2244
posPoint->secondBest[suit].rank=k;
2247
posPoint->secondBest[suit].hand=-1;
2248
posPoint->secondBest[suit].rank=0;
2331
2255
void UpdateSecondBest(struct pos * posPoint, int suit) {
2332
int k, h, hmax=0, flag;
2257
unsigned short int sb, sbmax;
2334
k=posPoint->secondBest[suit].rank-1;
2337
for (h=0; h<=3; h++)
2338
if ((posPoint->rankInSuit[h][suit] & bitMapRank[k]) != 0) {
2349
posPoint->secondBest[suit].rank=0;
2350
posPoint->secondBest[suit].hand=0;
2353
posPoint->secondBest[suit].rank=k;
2354
posPoint->secondBest[suit].hand=hmax;
2260
for (h=0; h<=3; h++) {
2261
sb=posPoint->rankInSuit[h][suit] & (~bitMapRank[posPoint->winner[suit].rank]);
2267
k=highestRank[sbmax];
2269
posPoint->secondBest[suit].hand=hmax;
2270
posPoint->secondBest[suit].rank=k;
2273
posPoint->secondBest[suit].hand=-1;
2274
posPoint->secondBest[suit].rank=0;
3019
2956
if (trumpContract &&(suit!=trump)&&(countOwn>0)&&(lowestQtricks==0)&&
3020
((qtricks==0)||((posPoint->winner[suit].hand!=hand)&&
3021
(posPoint->winner[suit].hand!=partner[hand])&&
3022
(posPoint->winner[trump].hand!=hand)&&
3023
(posPoint->winner[trump].hand!=partner[hand])))) {
2957
((qtricks==0)||((posPoint->winner[suit].hand!=hand)&&
2958
(posPoint->winner[suit].hand!=partner[hand])&&
2959
(posPoint->winner[trump].hand!=hand)&&
2960
(posPoint->winner[trump].hand!=partner[hand])))) {
3024
2961
if ((countPart==0)&&(posPoint->length[partner[hand]][trump]>0)) {
3025
if (((countRho>0)||(posPoint->length[rho[hand]][trump]==0))&&
3026
((countLho>0)||(posPoint->length[lho[hand]][trump]==0))) {
2962
if (((countRho>0)||(posPoint->length[rho[hand]][trump]==0))&&
2963
((countLho>0)||(posPoint->length[lho[hand]][trump]==0))) {
3027
2964
lowestQtricks=1;
3035
else if ((countRho==0)&&(countLho==0)) {
2972
else if ((countRho==0)&&(countLho==0)) {
3036
2973
if ((posPoint->rankInSuit[lho[hand]][trump] |
3037
posPoint->rankInSuit[rho[hand]][trump]) <
3038
posPoint->rankInSuit[partner[hand]][trump]) {
3040
for (rr=14; rr>=2; rr--) {
3041
if ((posPoint->rankInSuit[partner[hand]][trump] &
3042
bitMapRank[rr])!=0) {
3043
posPoint->winRanks[depth][trump]=
3044
posPoint->winRanks[depth][trump] | bitMapRank[rr];
2974
posPoint->rankInSuit[rho[hand]][trump]) <
2975
posPoint->rankInSuit[partner[hand]][trump]) {
2978
rr=highestRank[posPoint->rankInSuit[partner[hand]][trump]];
2980
posPoint->winRanks[depth][trump]|=bitMapRank[rr];
3052
2986
if (trumpContract && (suit==trump))
3128
3062
(posPoint->length[hand][ss]>0)&&
3129
3063
(posPoint->length[partner[hh]][ss]>0)) {
3134
if (nodeTypeStore[hand]==MAXNODE) {
3135
if ((posPoint->tricksMAX+(depth>>2)-Max(0,count-1))<target) {
3136
for (ss=0; ss<=3; ss++) {
3137
if ((posPoint->length[hand][ss]>0)
3138
&&(nodeTypeStore[posPoint->winner[ss].hand]==MINNODE))
3139
posPoint->winRanks[depth][ss]=
3140
bitMapRank[posPoint->winner[ss].rank];
3142
posPoint->winRanks[depth][ss]=0;
3148
if ((posPoint->tricksMAX+1+Max(0,count-1))>=target) {
3149
for (ss=0; ss<=3; ss++) {
3150
if ((posPoint->length[hand][ss]>0)
3151
&&(nodeTypeStore[posPoint->winner[ss].hand]==MAXNODE))
3152
posPoint->winRanks[depth][ss]=
3153
bitMapRank[posPoint->winner[ss].rank];
3155
posPoint->winRanks[depth][ss]=0;
3068
if (nodeTypeStore[hand]==MAXNODE) {
3069
if ((posPoint->tricksMAX+(depth>>2)-Max(0,count-1))<target) {
3070
for (ss=0; ss<=3; ss++) {
3071
if ((posPoint->length[hand][ss]>0)
3072
&&(nodeTypeStore[posPoint->winner[ss].hand]==MINNODE))
3073
posPoint->winRanks[depth][ss]=
3074
bitMapRank[posPoint->winner[ss].rank];
3076
posPoint->winRanks[depth][ss]=0;
3082
if ((posPoint->tricksMAX+1+Max(0,count-1))>=target) {
3083
for (ss=0; ss<=3; ss++) {
3084
if ((posPoint->length[hand][ss]>0)
3085
&&(nodeTypeStore[posPoint->winner[ss].hand]==MAXNODE))
3086
posPoint->winRanks[depth][ss]=
3087
bitMapRank[posPoint->winner[ss].rank];
3089
posPoint->winRanks[depth][ss]=0;
3193
3126
if ((posPoint->length[hand][trump]==0)&&
3194
3127
(posPoint->length[partner[hand]][trump]==0)) {
3195
3128
if (((posPoint->tricksMAX+(depth>>2)+1-
3196
Max(posPoint->length[lho[hand]][trump],
3197
posPoint->length[rho[hand]][trump]))<target)
3198
&&(depth>0)&&(depth!=iniDepth)) {
3129
Max(posPoint->length[lho[hand]][trump],
3130
posPoint->length[rho[hand]][trump]))<target)
3131
&&(depth>0)&&(depth!=iniDepth)) {
3199
3132
for (ss=0; ss<=3; ss++)
3200
3133
posPoint->winRanks[depth][ss]=0;
3204
3137
else if (((posPoint->tricksMAX+(depth>>2))<target)&&
3205
3138
(depth>0)&&(depth!=iniDepth)) {
3206
3139
for (ss=0; ss<=3; ss++)
3207
3140
posPoint->winRanks[depth][ss]=0;
3208
posPoint->winRanks[depth][trump]=
3141
posPoint->winRanks[depth][trump]=
3209
3142
bitMapRank[posPoint->winner[trump].rank];
3213
3146
hh=posPoint->secondBest[trump].hand;
3229
3162
hh=posPoint->secondBest[trump].hand;
3230
3163
if ((nodeTypeStore[hh]==MINNODE)&&
3231
3164
(posPoint->length[hh][trump]>1)&&
3232
(posPoint->winner[trump].hand==rho[hh])
3165
(posPoint->winner[trump].hand==rho[hh])
3233
3166
&&(posPoint->secondBest[trump].rank!=0)) {
3234
3167
if (((posPoint->tricksMAX+(depth>>2))<target)&&
3235
3168
(depth>0)&&(depth!=iniDepth)) {
3236
3169
for (ss=0; ss<=3; ss++)
3237
3170
posPoint->winRanks[depth][ss]=0;
3238
3171
posPoint->winRanks[depth][trump]=
3239
bitMapRank[posPoint->secondBest[trump].rank] ;
3172
bitMapRank[posPoint->secondBest[trump].rank] ;
3244
for (ss=0; ss<=3; ss++) {
3245
if ((ss!=trump)&&(posPoint->winner[ss].rank!=0)) {
3246
hh=posPoint->winner[ss].hand;
3247
if ((nodeTypeStore[hh]==MAXNODE)||
3248
(posPoint->length[hand][ss]==0)||
3249
(posPoint->length[partner[hand]][ss]==0)) {
3256
sum=Max(posPoint->length[hand][trump],
3257
posPoint->length[partner[hand]][trump]);
3258
if ((posPoint->tricksMAX+sum<target)&&(sum>0)
3259
&&(depth>0)&&(depth!=iniDepth)) {
3260
if (posPoint->tricksMAX+(depth>>2)<target) {
3261
for (ss=0; ss<=3; ss++) {
3263
if (nodeTypeStore[posPoint->winner[ss].hand]==MINNODE)
3264
posPoint->winRanks[depth][ss]=bitMapRank[posPoint->winner[ss].rank];
3266
posPoint->winRanks[depth][ss]=0;
3269
posPoint->winRanks[depth][ss]=0;
3287
3188
sum+=Max(posPoint->length[hh][ss], posPoint->length[partner[hh]][ss]);
3289
3190
if ((posPoint->tricksMAX+(depth>>2)+1-sum>=target)&&
3290
(sum>0)&&(depth>0)&&(depth!=iniDepth)) {
3191
(sum>0)&&(depth>0)&&(depth!=iniDepth)) {
3291
3192
if ((posPoint->tricksMAX+1>=target)) {
3292
for (ss=0; ss<=3; ss++) {
3193
for (ss=0; ss<=3; ss++) {
3293
3194
if (nodeTypeStore[posPoint->winner[ss].hand]==MAXNODE)
3294
3195
posPoint->winRanks[depth][ss]=bitMapRank[posPoint->winner[ss].rank];
3343
3244
if (((posPoint->tricksMAX+1)>=target)&&(depth>0)&&(depth!=iniDepth)) {
3344
3245
for (ss=0; ss<=3; ss++)
3345
3246
posPoint->winRanks[depth][ss]=0;
3346
posPoint->winRanks[depth][trump]=
3247
posPoint->winRanks[depth][trump]=
3347
3248
bitMapRank[posPoint->secondBest[trump].rank] ;
3352
for (ss=0; ss<=3; ss++) {
3353
if ((ss!=trump)&&(posPoint->winner[ss].rank!=0)) {
3354
hh=posPoint->winner[ss].hand;
3355
if ((nodeTypeStore[hh]==MINNODE)||
3356
(posPoint->length[hand][ss]==0)||
3357
(posPoint->length[partner[hand]][ss]==0)) {
3364
sum=Max(posPoint->length[hand][trump],
3365
posPoint->length[partner[hand]][trump]);
3366
if ((posPoint->tricksMAX+(depth>>2)+1-sum>=target)&&
3367
(depth>0)&&(depth!=iniDepth)) {
3368
if ((posPoint->tricksMAX+1>=target)&&(sum>0)) {
3369
for (ss=0; ss<=3; ss++) {
3371
if (nodeTypeStore[posPoint->winner[ss].hand]==MAXNODE)
3372
posPoint->winRanks[depth][ss]=bitMapRank[posPoint->winner[ss].rank];
3374
posPoint->winRanks[depth][ss]=0;
3377
posPoint->winRanks[depth][ss]=0;
3560
3429
if ((posPoint->length[partner[first]][suit]!=0)||
3561
3430
(posPoint->length[partner[first]][trump]==0)) {
3562
3431
if (((posPoint->length[lho[first]][suit]!=0)||
3563
(posPoint->length[lho[first]][trump]==0))&&
3564
((posPoint->length[rho[first]][suit]!=0)||
3565
(posPoint->length[rho[first]][trump]==0)))
3432
(posPoint->length[lho[first]][trump]==0))&&
3433
((posPoint->length[rho[first]][suit]!=0)||
3434
(posPoint->length[rho[first]][trump]==0)))
3568
3437
else if (((posPoint->length[lho[first]][suit]!=0)||
3569
(posPoint->rankInSuit[partner[first]][trump]>
3570
posPoint->rankInSuit[lho[first]][trump]))&&
3571
((posPoint->length[rho[first]][suit]!=0)||
3572
(posPoint->rankInSuit[partner[first]][trump]>
3573
posPoint->rankInSuit[rho[first]][trump])))
3438
(posPoint->rankInSuit[partner[first]][trump]>
3439
posPoint->rankInSuit[lho[first]][trump]))&&
3440
((posPoint->length[rho[first]][suit]!=0)||
3441
(posPoint->rankInSuit[partner[first]][trump]>
3442
posPoint->rankInSuit[rho[first]][trump])))
3579
3448
else if (posPoint->rankInSuit[partner[first]][suit] >
3580
3449
(posPoint->rankInSuit[lho[first]][suit] |
3581
posPoint->rankInSuit[rho[first]][suit])) {
3450
posPoint->rankInSuit[rho[first]][suit])) {
3582
3451
if ((trumpContract) && (suit!=trump)) {
3583
3452
if (((posPoint->length[lho[first]][suit]!=0)||
3584
(posPoint->length[lho[first]][trump]==0))&&
3585
((posPoint->length[rho[first]][suit]!=0)||
3586
(posPoint->length[rho[first]][trump]==0)))
3453
(posPoint->length[lho[first]][trump]==0))&&
3454
((posPoint->length[rho[first]][suit]!=0)||
3455
(posPoint->length[rho[first]][trump]==0)))
3592
3461
else if ((trumpContract)&&(suit!=trump)) {
3593
3462
if ((posPoint->length[partner[first]][suit]==0)&&
3594
(posPoint->length[partner[first]][trump]!=0)) {
3463
(posPoint->length[partner[first]][trump]!=0)) {
3595
3464
if ((posPoint->length[lho[first]][suit]==0)&&
3596
(posPoint->length[lho[first]][trump]!=0)&&
3597
(posPoint->length[rho[first]][suit]==0)&&
3598
(posPoint->length[rho[first]][trump]!=0)) {
3465
(posPoint->length[lho[first]][trump]!=0)&&
3466
(posPoint->length[rho[first]][suit]==0)&&
3467
(posPoint->length[rho[first]][trump]!=0)) {
3599
3468
if (posPoint->rankInSuit[partner[first]][trump]>
3600
(posPoint->rankInSuit[lho[first]][trump] |
3601
posPoint->rankInSuit[rho[first]][trump]))
3469
(posPoint->rankInSuit[lho[first]][trump] |
3470
posPoint->rankInSuit[rho[first]][trump]))
3604
3473
else if ((posPoint->length[lho[first]][suit]==0)&&
3605
(posPoint->length[lho[first]][trump]!=0)) {
3474
(posPoint->length[lho[first]][trump]!=0)) {
3606
3475
if (posPoint->rankInSuit[partner[first]][trump]
3607
> posPoint->rankInSuit[lho[first]][trump])
3476
> posPoint->rankInSuit[lho[first]][trump])
3610
3479
else if ((posPoint->length[rho[first]][suit]==0)&&
3611
(posPoint->length[rho[first]][trump]!=0)) {
3480
(posPoint->length[rho[first]][trump]!=0)) {
3612
3481
if (posPoint->rankInSuit[partner[first]][trump]
3613
> posPoint->rankInSuit[rho[first]][trump])
3482
> posPoint->rankInSuit[rho[first]][trump])
3622
3491
if (((posPoint->winner[suit].hand==lho[first])&&(suitCountLH==1))
3623
||((posPoint->winner[suit].hand==rho[first])&&(suitCountRH==1)))
3492
||((posPoint->winner[suit].hand==rho[first])&&(suitCountRH==1)))
3624
3493
weight=suitWeightDelta+40-(mp->rank);
3625
3494
else if (posPoint->winner[suit].hand==first) {
3626
if (posPoint->secondBest[suit].hand==partner[first])
3495
if ((posPoint->secondBest[suit].hand==partner[first])&&
3496
(posPoint->secondBest[suit].rank!=0))
3627
3497
weight=suitWeightDelta+50-(mp->rank);
3628
3498
else if (posPoint->winner[suit].rank==mp->rank)
3629
3499
weight=suitWeightDelta+31;
3644
3514
weight=suitWeightDelta+30-(mp->rank);
3645
3515
if ((bestMove[depth].suit==mp->suit)&&
3646
(bestMove[depth].rank==mp->rank))
3516
(bestMove[depth].rank==mp->rank))
3647
3517
weight+=50/*45*//*35*/;
3650
3520
if (((posPoint->winner[suit].hand==lho[first])&&(suitCountLH==1))
3651
||((posPoint->winner[suit].hand==rho[first])&&(suitCountRH==1)))
3521
||((posPoint->winner[suit].hand==rho[first])&&(suitCountRH==1)))
3652
3522
weight=suitWeightDelta+20-(mp->rank);
3653
3523
else if (posPoint->winner[suit].hand==first) {
3654
if (posPoint->secondBest[suit].hand==partner[first])
3524
if ((posPoint->secondBest[suit].hand==partner[first])&&
3525
(posPoint->secondBest[suit].rank!=0))
3655
3526
weight=suitWeightDelta+35-(mp->rank);
3656
3527
else if (posPoint->winner[suit].rank==mp->rank)
3657
3528
weight=suitWeightDelta+16;
3681
3552
leadSuit=posPoint->move[depth+1].suit;
3682
3553
if (leadSuit==suit) {
3683
3554
if (bitMapRank[mp->rank]>
3684
(bitMapRank[posPoint->move[depth+1].rank] |
3685
posPoint->rankInSuit[partner[first]][suit])) {
3555
(bitMapRank[posPoint->move[depth+1].rank] |
3556
posPoint->rankInSuit[partner[first]][suit])) {
3686
3557
if (trumpContract && (suit!=trump)) {
3687
3558
if ((posPoint->length[partner[first]][suit]!=0)||
3688
(posPoint->length[partner[first]][trump]==0))
3559
(posPoint->length[partner[first]][trump]==0))
3690
3561
else if ((posPoint->length[rho[first]][suit]==0)
3691
&&(posPoint->length[rho[first]][trump]!=0)
3692
&&(posPoint->rankInSuit[rho[first]][trump]>
3693
posPoint->rankInSuit[partner[first]][trump]))
3562
&&(posPoint->length[rho[first]][trump]!=0)
3563
&&(posPoint->rankInSuit[rho[first]][trump]>
3564
posPoint->rankInSuit[partner[first]][trump]))
3699
3570
else if (posPoint->rankInSuit[rho[first]][suit]>
3700
(bitMapRank[posPoint->move[depth+1].rank] |
3701
posPoint->rankInSuit[partner[first]][suit])) {
3571
(bitMapRank[posPoint->move[depth+1].rank] |
3572
posPoint->rankInSuit[partner[first]][suit])) {
3702
3573
if (trumpContract && (suit!=trump)) {
3703
3574
if ((posPoint->length[partner[first]][suit]!=0)||
3704
(posPoint->length[partner[first]][trump]==0))
3575
(posPoint->length[partner[first]][trump]==0))
3710
3581
else if (bitMapRank[posPoint->move[depth+1].rank] >
3711
(posPoint->rankInSuit[rho[first]][suit] |
3712
posPoint->rankInSuit[partner[first]][suit] |
3713
bitMapRank[mp->rank])) {
3582
(posPoint->rankInSuit[rho[first]][suit] |
3583
posPoint->rankInSuit[partner[first]][suit] |
3584
bitMapRank[mp->rank])) {
3714
3585
if (trumpContract && (suit!=trump)) {
3715
3586
if ((posPoint->length[rho[first]][suit]==0)&&
3716
(posPoint->length[rho[first]][trump]!=0)) {
3587
(posPoint->length[rho[first]][trump]!=0)) {
3717
3588
if ((posPoint->length[partner[first]][suit]!=0)||
3718
(posPoint->length[partner[first]][trump]==0))
3589
(posPoint->length[partner[first]][trump]==0))
3720
3591
else if (posPoint->rankInSuit[rho[first]][trump]
3721
> posPoint->rankInSuit[partner[first]][trump])
3592
> posPoint->rankInSuit[partner[first]][trump])
3726
3597
else { /* winnerHand is partner to first */
3727
3598
if (trumpContract && (suit!=trump)) {
3728
3599
if ((posPoint->length[rho[first]][suit]==0)&&
3729
(posPoint->length[rho[first]][trump]!=0))
3600
(posPoint->length[rho[first]][trump]!=0))
3735
/* Leading suit differs from suit played by LHO */
3606
/* Leading suit differs from suit played by LHO */
3736
3607
if (trumpContract && (suit==trump)) {
3737
3608
if (posPoint->length[partner[first]][leadSuit]!=0)
3739
3610
else if (bitMapRank[mp->rank]>
3740
posPoint->rankInSuit[partner[first]][trump])
3611
posPoint->rankInSuit[partner[first]][trump])
3742
3613
else if ((posPoint->length[rho[first]][leadSuit]==0)
3743
&&(posPoint->length[rho[first]][trump]!=0)&&
3744
(posPoint->rankInSuit[rho[first]][trump] >
3745
posPoint->rankInSuit[partner[first]][trump]))
3614
&&(posPoint->length[rho[first]][trump]!=0)&&
3615
(posPoint->rankInSuit[rho[first]][trump] >
3616
posPoint->rankInSuit[partner[first]][trump]))
3748
3619
else if (trumpContract && (leadSuit!=trump)) {
3753
3624
bitMapRank[posPoint->move[depth+1].rank]))
3755
3626
else if ((posPoint->length[rho[first]][leadSuit]==0)
3756
&&(posPoint->length[rho[first]][trump]!=0))
3627
&&(posPoint->length[rho[first]][trump]!=0))
3759
3630
/* Partner to leading hand is void in leading suit */
3760
3631
else if ((posPoint->length[rho[first]][leadSuit]==0)
3761
&&(posPoint->rankInSuit[rho[first]][trump]>
3762
posPoint->rankInSuit[partner[first]][trump]))
3632
&&(posPoint->rankInSuit[rho[first]][trump]>
3633
posPoint->rankInSuit[partner[first]][trump]))
3764
3635
else if ((posPoint->length[partner[first]][trump]==0)
3765
&&(posPoint->rankInSuit[rho[first]][leadSuit] >
3766
bitMapRank[posPoint->move[depth+1].rank]))
3636
&&(posPoint->rankInSuit[rho[first]][leadSuit] >
3637
bitMapRank[posPoint->move[depth+1].rank]))
3770
/* Either no trumps or leadSuit is trump, side with
3641
/* Either no trumps or leadSuit is trump, side with
3771
3642
highest rank in leadSuit wins */
3772
if (posPoint->rankInSuit[rho[first]][leadSuit] >
3643
if (posPoint->rankInSuit[rho[first]][leadSuit] >
3773
3644
(posPoint->rankInSuit[partner[first]][leadSuit] |
3774
3645
bitMapRank[posPoint->move[depth+1].rank]))
3790
3661
else if (k > bitMapRank[mp->rank])
3791
3662
weight=45-(mp->rank); /* If lowest card for partner to leading hand
3792
is higher than lho played card, playing as low as
3793
possible will give the cheapest win */
3663
is higher than lho played card, playing as low as
3664
possible will give the cheapest win */
3794
3665
else if ((ll > bitMapRank[posPoint->move[depth+1].rank])&&
3795
3666
(posPoint->rankInSuit[first][leadSuit] > ll))
3796
3667
weight=60-(mp->rank); /* If rho has a card in the leading suit that
3801
3672
else if (mp->rank > posPoint->move[depth+1].rank) {
3802
3673
if (bitMapRank[mp->rank] < ll)
3803
3674
weight=75-(mp->rank); /* If played card is lower than any of the cards of
3804
rho, it will be the cheapest win */
3675
rho, it will be the cheapest win */
3805
3676
else if (bitMapRank[mp->rank] > kk)
3806
3677
weight=70-(mp->rank); /* If played card is higher than any cards at partner
3807
3678
of the leading hand, rho can play low, under the
3897
3765
if (posPoint->high[depth+1]==first) {
3898
3766
if (trumpContract && (suit==trump))
3899
3767
weight=30-(mp->rank)+suitAdd; /* Ruffs partner's winner */
3900
/*else if ((posPoint->length[partner[first]][suit]==1)&&
3901
(bitMapRank[mp->suit]>posPoint->rankInSuit[first][suit])&&
3902
(posPoint->rankInSuit[first][suit]>
3903
(posPoint->rankInSuit[lho[first]][suit] |
3904
posPoint->rankInSuit[rho[first]][suit])))
3905
weight=90-(mp->rank)+suitAdd;*/
3907
3769
weight=60-(mp->rank)+suitAdd;
4648
4508
cardSuit[movePly[depth+k+1].move[mcurrent].suit],
4649
4509
cardRank[movePly[depth+k+1].move[mcurrent].rank]);
4652
for (hh=0; hh<=3; hh++) {
4653
fprintf(fp7, "hand=%c\n", cardHand[hh]);
4654
for (ss=0; ss<=3; ss++) {
4655
fprintf(fp7, "suit=%c", cardSuit[ss]);
4656
for (rr=14; rr>=2; rr--)
4657
if (posPoint->rankInSuit[hh][ss] & bitMapRank[rr])
4658
fprintf(fp7, " %c", cardRank[rr]);
4512
for (hh=0; hh<=3; hh++) {
4513
fprintf(fp7, "hand=%c\n", cardHand[hh]);
4514
for (ss=0; ss<=3; ss++) {
4515
fprintf(fp7, "suit=%c", cardSuit[ss]);
4516
for (rr=14; rr>=2; rr--)
4517
if (posPoint->rankInSuit[hh][ss] & bitMapRank[rr])
4518
fprintf(fp7, " %c", cardRank[rr]);
4665
for (hh=0; hh<=3; hh++) {
4666
fprintf(fp7, "hand=%c\n", cardHand[hh]);
4667
for (ss=0; ss<=3; ss++) {
4668
fprintf(fp7, "suit=%c", cardSuit[ss]);
4669
for (rr=1; rr<=13; rr++)
4670
if (posPoint->relRankInSuit[hh][ss] & bitMapRank[15-rr])
4671
fprintf(fp7, " %c", cardRank[rr]);
4525
for (hh=0; hh<=3; hh++) {
4526
fprintf(fp7, "hand=%c\n", cardHand[hh]);
4527
for (ss=0; ss<=3; ss++) {
4528
fprintf(fp7, "suit=%c", cardSuit[ss]);
4529
for (rr=1; rr<=13; rr++)
4530
if (posPoint->relRankInSuit[hh][ss] & bitMapRank[15-rr])
4531
fprintf(fp7, " %c", cardRank[rr]);
4672
4536
fprintf(fp7, "\n");
4713
void WinAdapt(struct pos * posPoint, int depth, struct nodeCardsType * cp,
4714
unsigned short int aggr[]) {
4717
for (ss=0; ss<=3; ss++) {
4718
posPoint->winRanks[depth][ss]=0;
4719
if (cp->leastWin[ss]==0)
4722
for (rr=14; rr>=2; rr--) {
4723
if ((aggr[ss] & bitMapRank[rr])!=0) {
4724
if (k<=cp->leastWin[ss]) {
4725
posPoint->winRanks[depth][ss]|=bitMapRank[rr];
4737
int DismissX(struct pos *posPoint, int depth) {
4571
int NextMove(struct pos *posPoint, int depth) {
4572
/* Returns TRUE if at least one move remains to be
4573
searched, otherwise FALSE is returned. */
4739
4575
unsigned short int lw;
4740
4577
struct moveType currMove;
4742
4579
mcurrent=movePly[depth].current;
4743
4580
currMove=movePly[depth].move[mcurrent];
4745
4582
if (lowestWin[depth][currMove.suit]==0) {
4583
/* A small card has not yet been identified for this suit. */
4746
4584
lw=posPoint->winRanks[depth][currMove.suit];
4748
lw=lw & (-lw); /* LSB */
4586
lw=lw & (-lw); /* LSB */
4751
4589
if (bitMapRank[currMove.rank]<lw) {
4752
lowestWin[depth][currMove.suit]=lw;
4590
/* The current move has a small card. */
4591
lowestWin[depth][currMove.suit]=lw;
4753
4592
while (movePly[depth].current<=movePly[depth].last-1) {
4754
4593
movePly[depth].current++;
4755
4594
mcurrent=movePly[depth].current;
4756
4595
if (bitMapRank[movePly[depth].move[mcurrent].rank] >=
4757
4596
lowestWin[depth][movePly[depth].move[mcurrent].suit])
4604
while (movePly[depth].current<=movePly[depth].last-1) {
4605
movePly[depth].current++;
4606
mcurrent=movePly[depth].current;
4607
suit=movePly[depth].move[mcurrent].suit;
4608
if ((currMove.suit==suit) ||
4609
(bitMapRank[movePly[depth].move[mcurrent].rank] >=
4610
lowestWin[depth][suit]))
4762
4617
else if (movePly[depth].current<=movePly[depth].last-1) {
4763
4618
movePly[depth].current++;
4770
4626
while (movePly[depth].current<=movePly[depth].last-1) {
4771
4627
movePly[depth].current++;
4772
4628
mcurrent=movePly[depth].current;
4773
4629
if (bitMapRank[movePly[depth].move[mcurrent].rank] >=
4774
lowestWin[depth][movePly[depth].move[mcurrent].suit])
4630
lowestWin[depth][movePly[depth].move[mcurrent].suit])