30 lines
421 B
Go
30 lines
421 B
Go
|
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())
|
||
|
}
|