Update replay format

This commit is contained in:
Trevor Slocum 2023-12-16 10:04:05 -08:00
parent 764c491c5b
commit c9af675820
2 changed files with 72 additions and 4 deletions

View file

@ -1,6 +1,6 @@
# Specification of bgammon.org replay file
Replays are stored as .match files.
Replays are stored as .match files with lines separated by newline characters only (no carriage-return characters).
## Match format (.match)
@ -46,6 +46,58 @@ Declined:
##### Roll and move
Moves are always specified from player 1's perspective.
Moves for both players are specified from player 1's perspective. The highest roll value is specified first.
`1 r 5-3 13/8 24/21`
When no moves are possible, only the roll is specified.
`1 r 4-4`
## Example .match file
```
bgammon-replay 00000024
i 1702738670 Guest_385 BOT_tabula 1 0 0 1 1 0
1 r 4-1 13/9 9/8
2 r 1-6 1/7 1/2
1 r 5-6 13/7 7/2
2 r 3-3 bar/3 bar/3 12/15 12/15
1 r 6-2 8/2 8/6
2 r 5-2 12/14 14/19
1 r 4-4 24/20 20/16 24/20 20/16
2 r 4-5 3/7 7/12
1 r 3-5 16/13 13/8
2 r 1-5 3/4 4/9
1 r 2-1 16/14 14/13
2 r 5-1 9/10 10/15
1 r 1-1 6/5 6/5 8/7 8/7
2 r 6-2 19/21 15/21
1 r 4-4 13/9 13/9 13/9 13/9
2 r 1-5 15/20 12/13
1 r 4-6 9/3 7/3
2 r 2-5 17/19 15/20
1 r 6-2 7/1 6/4
2 r 4-5 17/22 17/21
1 r 4-3 8/5 5/1
2 r 3-1 12/15 12/13
1 r 6-3 9/3 9/6
2 r 2-4 15/19 13/15
1 r 3-1 9/8 8/5
2 r 2-5 15/20 13/15
1 r 6-5 5/off 6/off
2 r 3-1 15/16 16/19
1 r 5-1 5/off 1/off
2 r 3-1 22/off 19/20
1 r 6-5 6/off 5/off
2 r 4-4 21/off 21/off 21/off 19/23
1 r 1-5 6/5 5/off
2 r 5-6 20/off 19/off
1 r 6-3 6/off 3/off
2 r 3-2 23/off 19/22
1 r 5-4 4/off 3/off
2 r 2-4 19/23 23/off
1 r 6-3 3/off 2/off
2 r 5-1 20/off 19/20
1 r 1-2 1/off 2/off
```

View file

@ -1294,7 +1294,15 @@ COMMANDS:
}
clientGame.replay = append([][]byte{[]byte(fmt.Sprintf("i %d %s %s %d %d %d %d %d %d", clientGame.Started.Unix(), clientGame.Player1.Name, clientGame.Player2.Name, clientGame.Points, clientGame.Player1.Points, clientGame.Player2.Points, clientGame.Winner, winPoints, acey))}, clientGame.replay...)
clientGame.replay = append(clientGame.replay, []byte(fmt.Sprintf("%d r %d-%d %s", clientGame.Turn, clientGame.Roll1, clientGame.Roll2, bgammon.FormatMoves(clientGame.Moves))))
r1, r2 := clientGame.Roll1, clientGame.Roll2
if r2 > r1 {
r1, r2 = r2, r1
}
var movesFormatted []byte
if len(clientGame.Moves) != 0 {
movesFormatted = append([]byte(" "), bgammon.FormatMoves(clientGame.Moves)...)
}
clientGame.replay = append(clientGame.replay, []byte(fmt.Sprintf("%d r %d-%d%s", clientGame.Turn, r1, r2, movesFormatted)))
winEvent = &bgammon.EventWin{
Points: winPoints * clientGame.DoubleValue,
@ -1436,7 +1444,15 @@ COMMANDS:
}
recordEvent := func() {
clientGame.replay = append(clientGame.replay, []byte(fmt.Sprintf("%d r %d-%d %s", clientGame.Turn, clientGame.Roll1, clientGame.Roll2, bgammon.FormatMoves(clientGame.Moves))))
r1, r2 := clientGame.Roll1, clientGame.Roll2
if r2 > r1 {
r1, r2 = r2, r1
}
var movesFormatted []byte
if len(clientGame.Moves) != 0 {
movesFormatted = append([]byte(" "), bgammon.FormatMoves(clientGame.Moves)...)
}
clientGame.replay = append(clientGame.replay, []byte(fmt.Sprintf("%d r %d-%d%s", clientGame.Turn, r1, r2, movesFormatted)))
}
if clientGame.Acey && ((clientGame.Roll1 == 1 && clientGame.Roll2 == 2) || (clientGame.Roll1 == 2 && clientGame.Roll2 == 1)) && len(clientGame.Moves) == 2 {