X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/462fca95471224f85b85be911e72faee16cd1597..b89a361943e53da59951cfbcb406221a2d5c4baa:/backgammon/common_source/odds.c?ds=inline diff --git a/backgammon/common_source/odds.c b/backgammon/common_source/odds.c index 02354d31..5f350a39 100644 --- a/backgammon/common_source/odds.c +++ b/backgammon/common_source/odds.c @@ -1,6 +1,8 @@ +/* $NetBSD: odds.c,v 1.4 1997/10/10 08:59:46 lukem Exp $ */ + /* - * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. + * 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 @@ -31,42 +33,48 @@ * SUCH DAMAGE. */ +#include #ifndef lint -/*static char sccsid[] = "from: @(#)odds.c 5.4 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$Id: odds.c,v 1.2 1993/08/01 18:56:42 mycroft Exp $"; +#if 0 +static char sccsid[] = "@(#)odds.c 8.1 (Berkeley) 5/31/93"; +#else +__RCSID("$NetBSD: odds.c,v 1.4 1997/10/10 08:59:46 lukem Exp $"); +#endif #endif /* not lint */ #include "back.h" -odds (r1,r2,val) -register int r1; -int r2, val; +void +odds(r1, r2, val) + int r1, r2, val; { - register int i, j; + int i, j; - if (r1 == 0) { - for (i = 0; i < 6; i++) + if (r1 == 0) { + for (i = 0; i < 6; i++) for (j = 0; j < 6; j++) table[i][j] = 0; return; - } else { + } else { r1--; - if (r2-- == 0) - for (i = 0; i < 6; i++) { + if (r2-- == 0) { + for (i = 0; i < 6; i++) { table[i][r1] += val; table[r1][i] += val; } - else { + } else { table[r2][r1] += val; table[r1][r2] += val; } } } -count () { - register int i; - register int j; - register int total; +int +count() +{ + int i; + int j; + int total; total = 0; for (i = 0; i < 6; i++) @@ -74,38 +82,38 @@ count () { total += table[i][j]; return (total); } - -canhit (i,c) -int i, c; +int +canhit(i, c) + int i, c; { - register int j, k, b; - int a, d, diff, place, addon, menstuck; + int j, k, b; + int a, diff, place, addon, menstuck; if (c == 0) - odds (0,0,0); - if (board[i] > 0) { + odds(0, 0, 0); + if (board[i] > 0) { a = -1; b = 25; - } else { + } else { a = 1; b = 0; } - place = abs (25-b-i); - menstuck = abs (board[b]); - for (j = b; j != i; j += a) { - if (board[j]*a > 0) { - diff = abs(j-i); - addon = place+((board[j]*a > 2 || j == b)? 5: 0); + place = abs(25 - b - i); + menstuck = abs(board[b]); + for (j = b; j != i; j += a) { + if (board[j] * a > 0) { + diff = abs(j - i); + addon = place + ((board[j] * a > 2 || j == b) ? 5 : 0); if ((j == b && menstuck == 1) && (j != b && menstuck == 0)) for (k = 1; k < diff; k++) - if (k < 7 && diff-k < 7 && - (board[i+a*k]*a >= 0 || - board[i+a*(diff-k)] >= 0)) - odds (k,diff-k,addon); + if (k < 7 && diff - k < 7 && + (board[i + a * k] * a >= 0 || + board[i + a * (diff - k)] >= 0)) + odds(k, diff - k, addon); if ((j == b || menstuck < 2) && diff < 7) - odds (diff,0,addon); + odds(diff, 0, addon); } if (j == b && menstuck > 1) break;