5 Commits

Author SHA1 Message Date
685bdef816 fix panic in the runtime 2022-11-19 20:10:59 +01:00
eb57a18a02 set initial params in hardcode 2022-11-16 18:57:18 +01:00
206796cf0f fix logic 2022-11-16 18:02:35 +01:00
d1bb82d2a1 write to file 2022-11-16 17:09:16 +01:00
659b913130 write to file 2022-11-15 09:05:27 +01:00
2 changed files with 29 additions and 14 deletions

View File

@ -13,4 +13,12 @@
- step: 500 - step: 500
amount: 1 amount: 1
neighbours: 1 neighbours: 1
- step: 600
amount: 500
neighbours: 50
- step: 1500
amount: 10
neighbours: 1
- step: 2000
amount: 1
neighbours: 1

31
main.go
View File

@ -22,8 +22,8 @@ import (
var windowWidth, windowHeight = 1000, 700 var windowWidth, windowHeight = 1000, 700
var goidSize = 3 var goidSize = 3
var goidColor = color.RGBA{200, 200, 100, 255} // gray, 50% transparency var goidColor = color.RGBA{200, 200, 100, 255} // gray, 50% transparency
var populationSize = 20 var populationSize = 0
var loops = 500 var loops = 3000
var numNeighbours = 5 var numNeighbours = 5
var separationFactor = float64(goidSize * 5) var separationFactor = float64(goidSize * 5)
var coherenceFactor = 8 var coherenceFactor = 8
@ -76,17 +76,20 @@ func main() {
hideCursor() hideCursor()
var goids []*Goid var goids []*Goid
for i := 0; i < populationSize; i++ { // for i := 0; i < populationSize; i++ {
g := createRandomGoid() // g := createRandomGoid()
goids = append(goids, &g) // 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, td[current_stage].Amount)
if td[current_stage].NumNeighbours >= populationSize {
numNeighbours = populationSize
} else {
numNeighbours = td[current_stage].NumNeighbours numNeighbours = td[current_stage].NumNeighbours
if i > td[current_stage].Step { }
if i == td[current_stage+1].Step {
current_stage += 1 current_stage += 1
} }
move(goids, fo, i) move(goids, fo, i)
@ -107,12 +110,15 @@ func main() {
total = goid.Goid total = goid.Goid
} }
} }
fmt.Println(total)
outfile, err := os.Create("./goids.txt")
if err != nil {
panic(err)
}
for i := 0; i <= total; i++{ for i := 0; i <= total; i++{
var x []string var x []string
var y []string var y []string
fmt.Println("GOID: ", i) outfile.Write([]byte(fmt.Sprintf("GOID: %d\n", i)))
for z := 0; z <= loops; z++ { for z := 0; z <= loops; z++ {
check := false check := false
for _, g := range output { for _, g := range output {
@ -128,8 +134,9 @@ func main() {
y = append(y, "-") 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)))
} }
} }