def fitnessCalculator(genome,type,games,popSize,preyPop,predPop): totalTurns = 0 print(genome) if type == 'predator': for i in range(games): index = random.randint(0,popSize - 1) print('game', i) totalTurns += hunt(genome, preyPop[index][0], 10000, False) else: for i in range(games): index = random.randint(0,popSize - 1) print('game', i) totalTurns += hunt(predPop[index][0], genome, 10000, False) return totalTurns/games
def fitnessCalculator(genome,games): totalTurns = 0 print(genome) for i in range(games): print('game', i) totalTurns += hunt([0.1,0.9,0.0,0.0,0.0,0.1,0.9,0.0,0.0,0.0,0.1,0.9,0.0,0.0,0.0,0.1,0.9,0.0,0.0,0.0], genome, 10000, False) return totalTurns/games
from hunt import * print hunt( [1,0,0,0,0, 1,0,0,0,0, 1,0,0,0,0, 1,0,0,0,0], [0,0,0,0,1, 0,0,0,0,1, 0,0,0,0,1, 0,0,0,0,1], 250, True)
from __future__ import print_function from numpy import * from scipy import stats from hunt import * import pylab import copy total = 0 games = 1 predGenome = [0.1,0.9,0.0,0.0,0.0,0.1,0.9,0.0,0.0,0.0,0.1,0.9,0.0,0.0,0.0,0.1,0.9,0.0,0.0,0.0] preyGenome = [0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0] for i in range(games): total += hunt(predGenome,preyGenome,10000,False) print(total/games)
from hunt import * print hunt( [0.226,0.079,0.309,0.244,0.142, 0.050,0.067,0.272,0.324,0.286, 0.478,0.310,0.075,0.100,0.036, 0.028,0.407,0.102,0.217,0.247], [0,0,0,0,1, 0,0,0,0,1, 0,0,0,0,1, 0,0,0,0,1], 1000, True)
print hunt( [ 0.154, 0.482, 0.180, 0.164, 0.019, 0.583, 0.171, 0.158, 0.077, 0.011, 0.161, 0.360, 0.107, 0.236, 0.136, 0.081, 0.729, 0.082, 0.067, 0.090, ], [ 0.016, 0.231, 0.454, 0.259, 0.004, 0.242, 0.586, 0.008, 0.050, 0.114, 0.058, 0.285, 0.424, 0.031, 0.202, 0.501, 0.043, 0.095, 0.293, 0.068, ], 1000, True, )
def fitnessCalculator(genome,games): totalTurns = 0 print(genome) for i in range(games): totalTurns += hunt(genome, [0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0], 5000, False) return totalTurns/games
def fitnessCalculator(preyGenome, predGenome): fitness = hunt(predGenome, preyGenome, 10000, False) return fitness
from hunt import * print hunt( [0.1,0,0.9,0,0, 0.1,0,0.9,0,0, 0.1,0,0.9,0,0, 0.1,0,0.9,0,0], [0,0,1,0,0, 0,0,1,0,0, 0,0,1,0,0, 0,0,1,0,0], 250, True)
from hunt import * print hunt( [0.1,0.9,0,0,0, 0.1,0.9,0,0,0, 0.1,0.9,0,0,0, 0.1,0.9,0,0,0], [0.079,0.233,0.347,0.282,0.058, 0.240,0.450,0.045,0.163,0.101, 0.249,0.244,0.174,0.063,0.269, 0.148,0.421,0.192,0.146,0.093], 1000, True)