Subject: bin/7992: [PATCH] Backgammon scoring fix
To: None <gnats-bugs@gnats.netbsd.org>
From: Joseph Myers <jsm28@cam.ac.uk>
List: netbsd-bugs
Date: 07/14/1999 15:04:21
>Number: 7992
>Category: bin
>Synopsis: [PATCH] Backgammon scoring fix
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jul 14 14:50:01 1999
>Last-Modified:
>Originator: Joseph S. Myers
>Organization:
Trinity College, University of Cambridge, UK
>Release: NetBSD-current of 1999-06-28
>Environment:
[
System: Linux decomino 2.2.10 #1 Mon Jun 14 07:48:53 UTC 1999 i686 unknown
Architecture: i686
]
>Description:
The following bug report against backgammon(6) was received from a
user of the Linux port of the NetBSD games. A patch is appended.
Subject: Bug#35038: Backgammon incorrectly calculates the game value
From: sjl@debian.lib.monash.edu.au (Stuart Lamble)
To: submit@bugs.debian.org
Date: Thu, 25 Mar 1999 21:27:38 +1100 (EST)
Package: bsdgames
Version: 2.1-3hamm1
The rules of backgammon state that scoring is as follows (assuming that
you just won the game):
* If your opponent has born off any men, _irrespective of where
the other men are_, the game is a single game. (worth one point)
* If your opponent has not born off any men, and no of his men are
left in your inner board (from where you bear off your men), the
game is a double game (worth, obviously enough, two points).
* If your opponent has not born off any men, and at least one of
his men is either in your inner board or on the bar, the game is
a triple game (three points).
In all cases, this is multiplied by the value of the doubling cube.
If you bear off all your men, and your opponent has born off at least
one man, but has a man in your inner board (or on the bar), backgammon
incorrectly makes the game a backgammon (triple game). This patch seems
to fix it for me (nb: not really exhaustively tested, but it seems to
work.)
[Snip patch - the one I give below should do the same job, and is
shorter and simpler.]
>How-To-Repeat:
>Fix:
Apply this patch (a simplified version of the one in the original bug
report) to games/backgammon/backgammon/main.c
--- main.c.bak Sat Feb 20 23:46:26 1999
+++ main.c Sat Mar 27 21:43:29 1999
@@ -478,15 +478,14 @@
/* compute game value */
if (tflag)
curmove(20, 0);
- if (*offopp == 15) {
+ if (*offopp == 15 && *offptr <= 0) {
if (mflag) {
writel(bgammon);
gvalue *= 3;
- } else
- if (*offptr <= 0) {
- writel(gammon);
- gvalue *= 2;
- }
+ } else {
+ writel(gammon);
+ gvalue *= 2;
+ }
}
/* report situation */
if (cturn == -1) {
>Audit-Trail:
>Unformatted: