dino_game_v2.rb
# Select the two fittest individuals and the two least fit individuals

Select the two fittest individuals and the two least fit individuals
Select the two fittest individuals and the two least fit individuals
def selection(dinos)
	scores = Hash.new
	num_dinos = dinos.length
	i = 0
	while i < num_dinos
		scores[i.to_s] = dinos[i].score
		i += 1
	end
	fittest, second_fittest, least_fittest, second_least_fittest = fitness(scores)
	return [fittest, second_fittest], [least_fittest, second_least_fittest] 
end
def selection ( dinos ) scores = Hash . new num_dinos = dinos . length i = 0 while i < num_dinos scores [ i . to_s ] = dinos [ i ] . score i += 1 end fittest , second_fittest , least_fittest , second_least_fittest = fitness ( scores ) return [ fittest , second_fittest ] , [ least_fittest , second_least_fittest ] end
Select the two fittest individuals and the two least fit individuals
Select the two fittest individuals and the two least fit individuals
# Check the scores

dinos
<not_specific>