Example #1
0
func crearIndividuo(cp modelo.ColoresPrendas) (ind Individuo) {
	ind.Genotipo = make([]modelo.FormaColor, 4)
	for i := 0; i < 4; i++ {
		ind.Genotipo[i] = cp.GetRandom(i)
	}
	ind.evaluar()
	return ind
}
Example #2
0
func TestCrearPoblacion(t *testing.T) {
	prendas := 20
	cp := modelo.ColoresPrendas{}
	cp.Calzado = make([]modelo.FormaColor, prendas)
	cp.Chamarra = make([]modelo.FormaColor, prendas)
	cp.Pantalon = make([]modelo.FormaColor, prendas)
	cp.Playera = make([]modelo.FormaColor, prendas)
	for i := 0; i < prendas; i++ {
		cp.Calzado[i].Tono = rand.Intn(prendas)
		cp.Chamarra[i].Tono = rand.Intn(prendas)
		cp.Pantalon[i].Tono = rand.Intn(prendas)
		cp.Playera[i].Tono = rand.Intn(prendas)
		cp.Calzado[i].Brillo = rand.Intn(5)
		cp.Chamarra[i].Brillo = rand.Intn(5)
		cp.Pantalon[i].Brillo = rand.Intn(5)
		cp.Playera[i].Brillo = rand.Intn(5)
	}
	mejores := Genetico(cp)
	fmt.Println("\nLo mejor de lo mejor de lo mejor de lo mejor de lo mejor de lo mejor de lo mejor de lo mejor:\n", mejores[0], "\n", mejores[1], "\n", mejores[2])
}
Example #3
0
func (ind *Individuo) mutar(cp modelo.ColoresPrendas) {
	p := rand.Intn(4)
	ind.Genotipo[p] = cp.GetRandom(p)
}