| 117 | } |
| 118 | |
| 119 | func (model *Model) Step(shapeType ShapeType, alpha, repeat int) int { |
| 120 | state := model.runWorkers(shapeType, alpha, 1000, 100, 16) |
| 121 | // state = HillClimb(state, 1000).(*State) |
| 122 | model.Add(state.Shape, state.Alpha) |
| 123 | |
| 124 | for i := 0; i < repeat; i++ { |
| 125 | state.Worker.Init(model.Current, model.Score) |
| 126 | a := state.Energy() |
| 127 | state = HillClimb(state, 100).(*State) |
| 128 | b := state.Energy() |
| 129 | if a == b { |
| 130 | break |
| 131 | } |
| 132 | model.Add(state.Shape, state.Alpha) |
| 133 | } |
| 134 | |
| 135 | // for _, w := range model.Workers[1:] { |
| 136 | // model.Workers[0].Heatmap.AddHeatmap(w.Heatmap) |
| 137 | // } |
| 138 | // SavePNG("heatmap.png", model.Workers[0].Heatmap.Image(0.5)) |
| 139 | |
| 140 | counter := 0 |
| 141 | for _, worker := range model.Workers { |
| 142 | counter += worker.Counter |
| 143 | } |
| 144 | return counter |
| 145 | } |
| 146 | |
| 147 | func (model *Model) runWorkers(t ShapeType, a, n, age, m int) *State { |
| 148 | wn := len(model.Workers) |