From bbec0a941eda21137e596fe3ddaa9312da55dda2 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Wed, 6 Dec 2023 17:45:24 -0800 Subject: [PATCH] Update table of pseudopip values --- DESIGN.md | 52 +++++++++++++++++++++++----------------------- analysis.go | 2 +- board.go | 10 ++++----- cmd/tabula/main.go | 15 +++++++++++++ 4 files changed, 47 insertions(+), 32 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 57977e8..ea86d17 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -97,32 +97,32 @@ lowest overall score is the best move. ## Pseudopip values -The following table lists pseudopip value of each space. Space 25 is the bar. +The following table lists the pseudopip value of each space. Space 25 is the bar. | Space | Pseudopips | | --- | --- | -| 1 | 15 | -| 2 | 16 | -| 3 | 17 | -| 4 | 20 | -| 5 | 21 | -| 6 | 24 | -| 7 | 51 | -| 8 | 52 | -| 9 | 57 | -| 10 | 60 | -| 11 | 65 | -| 12 | 70 | -| 13 | 75 | -| 14 | 82 | -| 15 | 91 | -| 16 | 100 | -| 17 | 111 | -| 18 | 126 | -| 19 | 143 | -| 20 | 164 | -| 21 | 189 | -| 22 | 220 | -| 23 | 257 | -| 24 | 302 | -| 25 | 357 | +| 1 | 9 | +| 2 | 10 | +| 3 | 11 | +| 4 | 14 | +| 5 | 15 | +| 6 | 18 | +| 7 | 57 | +| 8 | 58 | +| 9 | 63 | +| 10 | 66 | +| 11 | 71 | +| 12 | 76 | +| 13 | 81 | +| 14 | 88 | +| 15 | 97 | +| 16 | 106 | +| 17 | 117 | +| 18 | 132 | +| 19 | 149 | +| 20 | 170 | +| 21 | 195 | +| 22 | 226 | +| 23 | 263 | +| 24 | 308 | +| 25 | 363 | diff --git a/analysis.go b/analysis.go index 713b8af..0afa1c8 100644 --- a/analysis.go +++ b/analysis.go @@ -83,7 +83,7 @@ func (a *Analysis) _analyze() { move := a.Moves[i] checkers := a.Board.Checkers(o, move[1]) if checkers == 1 { - hs += pseudoPips(o, move[1]) + hs += PseudoPips(o, move[1]) } a.Board = a.Board.Move(move[0], move[1], a.player).UseRoll(move[0], move[1], a.player) } diff --git a/board.go b/board.go index c7be748..17d568e 100644 --- a/board.go +++ b/board.go @@ -327,12 +327,12 @@ func (b Board) Past() bool { func (b Board) Pips(player int) int { var pips int if player == 1 { - pips += int(b.Checkers(player, SpaceBarPlayer)) * pseudoPips(player, SpaceBarPlayer) + pips += int(b.Checkers(player, SpaceBarPlayer)) * PseudoPips(player, SpaceBarPlayer) } else { - pips += int(b.Checkers(player, SpaceBarOpponent)) * pseudoPips(player, SpaceBarOpponent) + pips += int(b.Checkers(player, SpaceBarOpponent)) * PseudoPips(player, SpaceBarOpponent) } for space := 1; space < 25; space++ { - pips += int(b.Checkers(player, space)) * pseudoPips(player, space) + pips += int(b.Checkers(player, space)) * PseudoPips(player, space) } return pips } @@ -345,7 +345,7 @@ func (b Board) Blots(player int) int { if checkers != 1 { continue } - pips += int(checkers) * pseudoPips(o, space) + pips += int(checkers) * PseudoPips(o, space) } return pips } @@ -463,7 +463,7 @@ func spaceValue(player int, space int) int { } } -func pseudoPips(player int, space int) int { +func PseudoPips(player int, space int) int { v := 6 + spaceValue(player, space) + int(math.Exp(float64(spaceValue(player, space))*0.2))*2 if (player == 1 && (space > 6 || space == SpaceBarPlayer)) || (player == 2 && (space < 19 || space == SpaceBarOpponent)) { v += 36 diff --git a/cmd/tabula/main.go b/cmd/tabula/main.go index fcbb342..adac029 100644 --- a/cmd/tabula/main.go +++ b/cmd/tabula/main.go @@ -1,6 +1,8 @@ package main import ( + "flag" + "fmt" "log" "time" @@ -8,6 +10,19 @@ import ( ) func main() { + var pips bool + flag.BoolVar(&pips, "pips", false, "Print table of pseudopip values") + flag.Parse() + + if pips { + fmt.Println("| Space | Pseudopips |") + fmt.Println("| --- | --- |") + for space := 1; space <= 25; space++ { + fmt.Printf("| %d | %d |\n", space, tabula.PseudoPips(1, space)) + } + return + } + b := tabula.NewBoard() b[tabula.SpaceRoll1] = 5 b[tabula.SpaceRoll2] = 3