* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 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
static char sccsid
[] = "@(#)extra.c 8.1 (Berkeley) 5/31/93";
* Have the current player double and ask opponent to accept.
register int resp
; /* response to y/n */
writel (" doubles."); /* indicate double */
if (cturn
== -pnum
) { /* see if computer accepts */
if (dblgood()) { /* guess not */
cturn
*= -2; /* indicate loss */
} else { /* computer accepts */
gvalue
*= 2; /* double game value */
/* ask if player accepts */
writel (cturn
== 1? color
[2]: color
[3]);
/* get response from yorn,
* a "2" means he said "p"
if ((resp
= yorn ('R')) == 2) {
nexturn (); /* declined */
* Returns 1 if the computer would double in this position. This
* is not an exact science. The computer will decline a double that he
* would have made. Accumulated judgments are kept in the variable n,
* which is in "pips", i.e., the position of each man summed over all
* men, with opponent's totals negative. Thus, n should have a positive
* value of 7 for each move ahead, or a negative value of 7 for each one
register int n
; /* accumulated judgment */
register int OFFC
= *offptr
; /* no. of computer's men off */
register int OFFO
= *offopp
; /* no. of player's men off */
trace
= fopen ("bgtrace","w");
fputs ("\nDoubles:\nBoard: ",trace
);
fprintf (trace
," %d",board
[i
]);
fprintf (trace
,"\n\tpip = %d, ",n
);
/* below adjusts pip value
if (OFFC
> -15 || OFFO
> -15) {
if (OFFC
< 0 && OFFO
< 0) {
if (OFFC
< 8 && OFFO
> 8)
if (OFFC
< 10 && OFFO
> 10)
if (OFFC
< 12 && OFFO
> 12)
if (OFFO
< 8 && OFFC
> 8)
if (OFFO
< 10 && OFFC
> 10)
if (OFFO
< 12 && OFFC
> 12)
fprintf (trace
,"off = %d, ",n
);
/* see if men are trapped */
n
+= trapped(home
,-cturn
);
fprintf (trace
,"free = %d\n",n
);
fprintf (trace
,"\tOFFC = %d, OFFO = %d\n",OFFC
,OFFO
);
/* double if 2-3 moves ahead */
register int i
, inc
, lim
;
for (i
= b
+inc
; i
!= lim
; i
+= inc
)
odds(abs(b
-i
),0,abs(board
[b
]));
for (i
= n
+inc
; i
!= l
; i
+= inc
) {
if (board
[i
+inc
*j
]*inc
< -1) {
for (k
= 1; k
< 7 && k
< j
; k
++)
ct
+= abs(board
[i
])*(36-count());
for (j
= i
= 0; i
< 26; i
++)
j
+= (board
[i
] >= 0 ? i
*board
[i
] : (25-i
)*board
[i
]);