2007-12-15 22:44:37 +03:00
|
|
|
/* $NetBSD: score.c,v 1.13 2007/12/15 19:44:39 perry Exp $ */
|
1995-03-21 18:03:38 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1980, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 13:36:50 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1997-10-10 16:26:34 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef lint
|
1995-03-21 18:03:38 +03:00
|
|
|
#if 0
|
|
|
|
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
|
|
|
|
#else
|
2007-12-15 22:44:37 +03:00
|
|
|
__RCSID("$NetBSD: score.c,v 1.13 2007/12/15 19:44:39 perry Exp $");
|
1995-03-21 18:03:38 +03:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif /* not lint */
|
|
|
|
|
1995-03-21 18:03:38 +03:00
|
|
|
#include <curses.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1995-03-21 18:03:38 +03:00
|
|
|
#include "deck.h"
|
|
|
|
#include "cribbage.h"
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* the following arrays give the sum of the scores of the (50 2)*48 = 58800
|
|
|
|
* hands obtainable for the crib given the two cards whose ranks index the
|
|
|
|
* array. the two arrays are for the case where the suits are equal and
|
|
|
|
* not equal respectively
|
|
|
|
*/
|
Add use of `const' where appropriate to the games.
This merges in all such remaining changes from the Linux port of the
NetBSD games, except in hunt (where substantial changes from OpenBSD
need to be looked at).
Some such changes were previously covered in PRs bin/6041, bin/6146,
bin/6148, bin/6150, bin/6151, bin/6580, bin/6660, bin/7993, bin/7994,
bin/8039, bin/8057 and bin/8093.
1999-09-09 01:17:44 +04:00
|
|
|
const long crbescr[169] = {
|
1993-03-21 12:45:37 +03:00
|
|
|
-10000, 271827, 278883, 332319, 347769, 261129, 250653, 253203, 248259,
|
|
|
|
243435, 256275, 237435, 231051, -10000, -10000, 412815, 295707, 349497,
|
|
|
|
267519, 262521, 259695, 254019, 250047, 262887, 244047, 237663, -10000,
|
|
|
|
-10000, -10000, 333987, 388629, 262017, 266787, 262971, 252729, 254475,
|
|
|
|
267315, 248475, 242091, -10000, -10000, -10000, -10000, 422097, 302787,
|
|
|
|
256437, 263751, 257883, 254271, 267111, 248271, 241887, -10000, -10000,
|
|
|
|
-10000, -10000, -10000, 427677, 387837, 349173, 347985, 423861, 436701,
|
|
|
|
417861, 411477, -10000, -10000, -10000, -10000, -10000, -10000, 336387,
|
|
|
|
298851, 338667, 236487, 249327, 230487, 224103, -10000, -10000, -10000,
|
|
|
|
-10000, -10000, -10000, -10000, 408483, 266691, 229803, 246195, 227355,
|
|
|
|
220971, -10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000,
|
|
|
|
300675, 263787, 241695, 226407, 220023, -10000, -10000, -10000, -10000,
|
|
|
|
-10000, -10000, -10000, -10000, -10000, 295635, 273543, 219771, 216939,
|
|
|
|
-10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000,
|
|
|
|
-10000, 306519, 252747, 211431, -10000, -10000, -10000, -10000, -10000,
|
|
|
|
-10000, -10000, -10000, -10000, -10000, -10000, 304287, 262971, -10000,
|
|
|
|
-10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000,
|
|
|
|
-10000, -10000, 244131, -10000, -10000, -10000, -10000, -10000, -10000,
|
1995-03-21 18:03:38 +03:00
|
|
|
-10000, -10000, -10000, -10000, -10000, -10000, -10000
|
|
|
|
};
|
1993-03-21 12:45:37 +03:00
|
|
|
|
Add use of `const' where appropriate to the games.
This merges in all such remaining changes from the Linux port of the
NetBSD games, except in hunt (where substantial changes from OpenBSD
need to be looked at).
Some such changes were previously covered in PRs bin/6041, bin/6146,
bin/6148, bin/6150, bin/6151, bin/6580, bin/6660, bin/7993, bin/7994,
bin/8039, bin/8057 and bin/8093.
1999-09-09 01:17:44 +04:00
|
|
|
const long crbnescr[169] = {
|
1993-03-21 12:45:37 +03:00
|
|
|
325272, 260772, 267828, 321264, 336714, 250074, 239598, 242148, 237204,
|
|
|
|
232380, 246348, 226380, 219996, -10000, 342528, 401760, 284652, 338442,
|
|
|
|
256464, 251466, 248640, 242964, 238992, 252960, 232992, 226608, -10000,
|
|
|
|
-10000, 362280, 322932, 377574, 250962, 255732, 251916, 241674, 243420,
|
|
|
|
257388, 237420, 231036, -10000, -10000, -10000, 360768, 411042, 291732,
|
|
|
|
245382, 252696, 246828, 243216, 257184, 237216, 230832, -10000, -10000,
|
|
|
|
-10000, -10000, 528768, 416622, 376782, 338118, 336930, 412806, 426774,
|
|
|
|
406806, 400422, -10000, -10000, -10000, -10000, -10000, 369864, 325332,
|
|
|
|
287796, 327612, 225432, 239400, 219432, 213048, -10000, -10000, -10000,
|
|
|
|
-10000, -10000, -10000, 359160, 397428, 255636, 218748, 236268, 216300,
|
|
|
|
209916, -10000, -10000, -10000, -10000, -10000, -10000, -10000, 331320,
|
|
|
|
289620, 252732, 231768, 215352, 208968, -10000, -10000, -10000, -10000,
|
|
|
|
-10000, -10000, -10000, -10000, 325152, 284580, 263616, 208716, 205884,
|
|
|
|
-10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000,
|
|
|
|
321240, 296592, 241692, 200376, -10000, -10000, -10000, -10000, -10000,
|
|
|
|
-10000, -10000, -10000, -10000, -10000, 348600, 294360, 253044, -10000,
|
|
|
|
-10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000, -10000,
|
|
|
|
-10000, 308664, 233076, -10000, -10000, -10000, -10000, -10000, -10000,
|
1995-03-21 18:03:38 +03:00
|
|
|
-10000, -10000, -10000, -10000, -10000, -10000, 295896
|
|
|
|
};
|
1993-03-21 12:45:37 +03:00
|
|
|
|
Add use of `const' where appropriate to the games.
This merges in all such remaining changes from the Linux port of the
NetBSD games, except in hunt (where substantial changes from OpenBSD
need to be looked at).
Some such changes were previously covered in PRs bin/6041, bin/6146,
bin/6148, bin/6150, bin/6151, bin/6580, bin/6660, bin/7993, bin/7994,
bin/8039, bin/8057 and bin/8093.
1999-09-09 01:17:44 +04:00
|
|
|
static const int ichoose2[5] = { 0, 0, 2, 6, 12 };
|
1995-03-21 18:03:38 +03:00
|
|
|
static int pairpoints, runpoints; /* Globals from pairuns. */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* scorehand:
|
|
|
|
* Score the given hand of n cards and the starter card.
|
|
|
|
* n must be <= 4
|
|
|
|
*/
|
1995-03-21 18:03:38 +03:00
|
|
|
int
|
2005-07-02 12:32:32 +04:00
|
|
|
scorehand(const CARD hand[], CARD starter, int n, BOOLEAN crb,
|
|
|
|
BOOLEAN do_explain)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-10 16:26:34 +04:00
|
|
|
int i, k;
|
2005-07-02 12:32:32 +04:00
|
|
|
int hscore;
|
1997-10-10 16:26:34 +04:00
|
|
|
BOOLEAN flag;
|
1995-03-21 18:03:38 +03:00
|
|
|
CARD h[(CINHAND + 1)];
|
|
|
|
char buf[32];
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2002-12-06 04:48:24 +03:00
|
|
|
explan[0] = '\0'; /* initialize explanation */
|
2005-07-02 12:32:32 +04:00
|
|
|
hscore = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
flag = TRUE;
|
|
|
|
k = hand[0].suit;
|
1995-03-21 18:03:38 +03:00
|
|
|
for (i = 0; i < n; i++) { /* check for flush */
|
|
|
|
flag = (flag && (hand[i].suit == k));
|
|
|
|
if (hand[i].rank == JACK) /* check for his nibs */
|
|
|
|
if (hand[i].suit == starter.suit) {
|
2005-07-02 12:32:32 +04:00
|
|
|
hscore++;
|
1995-03-21 18:03:38 +03:00
|
|
|
if (do_explain)
|
2002-12-06 04:48:24 +03:00
|
|
|
strcat(explan, "His Nobs");
|
1995-03-21 18:03:38 +03:00
|
|
|
}
|
|
|
|
h[i] = hand[i];
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag && n >= CINHAND) {
|
2002-12-06 04:48:24 +03:00
|
|
|
if (do_explain && explan[0] != '\0')
|
|
|
|
strcat(explan, ", ");
|
1995-03-21 18:03:38 +03:00
|
|
|
if (starter.suit == k) {
|
2005-07-02 12:32:32 +04:00
|
|
|
hscore += 5;
|
1995-03-21 18:03:38 +03:00
|
|
|
if (do_explain)
|
2002-12-06 04:48:24 +03:00
|
|
|
strcat(explan, "Five-flush");
|
1995-03-21 18:03:38 +03:00
|
|
|
} else
|
|
|
|
if (!crb) {
|
2005-07-02 12:32:32 +04:00
|
|
|
hscore += 4;
|
2002-12-06 04:48:24 +03:00
|
|
|
if (do_explain && explan[0] != '\0')
|
|
|
|
strcat(explan, ", Four-flush");
|
1995-03-21 18:03:38 +03:00
|
|
|
else
|
2002-12-06 04:48:24 +03:00
|
|
|
strcpy(explan, "Four-flush");
|
1995-03-21 18:03:38 +03:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2002-12-06 04:48:24 +03:00
|
|
|
if (do_explain && explan[0] != '\0')
|
|
|
|
strcat(explan, ", ");
|
1993-03-21 12:45:37 +03:00
|
|
|
h[n] = starter;
|
1995-03-21 18:03:38 +03:00
|
|
|
sorthand(h, n + 1); /* sort by rank */
|
1993-03-21 12:45:37 +03:00
|
|
|
i = 2 * fifteens(h, n + 1);
|
2005-07-02 12:32:32 +04:00
|
|
|
hscore += i;
|
1998-08-30 13:19:36 +04:00
|
|
|
if (do_explain) {
|
1995-03-21 18:03:38 +03:00
|
|
|
if (i > 0) {
|
|
|
|
(void) sprintf(buf, "%d points in fifteens", i);
|
2002-12-06 04:48:24 +03:00
|
|
|
strcat(explan, buf);
|
1995-03-21 18:03:38 +03:00
|
|
|
} else
|
2002-12-06 04:48:24 +03:00
|
|
|
strcat(explan, "No fifteens");
|
1998-08-30 13:19:36 +04:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
i = pairuns(h, n + 1);
|
2005-07-02 12:32:32 +04:00
|
|
|
hscore += i;
|
1998-08-30 13:19:36 +04:00
|
|
|
if (do_explain) {
|
1995-03-21 18:03:38 +03:00
|
|
|
if (i > 0) {
|
|
|
|
(void) sprintf(buf, ", %d points in pairs, %d in runs",
|
|
|
|
pairpoints, runpoints);
|
2002-12-06 04:48:24 +03:00
|
|
|
strcat(explan, buf);
|
1995-03-21 18:03:38 +03:00
|
|
|
} else
|
2002-12-06 04:48:24 +03:00
|
|
|
strcat(explan, ", No pairs/runs");
|
1998-08-30 13:19:36 +04:00
|
|
|
}
|
2005-07-02 12:32:32 +04:00
|
|
|
return (hscore);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* fifteens:
|
|
|
|
* Return number of fifteens in hand of n cards
|
|
|
|
*/
|
1995-03-21 18:03:38 +03:00
|
|
|
int
|
2005-07-02 12:32:32 +04:00
|
|
|
fifteens(const CARD hand[], int n)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-10 16:26:34 +04:00
|
|
|
int *sp, *np;
|
|
|
|
int i;
|
Add use of `const' where appropriate to the games.
This merges in all such remaining changes from the Linux port of the
NetBSD games, except in hunt (where substantial changes from OpenBSD
need to be looked at).
Some such changes were previously covered in PRs bin/6041, bin/6146,
bin/6148, bin/6150, bin/6151, bin/6580, bin/6660, bin/7993, bin/7994,
bin/8039, bin/8057 and bin/8093.
1999-09-09 01:17:44 +04:00
|
|
|
const CARD *endp;
|
1995-03-21 18:03:38 +03:00
|
|
|
static int sums[15], nsums[15];
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
np = nsums;
|
|
|
|
sp = sums;
|
|
|
|
i = 16;
|
|
|
|
while (--i) {
|
1995-03-21 18:03:38 +03:00
|
|
|
*np++ = 0;
|
|
|
|
*sp++ = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
for (endp = &hand[n]; hand < endp; hand++) {
|
1995-03-21 18:03:38 +03:00
|
|
|
i = hand->rank + 1;
|
|
|
|
if (i > 10)
|
|
|
|
i = 10;
|
|
|
|
np = &nsums[i];
|
|
|
|
np[-1]++; /* one way to make this */
|
|
|
|
sp = sums;
|
|
|
|
while (i < 15) {
|
|
|
|
*np++ += *sp++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
sp = sums;
|
|
|
|
np = nsums;
|
|
|
|
i = 16;
|
|
|
|
while (--i)
|
|
|
|
*sp++ = *np++;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
return sums[14];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pairuns returns the number of points in the n card sorted hand
|
|
|
|
* due to pairs and runs
|
|
|
|
* this routine only works if n is strictly less than 6
|
|
|
|
* sets the globals pairpoints and runpoints appropriately
|
|
|
|
*/
|
1995-03-21 18:03:38 +03:00
|
|
|
int
|
2005-07-02 12:32:32 +04:00
|
|
|
pairuns(const CARD h[], int n)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-10 16:26:34 +04:00
|
|
|
int i;
|
1995-03-21 18:03:38 +03:00
|
|
|
int runlength, runmult, lastmult, curmult;
|
|
|
|
int mult1, mult2, pair1, pair2;
|
|
|
|
BOOLEAN run;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
run = TRUE;
|
|
|
|
runlength = 1;
|
|
|
|
mult1 = 1;
|
|
|
|
pair1 = -1;
|
|
|
|
mult2 = 1;
|
|
|
|
pair2 = -1;
|
|
|
|
curmult = runmult = 1;
|
1995-03-21 18:03:38 +03:00
|
|
|
for (i = 1; i < n; i++) {
|
|
|
|
lastmult = curmult;
|
|
|
|
if (h[i].rank == h[i - 1].rank) {
|
|
|
|
if (pair1 < 0) {
|
|
|
|
pair1 = h[i].rank;
|
|
|
|
mult1 = curmult = 2;
|
|
|
|
} else {
|
|
|
|
if (h[i].rank == pair1) {
|
|
|
|
curmult = ++mult1;
|
|
|
|
} else {
|
|
|
|
if (pair2 < 0) {
|
|
|
|
pair2 = h[i].rank;
|
|
|
|
mult2 = curmult = 2;
|
|
|
|
} else {
|
|
|
|
curmult = ++mult2;
|
|
|
|
}
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1995-03-21 18:03:38 +03:00
|
|
|
if (i == (n - 1) && run) {
|
|
|
|
runmult *= curmult;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1995-03-21 18:03:38 +03:00
|
|
|
} else {
|
|
|
|
curmult = 1;
|
|
|
|
if (h[i].rank == h[i - 1].rank + 1) {
|
|
|
|
if (run) {
|
|
|
|
++runlength;
|
|
|
|
} else {
|
|
|
|
/* only if old short */
|
|
|
|
if (runlength < 3) {
|
|
|
|
run = TRUE;
|
|
|
|
runlength = 2;
|
|
|
|
runmult = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
runmult *= lastmult;
|
|
|
|
} else {
|
|
|
|
/* if just ended */
|
|
|
|
if (run)
|
|
|
|
runmult *= lastmult;
|
|
|
|
run = FALSE;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-03-21 18:03:38 +03:00
|
|
|
pairpoints = ichoose2[mult1] + ichoose2[mult2];
|
|
|
|
runpoints = (runlength >= 3 ? runlength * runmult : 0);
|
|
|
|
return (pairpoints + runpoints);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pegscore tells how many points crd would get if played after
|
|
|
|
* the n cards in tbl during pegging
|
|
|
|
*/
|
1995-03-21 18:03:38 +03:00
|
|
|
int
|
2005-07-02 12:32:32 +04:00
|
|
|
pegscore(CARD crd, const CARD tbl[], int n, int sum)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1995-03-21 18:03:38 +03:00
|
|
|
BOOLEAN got[RANKS];
|
1997-10-10 16:26:34 +04:00
|
|
|
int i, j, scr;
|
1995-03-21 18:03:38 +03:00
|
|
|
int k, lo, hi;
|
|
|
|
|
|
|
|
sum += VAL(crd.rank);
|
|
|
|
if (sum > 31)
|
|
|
|
return (-1);
|
|
|
|
if (sum == 31 || sum == 15)
|
|
|
|
scr = 2;
|
|
|
|
else
|
|
|
|
scr = 0;
|
|
|
|
if (!n)
|
|
|
|
return (scr);
|
1993-03-21 12:45:37 +03:00
|
|
|
j = 1;
|
1995-03-21 18:03:38 +03:00
|
|
|
while ((crd.rank == tbl[n - j].rank) && (n - j >= 0))
|
|
|
|
++j;
|
|
|
|
if (j > 1)
|
|
|
|
return (scr + ichoose2[j]);
|
|
|
|
if (n < 2)
|
|
|
|
return (scr);
|
1993-03-21 12:45:37 +03:00
|
|
|
lo = hi = crd.rank;
|
1995-03-21 18:03:38 +03:00
|
|
|
for (i = 0; i < RANKS; i++)
|
|
|
|
got[i] = FALSE;
|
|
|
|
got[crd.rank] = TRUE;
|
1993-03-21 12:45:37 +03:00
|
|
|
k = -1;
|
1995-03-21 18:03:38 +03:00
|
|
|
for (i = n - 1; i >= 0; --i) {
|
|
|
|
if (got[tbl[i].rank])
|
|
|
|
break;
|
|
|
|
got[tbl[i].rank] = TRUE;
|
|
|
|
if (tbl[i].rank < lo)
|
|
|
|
lo = tbl[i].rank;
|
|
|
|
if (tbl[i].rank > hi)
|
|
|
|
hi = tbl[i].rank;
|
|
|
|
for (j = lo; j <= hi; j++)
|
|
|
|
if (!got[j])
|
|
|
|
break;
|
|
|
|
if (j > hi)
|
|
|
|
k = hi - lo + 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1995-03-21 18:03:38 +03:00
|
|
|
if (k >= 3)
|
|
|
|
return (scr + k);
|
|
|
|
else
|
|
|
|
return (scr);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* adjust takes a two card hand that will be put in the crib
|
|
|
|
* and returns an adjusted normalized score for the number of
|
|
|
|
* points such a crib will get.
|
|
|
|
*/
|
1995-03-21 18:03:38 +03:00
|
|
|
int
|
2007-12-15 22:44:37 +03:00
|
|
|
adjust(const CARD cb[], CARD tnv __unused)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1995-03-21 18:03:38 +03:00
|
|
|
long scr;
|
|
|
|
int i, c0, c1;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
c0 = cb[0].rank;
|
|
|
|
c1 = cb[1].rank;
|
1995-03-21 18:03:38 +03:00
|
|
|
if (c0 > c1) {
|
|
|
|
i = c0;
|
|
|
|
c0 = c1;
|
|
|
|
c1 = i;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1995-03-21 18:03:38 +03:00
|
|
|
if (cb[0].suit != cb[1].suit)
|
|
|
|
scr = crbnescr[RANKS * c0 + c1];
|
|
|
|
else
|
|
|
|
scr = crbescr[RANKS * c0 + c1];
|
|
|
|
if (scr <= 0) {
|
|
|
|
printf("\nADJUST: internal error %d %d\n", c0, c1);
|
|
|
|
exit(93);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1995-03-21 18:03:38 +03:00
|
|
|
return ((scr + 29400) / 58800);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|