示例#1
0
func TestTriangleRenderer(t *testing.T) {
	gnm := ga.NewGenomeInt(9 * 15)
	rst := graphics.CreateRaster(50, 10)

	tr := NewTriangleRenderer(gnm, rst)
	gnm.Randomize()
	tr.Render()
	//fmt.Println(tr.Raster)
	graphics.PrintRaster(tr.Raster)
}
示例#2
0
func TestAsymmetry(t *testing.T) {
	rst := graphics.CreateRaster(4, 4)
	rst.SetColor(graphics.Color{255, 255, 255})
	var as uint32

	as = Asymmetry(rst)
	t.Log(as)
	if as > 0 {
		t.Error("assymetry is wrong")
	}
	rst.DrawPoint(2, 1)
	as = Asymmetry(rst)
	t.Log(as)
	if as <= 0 {
		t.Error("assymetry is wrong")
	}
	rst.DrawPoint(1, 1)
	as = Asymmetry(rst)
	t.Log(as)
	if as > 0 {
		t.Error("assymetry is wrong")
	}
}
示例#3
0
文件: main.go 项目: jsmarkus/goart
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)

}