diff --git a/helper/storage.go b/helper/storage.go index 37e3234..f26748e 100644 --- a/helper/storage.go +++ b/helper/storage.go @@ -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))