Compare commits
7 Commits
v0.0.2-dev
...
v0.0.8-dev
Author | SHA1 | Date | |
---|---|---|---|
c0e37c3183 | |||
3db36407ea | |||
685bdef816 | |||
eb57a18a02 | |||
206796cf0f | |||
d1bb82d2a1 | |||
659b913130 |
40
config.yaml
40
config.yaml
@ -1,16 +1,30 @@
|
||||
last_step: 100
|
||||
init_amount: 10
|
||||
steps:
|
||||
- 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
|
||||
neighbours: 1
|
||||
|
||||
- step: 20
|
||||
amount: 100
|
||||
neighbours: 1
|
||||
- step: 30
|
||||
amount: 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
|
||||
|
41
main.go
41
main.go
@ -22,12 +22,17 @@ import (
|
||||
var windowWidth, windowHeight = 1000, 700
|
||||
var goidSize = 3
|
||||
var goidColor = color.RGBA{200, 200, 100, 255} // gray, 50% transparency
|
||||
var populationSize = 20
|
||||
var loops = 500
|
||||
var populationSize = 0
|
||||
var loops = 3000
|
||||
var numNeighbours = 5
|
||||
var separationFactor = float64(goidSize * 5)
|
||||
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"`
|
||||
Amount int `yaml:"amount"`
|
||||
@ -65,8 +70,11 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
td := []steps{}
|
||||
err = yaml.Unmarshal(conf, &td)
|
||||
config := configuration{}
|
||||
err = yaml.Unmarshal(conf, &config)
|
||||
steps := config.Steps
|
||||
loops = config.LastStep
|
||||
populationSize = config.InitAmount
|
||||
defer func() {
|
||||
if err := fo.Close(); err != nil {
|
||||
panic(err)
|
||||
@ -75,18 +83,19 @@ 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, td[current_stage].Amount)
|
||||
numNeighbours = td[current_stage].NumNeighbours
|
||||
if i > td[current_stage].Step {
|
||||
goids, populationSize = fixGoids(goids, populationSize, steps[current_stage].Amount)
|
||||
if steps[current_stage].NumNeighbours >= populationSize {
|
||||
numNeighbours = populationSize
|
||||
} else {
|
||||
numNeighbours = steps[current_stage].NumNeighbours
|
||||
}
|
||||
if i == steps[current_stage+1].Step {
|
||||
current_stage += 1
|
||||
}
|
||||
move(goids, fo, i)
|
||||
@ -107,12 +116,15 @@ func main() {
|
||||
total = goid.Goid
|
||||
}
|
||||
}
|
||||
fmt.Println(total)
|
||||
|
||||
outfile, err := os.Create("./goids.txt")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for i := 0; i <= total; i++ {
|
||||
var x []string
|
||||
var y []string
|
||||
fmt.Println("GOID: ", i)
|
||||
outfile.Write([]byte(fmt.Sprintf("GOID: %d\n", i)))
|
||||
for z := 0; z <= loops; z++ {
|
||||
check := false
|
||||
for _, g := range output {
|
||||
@ -128,8 +140,9 @@ func main() {
|
||||
y = append(y, "-")
|
||||
}
|
||||
}
|
||||
fmt.Printf("%v\n", x)
|
||||
fmt.Printf("%v\n", y)
|
||||
|
||||
outfile.Write([]byte(fmt.Sprintf("%v\n", x)))
|
||||
outfile.Write([]byte(fmt.Sprintf("%v\n", y)))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user