func (manager *NetworkManager) NextGeneration() {
	manager.SortNetworksByFitness()

	population := manager.Population()
	nextGeneration := make([]Network, population)
	fmt.Printf("Network[0] fitness: %.0f        \n", manager.Networks[0].Fitness)
	fmt.Printf("Network[1] fitness: %.0f        \n", manager.Networks[1].Fitness)
	fmt.Printf("Network[2] fitness: %.0f        \n", manager.Networks[2].Fitness)
	fmt.Print("\033[4A")
	for networkIndex := 0; networkIndex < population; networkIndex++ {
		p := float32(networkIndex) / float32(population)
		if networkIndex == 0 {
			nextGeneration[networkIndex] = manager.Networks[0]
		} else if p < 0.5 {
			nextGeneration[networkIndex] = manager.Networks[0].Mutated()
		} else if p < 0.8 {
			nextGeneration[networkIndex] = manager.Networks[1].Mutated()
		} else if p < 0.9 {
			nextGeneration[networkIndex] = manager.Networks[2].Mutated()
		} else {
			// new Neural Network for the rest
			nextGeneration[networkIndex] = NewNetwork(manager.layers, manager.randomProvider)
		}
	}

	manager.Networks = nextGeneration
	manager.generationNumber++
}
// NextGeneration creates new generation of Neural Networks based on
// top performing networks (fitness):
// - top performer is recreated in the new generation
// - top performer mutants are assigned to 50% slots of the new generation
// - 2nd top performer mutants are assigned to 30% slots of the new generation
// - 3rd top performer mutants are assigned to 10% slots of the new generation
// - the rest slots of the new generation are filled with randomized networks
NextGeneration creates new generation of Neural Networks based on
top performing networks (fitness):
- top performer is recreated in the new generation
- top performer mutants are assigned to 50% slots of the new generation
- 2nd top performer mutants are assigned to 30% slots of the new generation
- 3rd top performer mutants are assigned to 10% slots of the new generation
- the rest slots of the new generation are filled with randomized networks
// NextGeneration creates new generation of Neural Networks based on // top performing networks ( fitness ) : // - top performer is recreated in the new generation // - top performer mutants are assigned to 50% slots of the new generation // - 2nd top performer mutants are assigned to 30% slots of the new generation // - 3rd top performer mutants are assigned to 10% slots of the new generation // - the rest slots of the new generation are filled with randomized networks
func (manager *NetworkManager) NextGeneration() {
	manager.SortNetworksByFitness()
	population := manager.Population()
	nextGeneration := make([]Network, population)
	fmt.Printf("Network[0] fitness: %.0f        \n", manager.Networks[0].Fitness)
	fmt.Printf("Network[1] fitness: %.0f        \n", manager.Networks[1].Fitness)
	fmt.Printf("Network[2] fitness: %.0f        \n", manager.Networks[2].Fitness)
	fmt.Print("\033[4A")
	for networkIndex := 0; networkIndex < population; networkIndex++ {
		p := float32(networkIndex) / float32(population)
		if networkIndex == 0 {
			nextGeneration[networkIndex] = manager.Networks[0]
		} else if p < 0.5 {
			nextGeneration[networkIndex] = manager.Networks[0].Mutated()
		} else if p < 0.8 {
			nextGeneration[networkIndex] = manager.Networks[1].Mutated()
		} else if p < 0.9 {
			nextGeneration[networkIndex] = manager.Networks[2].Mutated()
		} else {
			nextGeneration[networkIndex] = NewNetwork(manager.layers, manager.randomProvider)
		}
	}
	manager.Networks = nextGeneration
	manager.generationNumber++
}
func ( manager * NetworkManager ) NextGeneration ( ) { manager . SortNetworksByFitness ( ) population := manager . Population ( ) nextGeneration := make ( [ ] Network , population ) fmt . Printf ( " \n " , manager . Networks [ 0 ] . Fitness ) fmt . Printf ( " \n " , manager . Networks [ 1 ] . Fitness ) fmt . Printf ( " \n " , manager . Networks [ 2 ] . Fitness ) fmt . Print ( " \033 " ) for networkIndex := 0 ; networkIndex < population ; networkIndex ++ { p := float32 ( networkIndex ) / float32 ( population ) if networkIndex == 0 { nextGeneration [ networkIndex ] = manager . Networks [ 0 ] } else if p < 0.5 { nextGeneration [ networkIndex ] = manager . Networks [ 0 ] . Mutated ( ) } else if p < 0.8 { nextGeneration [ networkIndex ] = manager . Networks [ 1 ] . Mutated ( ) } else if p < 0.9 { nextGeneration [ networkIndex ] = manager . Networks [ 2 ] . Mutated ( ) } else { nextGeneration [ networkIndex ] = NewNetwork ( manager . layers , manager . randomProvider ) } } manager . Networks = nextGeneration manager . generationNumber ++ }
NextGeneration creates new generation of Neural Networks based on
top performing networks (fitness):
 top performer is recreated in the new generation
 top performer mutants are assigned to 50% slots of the new generation
 2nd top performer mutants are assigned to 30% slots of the new generation
 3rd top performer mutants are assigned to 10% slots of the new generation
 the rest slots of the new generation are filled with randomized networks
NextGeneration creates new generation of Neural Networks based on top performing networks ( fitness ) : top performer is recreated in the new generation top performer mutants are assigned to 50% slots of the new generation 2nd top performer mutants are assigned to 30% slots of the new generation 3rd top performer mutants are assigned to 10% slots of the new generation the rest slots of the new generation are filled with randomized networks
// new Neural Network for the rest