Backgammon tools in J: 2. Wastage
Vector 24:4, page 106
Transcribed from the printed issue; not yet reviewed.
J programs are presented as analytical tools for expert backgammon. Part 2 here develops a program to compute the number of pips expected to be wasted while bearing off pieces in one inner board (without contact).
The inner board is represented as a list of six integers. For example, 0 pieces on the 1, 2, and 3 points, 2 on the 4-point, 3 on the 5, and 4 on the 6:
To count pips for bearing off, sum the board times a list of the point numbers:
Use program N (from [1]) to compute expected number of rolls to bear off:
Expected number of pips to bear off is the expected number of rolls n times the average number of pips per roll (8 1/6):
Wastage is this expected number of pips minus the pipcount.
Define a program to compute wastage for any inner board:
For the example above:
Wastage for all possible full distributions (with all 15 pieces) in the inner board follows:
(See Appendix for an alternative way to generate these boards using partitions.)
Wastages for all full inner boards are:
The minimum wastage is:
The board with minimal wastage is:
Other distributions can be searched similarly:
| # Pieces | #Boards | Minimum Wastage | Best board |
|---|---|---|---|
| 15 | 15504 | 7.06895 | 0 0 0 3 5 7 |
| 14 | 11628 | 7.02941 | 0 0 0 3 5 6 |
| 13 | 8568 | 6.98028 | 0 0 0 3 4 6 |
| 12 | 6188 | 6.90551 | 0 0 0 2 4 6 |
| 11 | 4368 | 6.82085 | 0 0 0 2 4 5 |
| 10 | 3003 | 6.75322 | 0 0 0 2 3 5 |
| 9 | 2002 | 6.62895 | 0 0 0 2 3 4 |
| 8 | 1287 | 6.51014 | 0 0 0 1 3 4 |
| 7 | 792 | 6.36102 | 0 0 0 1 3 3 |
| 6 | 462 | 6.14734 | 0 0 0 1 2 3 |
| 5 | 252 | 5.88967 | 0 0 0 1 2 2 |
| 4 | 126 | 5.52802 | 0 0 0 1 1 2 |
| 3 | 56 | 5.30579 | 0 0 0 1 1 1 |
| 2 | 21 | 4.62037 | 1 0 1 0 0 0 |
| 1 | 6 | 4.20833 | 0 0 0 0 0 1 |
Reference¶
- Peelle, Howard A. “Backgammon Tools in J: 1. Bearoff Expected Rolls”, Vector, Vol.24, N°2
Appendix¶
Program to compute wastage:
See [1] for script with definition of N to compute expected number of rolls to bear off.
Co-recursive program to compute all partitions of an integer x into y parts:
ELSE =: `
WHEN =: @.
Partitions =: ;@AllParts
AllParts =: <@Parts"0 >:@i.
Parts =: Ps ELSE (,.@[) WHEN (]=1:)
Ps =: Add1 ELSE (#1:) WHEN =
Add1 =: 1: + ] {."1 - Partitions - <. ]
For example:
Program to produce a table of permutations:
All full distributions of 15 pieces on 6 points in an inner board:
Number of full inner boards:
All wastages:
Average wastage:
Minimal wastage:
Board with minimal wastage:
Top ten minimal boards: