fix panic in the runtime

This commit is contained in:
Nikolai Rodionov 2022-11-19 20:10:59 +01:00
parent eb57a18a02
commit 685bdef816

View File

@ -22,7 +22,7 @@ import (
var windowWidth, windowHeight = 1000, 700
var goidSize = 3
var goidColor = color.RGBA{200, 200, 100, 255} // gray, 50% transparency
var populationSize = 10
var populationSize = 0
var loops = 3000
var numNeighbours = 5
var separationFactor = float64(goidSize * 5)
@ -85,7 +85,7 @@ func main() {
for i := 0; i < loops; i++ {
goids, populationSize = fixGoids(goids, populationSize, td[current_stage].Amount)
if td[current_stage].NumNeighbours >= populationSize {
numNeighbours = populationSize - 1
numNeighbours = populationSize
} else {
numNeighbours = td[current_stage].NumNeighbours
}