gambit/example/simple/main.go

30 lines
421 B
Go
Raw Normal View History

2023-07-06 09:10:29 +00:00
package main
import (
"log"
"lukechampine.com/frand"
"tuxpa.in/a/gambit"
"tuxpa.in/a/gambit/algo"
)
func main() {
g := &gambit.Gang{}
b := &algo.EpsilonGreedy{Epsilon: 0.1}
b.Reset(4)
g.WithBandit(b)
n := 100
for i := 0; i < n; i++ {
b.Update(
// select a random arm
b.Select(frand.Float64()),
// and supply a random score
float64(frand.Intn(4)),
)
}
log.Println(g.AllocateSolution())
}