def mutate(self): """Mutates the directed graph. The mutation adds a random connection, removes a random connection, and mutates the parameters of a random connection and node.""" connections = breve.objectList() nodes = breve.objectList() m = 0 n = 0 connection = None nodes = self.rootNode.getConnectedNodes() n = breve.randomExpression((breve.length(nodes) - 1)) m = breve.randomExpression((breve.length(nodes) - 1)) connection = nodes[n].connect(nodes[m], []) connection.setParameterLength(self._connParamCount) connection.randomizeParameters() m = breve.randomExpression((breve.length(nodes) - 1)) connections = nodes[m].getConnections() if breve.length(connections) > 1: connections.pop(breve.randomExpression((breve.length(connections) - 1))) m = breve.randomExpression((breve.length(nodes) - 1)) connections = nodes[m].getConnections() if breve.length(connections): connections[breve.randomExpression((breve.length(connections) - 1))].mutate() m = breve.randomExpression((breve.length(nodes) - 1)) nodes[m].mutate()
def __init__( self ): breve.Control.__init__( self ) self.numBirds = 150 self.numPred = 25 self.num_dead_birds = 0 self.num_dead_predators = 0 # World self.minX = -50 self.maxX = 50 self.minY = -50 self.maxY = 50 self.delta = 1 # Feeder self.maxFoodSupply = 400 self.minCreatedFoodSupply = 15 self.maxCreatedFoodSupply = 25 self.totalFoodSupply = 0 # List self.prob_mutation = 0.05 self.pollBirds = breve.objectList() self.pollPredators = breve.objectList() # Other thing Swarm.init( self )
def __init__( self ): breve.Control.__init__( self ) self.numBirds = 150 self.numPred = 25 self.num_dead_birds = 0 self.num_dead_predators = 0 # World self.minX = -50 self.maxX = 50 self.minY = -50 self.maxY = 50 self.delta = 1 # Feeder self.maxFoodSupply = 600 self.minCreatedFoodSupply = 15 self.maxCreatedFoodSupply = 25 self.totalFoodSupply = 0 # List self.pollBirds = breve.objectList() self.pollPredators = breve.objectList() # Other thing Swarm.init( self )
def __init__(self): breve.Object.__init__(self) self.ampShifts = breve.objectList() self.limbLengths = breve.objectList() self.phaseShifts = breve.objectList() self.waveCompression = 0 MonkeyGenome.init(self)
def __init__( self ): breve.Control.__init__( self ) self.numBirds = 150 self.numPred = 25 self.num_dead_birds = 0 self.num_dead_predators = 0 # World self.minX = -50 self.maxX = 50 self.minY = -50 self.maxY = 50 self.delta = 1 # Feeder self.maxFoodSupply = 600 self.minCreatedFoodSupply = 15 self.maxCreatedFoodSupply = 25 self.totalFoodSupply = 0 # List self.current_generation = 0 self.breeding_season = 50 self.breeding_inc = 0.5 self.max_pop_predadors = 0.5 self.pollBirds = breve.objectList() self.pollPredators = breve.objectList() # Other thing Swarm.init( self )
def __init__( self ): breve.Object.__init__( self ) self.ampShifts = breve.objectList() self.limbLengths = breve.objectList() self.phaseShifts = breve.objectList() self.waveCompression = 0 MonkeyGenome.init( self )
def __init__(self): breve.Control.__init__(self) self.numBirds = 150 self.numPred = 25 self.num_dead_birds = 0 self.num_dead_predators = 0 # World self.minX = -50 self.maxX = 50 self.minY = -50 self.maxY = 50 self.delta = 1 # Feeder self.maxFoodSupply = 600 self.minCreatedFoodSupply = 15 self.maxCreatedFoodSupply = 25 self.totalFoodSupply = 0 # List self.current_generation = 0 self.breeding_season = 50 self.breeding_inc = 0.5 self.max_pop_predadors = 0.5 self.prob_mutation = 0.05 self.pollBirds = breve.objectList() self.pollPredators = breve.objectList() # Other thing Swarm.init(self)
def mutate(self): '''Mutates the directed graph. The mutation adds a random connection, removes a random connection, and mutates the parameters of a random connection and node.''' connections = breve.objectList() nodes = breve.objectList() m = 0 n = 0 connection = None nodes = self.rootNode.getConnectedNodes() n = breve.randomExpression((breve.length(nodes) - 1)) m = breve.randomExpression((breve.length(nodes) - 1)) connection = nodes[n].connect(nodes[m], []) connection.setParameterLength(self._connParamCount) connection.randomizeParameters() m = breve.randomExpression((breve.length(nodes) - 1)) connections = nodes[m].getConnections() if (breve.length(connections) > 1): connections.pop( breve.randomExpression((breve.length(connections) - 1))) m = breve.randomExpression((breve.length(nodes) - 1)) connections = nodes[m].getConnections() if breve.length(connections): connections[breve.randomExpression( (breve.length(connections) - 1))].mutate() m = breve.randomExpression((breve.length(nodes) - 1)) nodes[m].mutate()
def __init__(self): breve.MultiBody.__init__(self) self.bodyLink = None self.bodyShape = None self.joints = breve.objectList() self.linkShape = None self.links = breve.objectList() self.lowerLinkShape = None
def __init__( self ): breve.MultiBody.__init__( self ) self.bodyLink = None self.bodyShape = None self.joints = breve.objectList() self.linkShape = None self.links = breve.objectList() self.lowerLinkShape = None
def __init__( self ): breve.MultiBody.__init__( self ) self.bodyLink = None self.bodyShape = None self.sensorShape = None self.sensors = breve.objectList() self.wheelShape = None self.wheels = breve.objectList() BraitenbergVehicle.init( self )
def __init__(self): breve.MultiBody.__init__(self) self.bodyLink = None self.bodyShape = None self.sensorShape = None self.sensors = breve.objectList() self.wheelShape = None self.wheels = breve.objectList() BraitenbergVehicle.init(self)
def __init__(self): breve.PhysicalControl.__init__(self) self.currentSeat = 0 self.floor = None self.lockMenu = None self.locked = 0 self.monkeys = breve.objectList() self.seats = breve.objectList() self.wigglyThing = None Walker.init(self)
def __init__( self ): breve.PhysicalControl.__init__( self ) self.currentSeat = 0 self.lockMenu = None self.locked = 0 self.monkeys = breve.objectList() self.seats = breve.objectList() self.terrain = None self.walker = None Walker.init( self )
def __init__( self ): breve.PhysicalControl.__init__( self ) self.currentSeat = 0 self.floor = None self.lockMenu = None self.locked = 0 self.monkeys = breve.objectList() self.seats = breve.objectList() self.wigglyThing = None Walker.init( self )
def parse(self, root, n, rootNode, f=0.000000): connections = breve.objectList() nodeParams = breve.objectList() connectionParams = breve.objectList() joint = None childNode = None child = None norm = breve.vector() size = breve.vector() point = breve.vector() ppoint = breve.vector() cpoint = breve.vector() jointRange = 0 connections = root.getConnections() nodeParams = root.getParameters() size = ((3.000000 * breve.vector(breve.length(nodeParams[0]), breve.length(nodeParams[1]), breve.length(nodeParams[2]))) + breve.vector(0.500000, 0.500000, 0.500000)) if (((self._linkCount > 20) or (n > 6)) or ((n > 1) and (nodeParams[9] < 0.000000))): return 0 for child in connections: childNode = self.createNode(child.getTarget(), (n + 1)) if childNode: connectionParams = child.getParameters() point = breve.vector(connectionParams[0], connectionParams[1], connectionParams[2]) if f: point.x = (point.x * -1) point.x = (point.x * size.x) point.y = (point.y * size.y) point.z = (point.z * size.z) cpoint = childNode.getShape().getPointOnShape(point) ppoint = rootNode.getShape().getPointOnShape((-point)) norm = breve.vector(connectionParams[4], connectionParams[5], connectionParams[6]) norm = (norm / breve.length(norm)) if f: norm.x = (norm.x * -1) joint = breve.createInstances(breve.SineJoint, 1) joint.link(norm, ppoint, cpoint, childNode, rootNode) joint.setPhaseshift(((n * 3.140000) * connectionParams[7])) joint.setFrequency((0.100000 + connectionParams[8])) jointRange = (0.500000 + (1 * breve.length(connectionParams[9]))) joint.setDoubleSpring(jointRange, (-jointRange), 1) joint.setStrengthLimit(1000) self.parse(child.getTarget(), (n + 1), childNode) return rootNode
def parse( self, root, n, rootNode, f = 0.000000 ): connections = breve.objectList() nodeParams = breve.objectList() connectionParams = breve.objectList() joint = None childNode = None child = None norm = breve.vector() size = breve.vector() point = breve.vector() ppoint = breve.vector() cpoint = breve.vector() jointRange = 0 connections = root.getConnections() nodeParams = root.getParameters() size = ( ( 3.000000 * breve.vector( breve.length( nodeParams[ 0 ] ), breve.length( nodeParams[ 1 ] ), breve.length( nodeParams[ 2 ] ) ) ) + breve.vector( 0.500000, 0.500000, 0.500000 ) ) if ( ( ( self._linkCount > 20 ) or ( n > 6 ) ) or ( ( n > 1 ) and ( nodeParams[ 9 ] < 0.000000 ) ) ): return 0 for child in connections: childNode = self.createNode( child.getTarget(), ( n + 1 ) ) if childNode: connectionParams = child.getParameters() point = breve.vector( connectionParams[ 0 ], connectionParams[ 1 ], connectionParams[ 2 ] ) if f: point.x = ( point.x * -1 ) point.x = ( point.x * size.x ) point.y = ( point.y * size.y ) point.z = ( point.z * size.z ) cpoint = childNode.getShape().getPointOnShape( point ) ppoint = rootNode.getShape().getPointOnShape( ( -point ) ) norm = breve.vector( connectionParams[ 4 ], connectionParams[ 5 ], connectionParams[ 6 ] ) norm = ( norm / breve.length( norm ) ) if f: norm.x = ( norm.x * -1 ) joint = breve.createInstances( breve.SineJoint, 1 ) joint.link( norm, ppoint, cpoint, childNode, rootNode ) joint.setPhaseshift( ( ( n * 3.140000 ) * connectionParams[ 7 ] ) ) joint.setFrequency( ( 0.100000 + connectionParams[ 8 ] ) ) jointRange = ( 0.500000 + ( 1 * breve.length( connectionParams[ 9 ] ) ) ) joint.setDoubleSpring( jointRange, ( -jointRange ), 1 ) joint.setStrengthLimit( 1000 ) self.parse( child.getTarget(), ( n + 1 ), childNode ) return rootNode
def __init__( self ): breve.Object.__init__( self ) self._abortFitnessTest = 0 self._abortFitnessValue = 0 self._bestOfGen = None self._solutionCountsGeneration = breve.objectList() self._solutionCountsTotal = breve.objectList() self._solutionRatesGeneration = breve.objectList() self._solutionRatesTotal = breve.objectList() self._totalErrors = 0 self._totalSize = 0 self._useChallenges = 0 self.crossoverPercent = 0 self.current = breve.objectList() self.currentFitnessTest = 0 self.currentIndividual = 0 self.deletionPercent = 0 self.fitnessTestDuration = 0 self.generation = 0 self.generationLimit = 0 self.inited = 0 self.interpreter = None self.mutationPercent = 0 self.next = breve.objectList() self.pop1 = breve.objectList() self.pop2 = breve.objectList() self.populationSize = 0 self.seed = '' self.spatialRadius = 0 self.tournamentSize = 0 PushGP.init( self )
def __init__(self): breve.Object.__init__(self) self._abortFitnessTest = 0 self._abortFitnessValue = 0 self._bestOfGen = None self._solutionCountsGeneration = breve.objectList() self._solutionCountsTotal = breve.objectList() self._solutionRatesGeneration = breve.objectList() self._solutionRatesTotal = breve.objectList() self._totalErrors = 0 self._totalSize = 0 self._useChallenges = 0 self.crossoverPercent = 0 self.current = breve.objectList() self.currentFitnessTest = 0 self.currentIndividual = 0 self.deletionPercent = 0 self.fitnessTestDuration = 0 self.generation = 0 self.generationLimit = 0 self.inited = 0 self.interpreter = None self.mutationPercent = 0 self.next = breve.objectList() self.pop1 = breve.objectList() self.pop2 = breve.objectList() self.populationSize = 0 self.seed = '' self.spatialRadius = 0 self.tournamentSize = 0 PushGP.init(self)
def __init__( self ): breve.Control.__init__( self ) self.chemicals = breve.objectList() self.colors = breve.objectList() self.cube = None self.diffusion = None self.inflow = None self.reactionRates = breve.objectList() self.reactions = breve.objectList() self.rgb = breve.objectList() self.temp = None self.tempreact = None self.texture = None self.totalConcentration = None GS.init( self )
def __init__(self): breve.Control.__init__(self) self.chemicals = breve.objectList() self.colors = breve.objectList() self.cube = None self.diffusion = None self.inflow = None self.reactionRates = breve.objectList() self.reactions = breve.objectList() self.rgb = breve.objectList() self.temp = None self.tempreact = None self.texture = None self.totalConcentration = None GS.init(self)
def getAllConnectedLinks( self ): '''Returns all of the OBJECT(Link) objects which comprise the MultiBody.''' links = breve.objectList() allObjects = breve.objectList() link = None allObjects = self.getAllConnectedObjects() for link in allObjects: if link.isA( 'Link' ): links.append( link ) return links
def get3dMooreNeighborhood( self ): '''Returns a list of the 3D Moore neighbors of this patch. The 3D Moore neighborhood consists of the 26 patches adjacent to this patch, including diagonally, in three dimensions. <P> If you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.''' result = breve.objectList() z = 0 y = 0 x = 0 patch = None x = -1 while ( x <= 1 ): y = -1 while ( y <= 1 ): z = -1 while ( z <= 1 ): patch = self.grid.getPatchAt( ( x + self.xIndex ), ( y + self.yIndex ), ( z + self.zIndex ) ) if ( patch and ( patch != self ) ): result.append( patch ) z = ( z + 1 ) y = ( y + 1 ) x = ( x + 1 ) return result
def dearchive( self ): handler = breve.objectList() self.setCollisionShape( self.collisionShape ) self.setDisplayShape( self.displayShape ) self.move( self.archiveLocation ) self.setRotationMatrix( self.archiveRotation ) for handler in self.collisionHandlerList: if handler[ 1 ]: breve.breveInternalFunctionFinder.addCollisionHandler( self, self, handler[ 0 ], handler[ 1 ] ) if handler[ 2 ]: breve.breveInternalFunctionFinder.setIgnoreCollisionsWith( self, self, handler[ 0 ], 1 ) if self.archiveTextureImage: self.setTextureImage( self.archiveTextureImage ) if self.archiveLightmapImage: self.setLightmap( self.archiveLightmapImage ) if self.archiveBitmapImage: self.setBitmapImage( self.archiveBitmapImage ) self.setTextureScaleX( self.archiveTextureScaleX ) self.setTextureScaleY( self.archiveTextureScaleY ) self.setNeighborhoodSize( self.neighborhoodSize ) self.setColor( self.color ) breve.breveInternalFunctionFinder.realSetCollisionProperties( self, self.realWorldPointer, self.e, self.mu ) return breve.Object.dearchive( self )
def report( self, bestIndividual ): '''Logs information to the output at every generation. This method may be overridden to provide more (or less) output data. <P> The argument bestIndividual is the best individual in the population and is provided so that it may be inspected by the user if this method is overridden.''' bestFitness = 0 errors = breve.objectList() n = 0 self._totalSize = ( self._totalSize / self.populationSize ) self._totalErrors = ( self._totalErrors / self.populationSize ) bestFitness = bestIndividual.getFitness() errors = bestIndividual.getErrors() print ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;' print ''';; -*- Report at generation %s''' % ( self.generation ) print ''';; Best Individual: ''' print bestIndividual.getString() print ''';; Errors for best individual: ''', errors print ''';; Problem solution rates this generation: ''', self._solutionRatesGeneration print ''';; Problem solution rates all generations: ''', self._solutionRatesTotal print ''';; Total errors for best individual: %s''' % ( bestFitness ) print ''';; Size of best individual (points):''', bestIndividual.getSize() print ';;' print ''';; Average total errors in population: %s''' % ( self._totalErrors ) print ''';; Average program size in population (points): %s''' % ( self._totalSize ) print '' self.controller.setDisplayText( '''Best Fitness: %s''' % ( bestFitness ), -0.900000, -0.900000, 2 )
def untrack( self, theDiffusable ): '''Removes a OBJECT(PatchChemcial) from the patch grid.''' chem = None newChems = breve.objectList() if self.chemicalConcentrationMatrix[ theDiffusable ]: breve.deleteInstances( self.chemicalConcentrationMatrix[ theDiffusable ] ) for chem in self.chemicals: if ( chem != theDiffusable ): newChems.append( chem ) self.chemicals = newChems for chem in self.diffusingChemicals: if ( chem != theDiffusable ): newChems.append( chem ) self.diffusingChemicals = newChems for chem in self.linearlyDecayingChemicals: if ( chem != theDiffusable ): newChems.append( chem ) self.linearlyDecayingChemicals = newChems for chem in self.exponentiallyDecayingChemicals: if ( chem != theDiffusable ): newChems.append( chem ) self.exponentiallyDecayingChemicals = newChems
def get3dMooreNeighborhood(self): '''Returns a list of the 3D Moore neighbors of this patch. The 3D Moore neighborhood consists of the 26 patches adjacent to this patch, including diagonally, in three dimensions. <P> If you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.''' result = breve.objectList() z = 0 y = 0 x = 0 patch = None x = -1 while (x <= 1): y = -1 while (y <= 1): z = -1 while (z <= 1): patch = self.grid.getPatchAt((x + self.xIndex), (y + self.yIndex), (z + self.zIndex)) if (patch and (patch != self)): result.append(patch) z = (z + 1) y = (y + 1) x = (x + 1) return result
def selectParent(self, specie): birds = breve.objectList() for item in breve.allInstances(specie): if item.isAlive: birds.append(item) parent = self.tournament(birds, 5) return parent
def closestOther( self ): others = breve.objectList() item = None closestDistance = 0 thisDistance = 0 closestOther = None for item in self.getNeighbors(): if item.isA( 'Bird' ): if ( self.isFriend( item ) == 0 ): others.append( item ) if ( breve.length( others ) < 1 ): closestOther = self else: closestDistance = 1000000 for item in others: thisDistance = breve.length( ( item.getLocation() - self.getLocation() ) ) if ( thisDistance < closestDistance ): closestDistance = thisDistance closestOther = item return closestOther
def __init__( self ): breve.Object.__init__( self ) self.menus = breve.objectList() self.multibodyPointer = None self.rootLink = None self.selfCollisions = 0 MultiBody.init( self )
def report(self, bestIndividual): '''Logs information to the output at every generation. This method may be overridden to provide more (or less) output data. <P> The argument bestIndividual is the best individual in the population and is provided so that it may be inspected by the user if this method is overridden.''' bestFitness = 0 errors = breve.objectList() n = 0 self._totalSize = (self._totalSize / self.populationSize) self._totalErrors = (self._totalErrors / self.populationSize) bestFitness = bestIndividual.getFitness() errors = bestIndividual.getErrors() print ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;' print ''';; -*- Report at generation %s''' % (self.generation) print ''';; Best Individual: ''' print bestIndividual.getString() print ''';; Errors for best individual: ''', errors print ''';; Problem solution rates this generation: ''', self._solutionRatesGeneration print ''';; Problem solution rates all generations: ''', self._solutionRatesTotal print ''';; Total errors for best individual: %s''' % (bestFitness) print ''';; Size of best individual (points):''', bestIndividual.getSize( ) print ';;' print ''';; Average total errors in population: %s''' % ( self._totalErrors) print ''';; Average program size in population (points): %s''' % ( self._totalSize) print '' self.controller.setDisplayText('''Best Fitness: %s''' % (bestFitness), -0.900000, -0.900000, 2)
def __init__( self ): breve.Control.__init__( self ) self.m1 = None self.m2 = None self.m3 = None self.particles = breve.objectList() Fountain.init( self )
def __init__(self, size = breve.vector(7,1,4)): breve.MultiBody.__init__(self) self.sensors = breve.objectList() self.wheels = breve.objectList() self.bodyShape = breve.createInstances(breve.Cube, 1) self.bodyShape.initWith(size) self.bodyShape.setDensity(self.getDensity()) self.bodyLink = breve.createInstances(breve.Link, 1) self.bodyLink.setShape(self.bodyShape) self.bodyLink.setMu(-1.000000) self.bodyLink.setET(0.800000) self.setRoot(self.bodyLink) self.setTextureScale(1.500000)
def createNode(self, root, n): rootNode = None nodeParams = breve.objectList() size = breve.vector() scaleFactor = 0 self._linkCount = (self._linkCount + 1) if ((n > 6) or (self._linkCount > 20)): return 0 nodeParams = root.getParameters() scaleFactor = (((6 + 1) - ((0.500000 + (0.450000 * breve.length(nodeParams[10]))) * n)) / (6 + 1)) rootNode = breve.createInstances(breve.CreaturesLink, 1) rootNode.move(breve.vector(0, 15, 0)) rootNode.setColor((scaleFactor * breve.vector(1, 1, 1))) size = ((6 * breve.vector(breve.length(nodeParams[0]), breve.length(nodeParams[1]), breve.length(nodeParams[2]))) + breve.vector(0.300000, 0.300000, 0.300000)) rootNode.setColor( breve.vector(breve.length(nodeParams[3]), breve.length(nodeParams[4]), breve.length(nodeParams[5]))) rootNode.setShape( breve.createInstances(breve.Cube, 1).initWith( (scaleFactor * size))) rootNode.setTextureImage(self.controller.getBlockTexture()) return rootNode
def send(self, message): qtest = 0 agents = breve.objectList() i = None col = 0 col = breve.randomExpression(100) self.updatePos() self.draw.clear() agents = breve.allInstances("basicAgent") self.draw.setColor(breve.vector(1, 0, 0)) self.draw.drawLine(self.getLocation(), (self.getLocation() + (self.getRotation() * breve.vector(0, 0, 27)))) for i in agents: if (i != self.owner): qtest = ( 233 * breve.breveInternalFunctionFinder.calculateQualityToObject( self, self.realWorldPointer_owner, self.getLocation(), self.getRotation(), i.getRealWorldPointer(), self.sensorType)) self.draw.setColor(breve.vector(0, 0, 0)) if (qtest > self.communicationThreshold): i.receiveMessage2(message, self.getOwner())
def clear( self ): patch = None patchList = breve.objectList() patchList = self.patches.getPatches() for patch in patchList: patch.setState( 0 )
def randomize(self): patch = None patchList = breve.objectList() patchList = self.patches.getPatches() for patch in patchList: patch.setState(breve.randomExpression(1))
def closestFriend( self ): friends = breve.objectList() item = None closestDistance = 0 thisDistance = 0 closestFriend = None for item in self.getNeighbors(): if item.isA( 'Bird' ): if self.isFriend( item ): friends.append( item ) if ( breve.length( friends ) < 1 ): closestFriend = self else: closestDistance = 1000000 for item in friends: thisDistance = breve.length( ( item.getLocation() - self.getLocation() ) ) if ( thisDistance < closestDistance ): closestDistance = thisDistance closestFriend = item return closestFriend
def clear(self): patch = None patchList = breve.objectList() patchList = self.patches.getPatches() for patch in patchList: patch.setState(0)
def dearchive(self): handler = breve.objectList() self.setCollisionShape(self.collisionShape) self.setDisplayShape(self.displayShape) self.move(self.archiveLocation) self.setRotationMatrix(self.archiveRotation) for handler in self.collisionHandlerList: if handler[1]: breve.breveInternalFunctionFinder.addCollisionHandler( self, self, handler[0], handler[1]) if handler[2]: breve.breveInternalFunctionFinder.setIgnoreCollisionsWith( self, self, handler[0], 1) if self.archiveTextureImage: self.setTextureImage(self.archiveTextureImage) if self.archiveLightmapImage: self.setLightmap(self.archiveLightmapImage) if self.archiveBitmapImage: self.setBitmapImage(self.archiveBitmapImage) self.setTextureScaleX(self.archiveTextureScaleX) self.setTextureScaleY(self.archiveTextureScaleY) self.setNeighborhoodSize(self.neighborhoodSize) self.setColor(self.color) breve.breveInternalFunctionFinder.realSetCollisionProperties( self, self.realWorldPointer, self.e, self.mu) return breve.Object.dearchive(self)
def randomize( self ): patch = None patchList = breve.objectList() patchList = self.patches.getPatches() for patch in patchList: patch.setState( breve.randomExpression( 1 ) )
def selectParent( self, specie): birds = breve.objectList() for item in breve.allInstances( specie ): if item.isAlive: birds.append( item ) parent = self.tournament(birds, 5) return parent
def send(self, message): qtest = 0 agents = breve.objectList() i = None col = 0 col = breve.randomExpression(100) self.updatePos() self.draw.clear() agents = breve.allInstances("basicAgent") self.draw.setColor(breve.vector(1, 0, 0)) self.draw.drawLine(self.getLocation(), (self.getLocation() + (self.getRotation() * breve.vector(0, 0, 27)))) for i in agents: if i != self.owner: qtest = 233 * breve.breveInternalFunctionFinder.calculateQualityToObject( self, self.realWorldPointer_owner, self.getLocation(), self.getRotation(), i.getRealWorldPointer(), self.sensorType, ) self.draw.setColor(breve.vector(0, 0, 0)) if qtest > self.communicationThreshold: i.receiveMessage2(message, self.getOwner())
def __init__( self ): breve.MultiBody.__init__( self ) self.joint = None self.links = breve.objectList() self.shape = None self.smallShape = None self.worldJoint = None JointTestBody.init( self )
def __init__( self ): breve.Control.__init__( self ) self.autoCameraMenu = None self.autoCameraMode = 0 self.birds = breve.objectList() self.breveTexture = 0 self.cloudTexture = None self.deaths = 0 self.doMutations = 0 self.drawEveryFrameMenu = None self.feeders = breve.objectList() self.item = None self.iteration = 0 self.manualCameraMenu = None self.selection = None self.skipFramesIfNecessaryMenu = None Swarm.init( self )
def __init__(self): breve.Control.__init__(self) self.autoCameraMenu = None self.autoCameraMode = 0 self.birds = breve.objectList() self.breveTexture = 0 self.cloudTexture = None self.deaths = 0 self.doMutations = 0 self.drawEveryFrameMenu = None self.feeders = breve.objectList() self.item = None self.iteration = 0 self.manualCameraMenu = None self.selection = None self.skipFramesIfNecessaryMenu = None Swarm.init(self)
def __init__( self ): breve.BraitenbergControl.__init__( self ) self.body = None self.depth = None self.frameCount = 0 self.leftFrontWheel = None self.leftRearWheel = None self.leftSpeed = 0 self.neighbours = breve.objectList() self.rightFrontWheel = None self.rightRearWheel = None self.rightSpeed = 0 self.stepfield = breve.objectList() self.vehicle = None self.video = None self.wheels = breve.objectList() BraitenbergStepfield.init( self )
def __init__(self): breve.Drawing.__init__(self) self.currentColor = breve.vector() self.currentDirection = breve.vector() self.penDown = 0 self.states = breve.objectList() self.turtle = None TurtleDrawing.init(self)
def __init__( self ): breve.Control.__init__( self ) self.showCorpse = True self.isToLoad = False self.isToSave = False self.isToRecord = True self.movie = None # Simulation self.initialNumPreys = 150 self.initialNumPredators = 25 self.numPreys = 150 self.numPredators = 25 self.numDeadPreys = 0 self.numDeadPredators = 0 # World self.minX = -200 self.maxX = 200 self.minY = -100 self.maxY = 100 self.targetZone = 50 self.socialZone = 20 # Feeder self.feederMinDistance = 25 self.maxFoodSupply = 200 self.minCreatedFoodSupply = 7 self.maxCreatedFoodSupply = 15 self.totalFoodSupply = 0 # List self.pollPreys = breve.objectList() self.pollPredators = breve.objectList() # Generation self.maxGeneration = 5000 self.current_generation = 0 self.breeding_season = 50 self.breeding_inc = 0.5 self.max_pop_predators = 0.6 self.prob_mutation = 0.05 # Other thing Swarm.init( self )
def init( self ): t = breve.objectList() t = breve.createInstances( breve.Things, 150 ) self.pointCamera( breve.vector( 0, 0, 0 ), breve.vector( 0, 0, 50 ) ) self.setDisplayText( '''Select an object to highlight its neighbors''', -0.950000, -0.900000 ) self.enableSmoothDrawing() self.updateNeighbors()
def __init__(self): breve.MultiBody.__init__(self) self.joint = None self.links = breve.objectList() self.shape = None self.smallShape = None self.worldJoint = None JointTestBody.init(self)
def __init__( self ): breve.Drawing.__init__( self ) self.currentColor = breve.vector() self.currentDirection = breve.vector() self.penDown = 0 self.states = breve.objectList() self.turtle = None TurtleDrawing.init( self )
def destroy( self ): blockList = breve.objectList() block = None breve.deleteInstances( self.outsideFrame ) for blockList in self.blocks: for block in blockList: breve.deleteInstances( block )