Update dependencies
This commit is contained in:
parent
1a5da6bada
commit
8b2874903a
3 changed files with 35 additions and 27 deletions
|
@ -422,21 +422,12 @@ func (c *Client) HandleEvents() {
|
|||
t = time.Now()
|
||||
}
|
||||
|
||||
boardState := tabulaBoard(Game.Board)
|
||||
|
||||
available, _ := boardState.Available(1)
|
||||
boardState.Analyze(available, &c.analysis)
|
||||
if len(c.analysis) == 0 {
|
||||
log.Printf("Legal moves: %+v", Game.Available)
|
||||
log.Fatalf("NO PLAYABLE MOVES RETURNED: %+v", c.analysis)
|
||||
}
|
||||
boardState := TabulaBoard(Game.Board)
|
||||
|
||||
if !c.quiet {
|
||||
log.Println("==========")
|
||||
log.Println("Legal moves:", Game.Available)
|
||||
|
||||
log.Println("Past:", c.analysis[0].Past)
|
||||
|
||||
builder := &strings.Builder{}
|
||||
builder.Write([]byte("Board: "))
|
||||
for i := range boardState {
|
||||
|
@ -446,6 +437,17 @@ func (c *Client) HandleEvents() {
|
|||
builder.Write([]byte(strconv.Itoa(int(boardState[i]))))
|
||||
}
|
||||
log.Println(builder.String())
|
||||
}
|
||||
|
||||
available, _ := boardState.Available(1)
|
||||
boardState.Analyze(available, &c.analysis)
|
||||
if len(c.analysis) == 0 {
|
||||
log.Printf("Legal moves: %+v", Game.Available)
|
||||
log.Fatalf("NO PLAYABLE MOVES RETURNED: %+v", c.analysis)
|
||||
}
|
||||
|
||||
if !c.quiet {
|
||||
log.Println("Past:", c.analysis[0].Past)
|
||||
|
||||
const padding = 3
|
||||
w := tabwriter.NewWriter(os.Stderr, 0, 0, padding, ' ', 0)
|
||||
|
@ -458,6 +460,9 @@ func (c *Client) HandleEvents() {
|
|||
}
|
||||
|
||||
for _, move := range c.analysis[0].Moves {
|
||||
if move[0] == 0 && move[1] == 0 {
|
||||
break
|
||||
}
|
||||
if move[0] == 0 {
|
||||
c.Out <- []byte(fmt.Sprintf("mv off/%d", move[1]))
|
||||
} else if move[0] == 25 {
|
||||
|
@ -476,9 +481,12 @@ func (c *Client) HandleEvents() {
|
|||
if Game.MayChooseRoll() {
|
||||
newGame := Game.Copy()
|
||||
for _, move := range c.analysis[0].Moves {
|
||||
newGame.AddLocalMove(move)
|
||||
if move[0] == 0 && move[1] == 0 {
|
||||
break
|
||||
}
|
||||
newGame.AddLocalMove([]int{move[0], move[1]})
|
||||
}
|
||||
newBoardState := tabulaBoard(newGame.Board)
|
||||
newBoardState := TabulaBoard(newGame.Board)
|
||||
doubles := newBoardState.ChooseDoubles(&c.analysis)
|
||||
c.Out <- []byte(fmt.Sprintf("ok %d", doubles))
|
||||
} else {
|
||||
|
@ -539,7 +547,7 @@ func (c *Client) HandleEvents() {
|
|||
}
|
||||
}
|
||||
|
||||
func tabulaBoard(b []int) tabula.Board {
|
||||
func TabulaBoard(b []int) tabula.Board {
|
||||
var roll1, roll2, roll3, roll4 int8
|
||||
roll1, roll2 = int8(Game.Roll1), int8(Game.Roll2)
|
||||
if roll1 == roll2 {
|
||||
|
@ -559,6 +567,14 @@ func tabulaBoard(b []int) tabula.Board {
|
|||
return tabula.Board{int8(b[0]), int8(b[1]), int8(b[2]), int8(b[3]), int8(b[4]), int8(b[5]), int8(b[6]), int8(b[7]), int8(b[8]), int8(b[9]), int8(b[10]), int8(b[11]), int8(b[12]), int8(b[13]), int8(b[14]), int8(b[15]), int8(b[16]), int8(b[17]), int8(b[18]), int8(b[19]), int8(b[20]), int8(b[21]), int8(b[22]), int8(b[23]), int8(b[24]), int8(b[25]), int8(b[26]), int8(b[27]), roll1, roll2, roll3, roll4, entered1, entered2, acey}
|
||||
}
|
||||
|
||||
func randInt(max int) int {
|
||||
i, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return int(i.Int64())
|
||||
}
|
||||
|
||||
var phrases = [][]byte{
|
||||
[]byte("Gadzooks! I accidentally lost by mistake."),
|
||||
[]byte("My checkers began too close to your home board."),
|
||||
|
@ -578,11 +594,3 @@ var phrases = [][]byte{
|
|||
[]byte("Alas, I could find naught but tiny rolls."),
|
||||
[]byte("No wonder thou wert victorious! I shalt abdicate."),
|
||||
}
|
||||
|
||||
func randInt(max int) int {
|
||||
i, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return int(i.Int64())
|
||||
}
|
||||
|
|
4
go.mod
4
go.mod
|
@ -3,7 +3,7 @@ module code.rocket9labs.com/tslocum/bgammon-tabula-bot
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231211185248-f939d053a819
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231212190831-bfc39a406f20
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231213071157-58ef5c9749a0
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231213214359-de3946764327
|
||||
nhooyr.io/websocket v1.8.10
|
||||
)
|
||||
|
|
8
go.sum
8
go.sum
|
@ -1,6 +1,6 @@
|
|||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231211185248-f939d053a819 h1:QUps5Kz32BpKMvVISbRZe2gtr1BYqfPOSV1UifpHADU=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231211185248-f939d053a819/go.mod h1:u3nbSwxWnwOXbCNPQD4s3abGTfvA4/gi9U626f7ZN9Q=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231212190831-bfc39a406f20 h1:Y/OwzfDQcm6FLCMKa8eMI+MjpcVDgmnHwsewd22KbHo=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231212190831-bfc39a406f20/go.mod h1:XtS6M8qcK0fnUn4k5I7h4JcZ2sz2WEAXOcF2DLaQBME=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231213071157-58ef5c9749a0 h1:fmiLaum38ux+N3F2VSAdn9k0Byh1YxhLJVPvjoQLuXg=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231213071157-58ef5c9749a0/go.mod h1:znz6dMj0MWOISPj71Z/s/EUI+ire0PVuHE/ejeXlYMY=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231213214359-de3946764327 h1:QLnBqgAxpFSyENzum6buVmnIeG9kOZib97pkcyaAbRc=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231213214359-de3946764327/go.mod h1:XtS6M8qcK0fnUn4k5I7h4JcZ2sz2WEAXOcF2DLaQBME=
|
||||
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
|
||||
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
|
||||
|
|
Loading…
Reference in a new issue