add last_step to config file
This commit is contained in:
parent
685bdef816
commit
3db36407ea
41
config.yaml
41
config.yaml
@ -1,24 +1,29 @@
|
|||||||
|
last_step: 100
|
||||||
|
steps:
|
||||||
- step: 10
|
- step: 10
|
||||||
amount: 100
|
|
||||||
neighbours: 1
|
|
||||||
- step: 100
|
|
||||||
amount: 100
|
|
||||||
neighbours: 50
|
|
||||||
- step: 200
|
|
||||||
amount: 500
|
|
||||||
neighbours: 20
|
|
||||||
- step: 400
|
|
||||||
amount: 10
|
|
||||||
neighbours: 5
|
|
||||||
- step: 500
|
|
||||||
amount: 1
|
amount: 1
|
||||||
neighbours: 1
|
neighbours: 1
|
||||||
- step: 600
|
- step: 20
|
||||||
amount: 500
|
amount: 100
|
||||||
neighbours: 50
|
|
||||||
- step: 1500
|
|
||||||
amount: 10
|
|
||||||
neighbours: 1
|
neighbours: 1
|
||||||
- step: 2000
|
- step: 30
|
||||||
amount: 1
|
amount: 1
|
||||||
neighbours: 1
|
neighbours: 1
|
||||||
|
- step: 40
|
||||||
|
amount: 10
|
||||||
|
neighbours: 2
|
||||||
|
- step: 50
|
||||||
|
Amount: 2
|
||||||
|
neighbours: 1
|
||||||
|
- step: 60
|
||||||
|
amount: 2
|
||||||
|
neighbours: 1
|
||||||
|
- step: 70
|
||||||
|
amount: 3
|
||||||
|
neighbours: 2
|
||||||
|
- step: 80
|
||||||
|
amount: 3
|
||||||
|
neighbours: 1
|
||||||
|
- step: 3000
|
||||||
|
amount: 3
|
||||||
|
neighbours: 1
|
||||||
|
23
main.go
23
main.go
@ -28,6 +28,10 @@ var numNeighbours = 5
|
|||||||
var separationFactor = float64(goidSize * 5)
|
var separationFactor = float64(goidSize * 5)
|
||||||
var coherenceFactor = 8
|
var coherenceFactor = 8
|
||||||
|
|
||||||
|
type configuration struct {
|
||||||
|
Steps []steps `yaml:"steps"`
|
||||||
|
LastStep int `yaml:"last_step"`
|
||||||
|
}
|
||||||
type steps struct {
|
type steps struct {
|
||||||
Step int `yaml:"step"`
|
Step int `yaml:"step"`
|
||||||
Amount int `yaml:"amount"`
|
Amount int `yaml:"amount"`
|
||||||
@ -65,8 +69,10 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
td := []steps{}
|
config := configuration{}
|
||||||
err = yaml.Unmarshal(conf, &td)
|
err = yaml.Unmarshal(conf, &config)
|
||||||
|
steps := config.Steps
|
||||||
|
loops = config.LastStep
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := fo.Close(); err != nil {
|
if err := fo.Close(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -76,20 +82,15 @@ func main() {
|
|||||||
hideCursor()
|
hideCursor()
|
||||||
var goids []*Goid
|
var goids []*Goid
|
||||||
|
|
||||||
// for i := 0; i < populationSize; i++ {
|
|
||||||
// g := createRandomGoid()
|
|
||||||
// goids = append(goids, &g)
|
|
||||||
// }
|
|
||||||
|
|
||||||
current_stage := 0
|
current_stage := 0
|
||||||
for i := 0; i < loops; i++ {
|
for i := 0; i < loops; i++ {
|
||||||
goids, populationSize = fixGoids(goids, populationSize, td[current_stage].Amount)
|
goids, populationSize = fixGoids(goids, populationSize, steps[current_stage].Amount)
|
||||||
if td[current_stage].NumNeighbours >= populationSize {
|
if steps[current_stage].NumNeighbours >= populationSize {
|
||||||
numNeighbours = populationSize
|
numNeighbours = populationSize
|
||||||
} else {
|
} else {
|
||||||
numNeighbours = td[current_stage].NumNeighbours
|
numNeighbours = steps[current_stage].NumNeighbours
|
||||||
}
|
}
|
||||||
if i == td[current_stage+1].Step {
|
if i == steps[current_stage+1].Step {
|
||||||
current_stage += 1
|
current_stage += 1
|
||||||
}
|
}
|
||||||
move(goids, fo, i)
|
move(goids, fo, i)
|
||||||
|
Loading…
Reference in New Issue
Block a user