bgammon-tabula-bot/main.go

46 lines
1.3 KiB
Go

package main
import (
"flag"
"fmt"
"log"
"time"
"net/http"
_ "net/http/pprof"
"code.rocket9labs.com/tslocum/bgammon-tabula-bot/bot"
"code.rocket9labs.com/tslocum/tabula"
)
func main() {
var (
serverAddress string
username string
password string
points int
thinkTime time.Duration
debug int
)
flag.StringVar(&serverAddress, "address", "bgammon.org:1337", "Server address")
flag.StringVar(&username, "username", "", "Username")
flag.StringVar(&password, "password", "", "Password")
flag.IntVar(&points, "points", 1, "Match points")
flag.Float64Var(&tabula.WeightBlot, "weight-blot", tabula.WeightBlot, "Weight (multiplier) when scoring blots")
flag.Float64Var(&tabula.WeightHit, "weight-hit", tabula.WeightHit, "Weight (multiplier) when scoring hits")
flag.Float64Var(&tabula.WeightOppScore, "weight-score", tabula.WeightOppScore, "Weight (multiplier) when adding opponent score to overall score")
flag.DurationVar(&thinkTime, "think", 0, "Minimum think time")
flag.IntVar(&debug, "debug", 0, "Port to serve debug information on (pprof)")
flag.Parse()
if debug > 0 {
go func() {
log.Fatal(http.ListenAndServe(fmt.Sprintf("localhost:%d", debug), nil))
}()
}
c := bot.NewClient(serverAddress, username, password, points, thinkTime)
go c.Connect()
c.HandleEvents()
}