Add initial design document
This commit is contained in:
parent
89331e1220
commit
1f25e9109c
2 changed files with 36 additions and 1 deletions
33
DESIGN.md
Normal file
33
DESIGN.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Design
|
||||
|
||||
[tabula](https://code.rocket9labs.com/tslocum/tabula) is a multi-threaded backgammon analysis engine.
|
||||
To find the best move, the engine performs a series of simulations and scores the resulting game states.
|
||||
The result with the lowest score is the best move.
|
||||
|
||||
## Scoring
|
||||
|
||||
### Space value
|
||||
|
||||
Space value is defined as what the term 'pips' would normally refer to. The
|
||||
value of a space is the same as the space number as it would appear to the
|
||||
player being scored.
|
||||
|
||||
### Pseudopips
|
||||
|
||||
All scoring calculations use pseudopips.
|
||||
|
||||
A pseudopip value is assigned to each board space as follows:
|
||||
|
||||
- Each space is worth 6 pseudopips plus **double the space value**.
|
||||
- Spaces outside of the player's home board are worth an additional 6 pseudopips.
|
||||
|
||||
Space 2 (from the perspective of the player being scored) is therefore worth 10
|
||||
pseudopips, space 6 is worth 18, space 7 is worth 26 and the bar space is worth 62.
|
||||
|
||||
## Analysis
|
||||
|
||||
### Step 1: Simulate all legal move available to the player
|
||||
|
||||
### Step 2: Simulate all opponent dice rolls and opponent moves that may follow the above simulations
|
||||
|
||||
### Step 3: Sort simulation results by score
|
4
board.go
4
board.go
|
@ -501,7 +501,9 @@ func opponent(player int) int {
|
|||
}
|
||||
|
||||
func spaceValue(player int, space int) int {
|
||||
if player == 1 {
|
||||
if space == SpaceBarPlayer || space == SpaceBarOpponent {
|
||||
return 25
|
||||
} else if player == 1 {
|
||||
return space
|
||||
} else {
|
||||
return 25 - space
|
||||
|
|
Loading…
Reference in a new issue