add init_amount to config

This commit is contained in:
Nikolai Rodionov 2022-12-01 22:12:05 +01:00
parent 3db36407ea
commit c0e37c3183
2 changed files with 7 additions and 1 deletions

View File

@ -1,4 +1,5 @@
last_step: 100
init_amount: 10
steps:
- step: 10
amount: 1

View File

@ -31,6 +31,7 @@ var coherenceFactor = 8
type configuration struct {
Steps []steps `yaml:"steps"`
LastStep int `yaml:"last_step"`
InitAmount int `yaml:"init_amount"`
}
type steps struct {
Step int `yaml:"step"`
@ -73,6 +74,7 @@ func main() {
err = yaml.Unmarshal(conf, &config)
steps := config.Steps
loops = config.LastStep
populationSize = config.InitAmount
defer func() {
if err := fo.Close(); err != nil {
panic(err)
@ -81,7 +83,10 @@ func main() {
clearScreen()
hideCursor()
var goids []*Goid
for i := 0; i < populationSize; i++ {
g := createRandomGoid()
goids = append(goids, &g)
}
current_stage := 0
for i := 0; i < loops; i++ {
goids, populationSize = fixGoids(goids, populationSize, steps[current_stage].Amount)