/
main.go
44 lines (36 loc) · 830 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"github.com/jsmarkus/goart/analytics"
"github.com/jsmarkus/goart/app"
"github.com/jsmarkus/goart/ga"
"github.com/jsmarkus/goart/graphics"
)
const NG = 100000
func experiment(pipe chan string) {
var generation [NG]*ga.GenomeInt
for i := 0; i < NG; i++ {
genome := ga.NewGenomeInt(5 * 9)
genome.Randomize()
generation[i] = genome
}
raster := graphics.CreateRaster(10, 10)
renderer := app.NewTriangleRenderer(raster)
for i := 0; i < NG; i++ {
renderer.Render(generation[i])
as := analytics.Asymmetry(raster)
if as <= 1000 {
pipe <- fmt.Sprintf("%d: as=%d\n", i, as)
//fmt.Printf("%d: as=%d\n", i, as)
//graphics.PrintRaster(raster)
}
}
close(pipe)
}
func main() {
pipe := make(chan string)
go experiment(pipe)
for msg := range pipe {
fmt.Println(msg)
}
}