Disable automatically playing forced moves

This commit is contained in:
Trevor Slocum 2024-01-10 21:21:49 -08:00
parent c677af3320
commit cf312f82fe
3 changed files with 15 additions and 5 deletions

View file

@ -90,7 +90,7 @@ func (c *Client) logIn() []byte {
if c.Username != "" && c.Password != "" {
loginInfo = fmt.Sprintf("%s %s", strings.ReplaceAll(c.Username, " ", "_"), strings.ReplaceAll(c.Password, " ", "_"))
}
return []byte(fmt.Sprintf("lj bgammon-tabula-bot %s\nlist\n", loginInfo))
return []byte(fmt.Sprintf("lj bgammon-tabula-bot %s\nset autoplay 0\n", loginInfo))
}
func (c *Client) LoggedIn() bool {
@ -417,6 +417,16 @@ func (c *Client) HandleEvents() {
continue
}
if Game.MayChooseRoll() {
if c.thinkTime != 0 {
time.Sleep(c.thinkTime)
}
doubles := TabulaBoard(Game.Board).ChooseDoubles(&c.analysis)
c.Out <- []byte(fmt.Sprintf("ok %d", doubles))
c.lastActivity = time.Now()
continue
}
if len(Game.Moves) != 0 {
continue
} else if len(Game.Available) == 0 {
@ -490,7 +500,7 @@ func (c *Client) HandleEvents() {
}
}
if Game.MayChooseRoll() {
newGame := Game.Copy()
newGame := Game.Copy(false)
for _, move := range c.analysis[0].Moves {
if move[0] == 0 && move[1] == 0 {
break

2
go.mod
View file

@ -3,7 +3,7 @@ module code.rocket9labs.com/tslocum/bgammon-tabula-bot
go 1.17
require (
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240108183627-118a7f78eb98
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240111071346-3eb433e57356
code.rocket9labs.com/tslocum/tabula v0.0.0-20240108183445-695ea428ae21
nhooyr.io/websocket v1.8.10
)

4
go.sum
View file

@ -1,7 +1,7 @@
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b h1:Y0a14Kf/hSYepSmp4ZfDeE4CZZGBGBS97CNjCbKJm0c=
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240108183627-118a7f78eb98 h1:6lndXAeTooxepIWtpVWOhEFjig6DVh6bkVaWJVtrmX4=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240108183627-118a7f78eb98/go.mod h1:0DTOM6NviKJsDDBANcB7hbk2fseN5qtHJZAFeKsnAPQ=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240111071346-3eb433e57356 h1:7D4HYPNbhugFbnRgACpvbAzzzElY9McrDsGyMnzLz6M=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240111071346-3eb433e57356/go.mod h1:65vhSKgeQb6ccjUm5NJlbBdwuAH3VSFoSApZ/aVG3+4=
code.rocket9labs.com/tslocum/tabula v0.0.0-20240108183445-695ea428ae21 h1:1VG88tdhCSVv7wGoIKQe8A8KfBXJsdz5pDsyP4ymDwk=
code.rocket9labs.com/tslocum/tabula v0.0.0-20240108183445-695ea428ae21/go.mod h1:WEJXESKXqrMFLAArikQ79lpRibNeeE1C0VruxXYMF5M=
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=