import sys from time import sleep import random sys.path.append('..') sys.path.append('../../..') import Evolife.Scenarii.Parameters as EPar import Evolife.Ecology.Observer as EO import Evolife.Ecology.Individual as EI import Evolife.Ecology.Group as EG import Evolife.Ecology.Population as EP import Evolife.QtGraphics.Evolife_Window as EW import Evolife.Tools.Tools as ET print(ET.boost()) # significantly accelerates python on some platforms from Antnet import Antnet_Observer, Node, Network, Ant, Group, Population ################################################# # Aspect of ants, food and pheromons on display ################################################# LinkAspect = ('green5', 2) # 2 = thickness AntAspect = ('black', 5) # 4 = size AntAspectWhenOld = ('red5', 4) # 4 = size PPAspect = (17, 2) # 17th colour class City(Node): def __init__(self, Name, Location): Node.__init__(self, Name, Location)
Evolife.QtGraphics.Evolife_Batch.Start(Population.One_Run, Observer) # writing header to result file open(Observer.get_info('ResultFile')+'.res','w').write(Observer.get_info('ResultHeader')) return #################### # Interactive mode #################### print __doc__ " launching window " # Evolife.QtGraphics.Evolife_Window.Start(Pop.One_Run, Observer, Capabilities='FNCP', Options=[('BackGround','grey')]) Evolife.QtGraphics.Evolife_Window.Start(Population.One_Run, Observer, Capabilities='FNCP', Options=[('BackGround','lightblue')]) print "Bye......." sleep(2.1) return if __name__ == "__main__": ET.boost() # A technical trick that sometimes provides impressive speeding up with Python up to 2.6 Observer = Social_Observer(Gbl.Parameters) # Observer contains statistics Observer.setOutputDir('___Results') Observer.recordInfo('DefaultViews', ['Field', 'Network']) # Evolife should start with that window open Pop = Population(Gbl.Param('NbAgents'), Observer) # population of agents Start(BatchMode=Gbl.Param('BatchMode')) __author__ = 'Dessalles'
for M in Ntwrk.TestMessages: for link in M.erase(): Observer.recordChanges( link, Slot='Trajectories') # display of message route Route = M.draw(MaxPath=Ntwrk.Size) self.Observer.MsgLength[M] = len(Route) for link in Route: Observer.recordChanges( link, Slot='Trajectories') # display of message route # print (year, self.AllMoved, Moves), return self.SimulationEnd > 0 # stops the simulation when True if __name__ == "__main__": print(__doc__) print(ET.boost()) # significantly accelerates python on some platforms ############################# # Global objects # ############################# Gbl = EPar.Parameters('_Params.evo') # Loading global parameter values Observer = Antnet_Observer(Gbl) # Observer contains statistics Ntwrk = Network(Size=Gbl.Parameter('DisplaySize'), NbNodes=Gbl.Parameter('NumberOfNodes')) Pop = AntPopulation(Gbl, Observer, Ntwrk.nodes()) # Ant colony # Initial draw Observer.recordInfo('FieldWallpaper', 'yellow') Observer.recordInfo('TrajectoriesWallpaper', 'lightblue') Observer.recordInfo('DefaultViews', ['Field', 'Trajectories']) Observer.recordChanges(
from time import sleep import random import cmath sys.path.append('..') sys.path.append('../../..') import Evolife.Scenarii.Parameters as EPar import Evolife.Ecology.Observer as EO import Evolife.Ecology.Individual as EI import Evolife.Ecology.Group as EG import Evolife.Ecology.Population as EP import Evolife.QtGraphics.Evolife_Window as EW import Evolife.Tools.Tools as ET import Landscapes print ET.boost() # significWalkerly accelerates python on some platforms # two functions to convert from complex numbers into (x,y) coordinates c2t = lambda c: (int(round(c.real)),int(round(c.imag))) # converts a complex into a couple t2c = lambda (x,y): complex(x,y) # converts a couple into a complex ################################################# # Aspect of Walkers and pheromone on display ################################################# # WalkerAspect = ('black', 6) # PheromonAspect = (17, 2) WalkerAspect = ('white', 1) PheromonAspect = ('white', 4)
""" Cellular Automaton: """ import sys sys.path.append('../../..') import Evolife.Ecology.Observer as EO import Evolife.QtGraphics.Evolife_Window as EW import Evolife.Tools.Tools as ET import Evolife.Scenarii.Parameters as EPar print ET.boost() # A technical trick that sometimes provides impressive speeding up import random class Rule: " defines all possible automaton rules " def __init__(self, RuleNumber): " convert the rule number into a list of bits " # For each configuration number (3-bit for three-cell neighbourhood --> 8 configurations), # the rule gives the new binary state of the cell. # Attention: the following line is only valid for 8 configurations self.Rule = [int(b) for b in list(bin(RuleNumber)[2:].rjust(8,'0'))] # example: rule 32 --> 00100000 self.Rule.reverse() # example: rule 32 --> 00000100
# -------------------------------------------------------------------------- # # License: Creative Commons BY-NC-SA # ############################################################################## """ 2D Cellular Automaton with coloring mutation: Modified by Cybill Clerger """ import sys sys.path.append('../../..') import Evolife.Ecology.Observer as EO import Evolife.QtGraphics.Evolife_Window as EW import Evolife.Tools.Tools as ET import Evolife.Scenarii.Parameters as EPar print ET.boost( ) # A technical trick that sometimes provides impressive speeding up import random import math class Rule: " defines all possible automaton rules " def __init__(self, RuleNumber): " convert the rule number into a list of bits " # For each configuration number (9-bit for nine-cell neighbourhood --> 512 configurations), # the rule gives the new binary state of the cell. self.Rule = [int(b) for b in list(bin(RuleNumber)[2:].rjust(512, '0'))] self.Rule.reverse() # if this configuration is absent at the beginning, an all-0 state emerges.