#!/usr/bin/python eta = 1.5 peaks = [1,4,9,16,25,36,49,64,81,100] print "# peaks = " + str(peaks) print "# eta = " + str(eta) for spot in range(101): shortest_distance = 999 # Just some initial value that will be erased over for peak in peaks: distance = abs(spot - peak) if distance < shortest_distance: shortest_distance = distance if shortest_distance == 0 : fitness = eta * 1.0 else: fitness = eta * (1.0 / shortest_distance) # print str(spot) + "\t" + str(shortest_distance) + "\t" + str(fitness) print str(spot) + "\t" + str(fitness) + "\t" + str(shortest_distance)