-/* $NetBSD: score.c,v 1.14 2009/06/04 04:48:04 dholland Exp $ */
+/* $NetBSD: score.c,v 1.17 2019/02/03 10:48:46 mrg Exp $ */
/*-
* Copyright (c) 1980, 1993
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: score.c,v 1.14 2009/06/04 04:48:04 dholland Exp $");
+__RCSID("$NetBSD: score.c,v 1.17 2019/02/03 10:48:46 mrg Exp $");
#endif
#endif /* not lint */
#include "deck.h"
#include "cribbage.h"
+static int fifteens(const CARD [], int);
+static int pairuns(const CARD [], int);
+
/*
* 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
*/
-const long crbescr[169] = {
+static const long crbescr[169] = {
-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, -10000, -10000, -10000, -10000, -10000
};
-const long crbnescr[169] = {
+static const long crbnescr[169] = {
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,
int hscore;
BOOLEAN flag;
CARD h[(CINHAND + 1)];
- char buf[32];
+ char buf[52];
explan[0] = '\0'; /* initialize explanation */
hscore = 0;
* fifteens:
* Return number of fifteens in hand of n cards
*/
-int
+static int
fifteens(const CARD hand[], int n)
{
int *sp, *np;
* this routine only works if n is strictly less than 6
* sets the globals pairpoints and runpoints appropriately
*/
-int
+static int
pairuns(const CARD h[], int n)
{
int i;
* the n cards in tbl during pegging
*/
int
-pegscore(CARD crd, const CARD tbl[], int n, int sum)
+pegscore(CARD crd, const CARD tbl[], unsigned n, int sum)
{
BOOLEAN got[RANKS];
int i, j, scr;
int k, lo, hi;
+ unsigned ju;
sum += VAL(crd.rank);
if (sum > 31)
scr = 0;
if (!n)
return (scr);
- j = 1;
- while ((crd.rank == tbl[n - j].rank) && (n - j >= 0))
- ++j;
- if (j > 1)
- return (scr + ichoose2[j]);
+ ju = 1;
+ while (ju <= n && crd.rank == tbl[n - ju].rank)
+ ++ju;
+ if (ju > 1)
+ return (scr + ichoose2[ju]);
if (n < 2)
return (scr);
lo = hi = crd.rank;