This commit is contained in:
a 2023-07-05 23:24:27 +01:00
parent ef5261b577
commit 169a87fccc
1 changed files with 20 additions and 0 deletions

View File

@ -10,11 +10,17 @@ func (c *CountReward) ResetTo(size int) {
c.Counts = make([]int, size)
}
c.Counts = c.Counts[:size]
for idx := range c.Counts {
c.Counts[idx] = 0
}
if len(c.Rewards) > size {
c.Rewards = make([]float64, size)
}
c.Rewards = c.Rewards[:size]
for idx := range c.Rewards {
c.Rewards[idx] = 0
}
}
func (c *CountReward) Count(res *[]int) {
@ -27,9 +33,23 @@ func (c *CountReward) Count(res *[]int) {
}
(*res) = (*res)[:len(c.Counts)]
copy(*res, c.Counts)
}
func (c *CountReward) CountSum() (i int) {
for _, v := range c.Counts {
i = i + v
}
return i
}
func (c *CountReward) CountReward() (i int) {
for _, v := range c.Counts {
i = i + v
}
return i
}
func (c *CountReward) Reward(res *[]float64) {
if res == nil {
r := make([]float64, len(c.Rewards))