Example #1
0
	public function mutate($genome)
	{
		$index = rand(0, count($genome) - 1);
		$action = rand(0, 1);
		$genome[$index] = null;
		return $this->_music->melodyGen(Nandu_Music_MusicScales::Major(), 2, 8, 16);
	}
Example #2
0
 public function initPopulation(Nandu_Species $species = null, $count = 8)
 {
 	
 	if (null == $species) {
 		$species = new Nandu_Species();
 		$species->save();
 	}
 	
 	$music = new Nandu_Music_Theory();
 	
 	for($i = 0; $i < $count; $i++) {
 		$melody = new Nandu_Melody();
 		$melody->species_id = $species->id;
 		$melody->save();
 		$notes = $music->melodyGen(Nandu_Music_MusicScales::Major(), 2, 8, 16);
 		$melody->setNotesFromArray($notes);
 	}
 	
 	return $species;
 }