示例#1
0
	def init( self ):
		self.setShape( breve.createInstances( breve.PolygonCone, 1 ).initWith( 3, 0.500000, 0.060000 ) )
		self.move( ( breve.randomExpression( breve.vector( 10, 10, 10 ) ) - breve.vector( 5, -5, 5 ) ) )
		self.setVelocity( ( breve.randomExpression( breve.vector( 20, 20, 20 ) ) - breve.vector( 10, 10, 10 ) ) )
		self.setColor( breve.randomExpression( breve.vector( 1, 1, 1 ) ) )
		self.handleCollisions( 'Terrain', 'land' )
		self.setNeighborhoodSize( 3.000000 )
示例#2
0
	def init( self ):
		''''''


		self.move( ( breve.randomExpression( breve.vector( 50, 0, 50 ) ) - breve.vector( 25, 0, 25 ) ) )
		self.setVelocity( ( breve.randomExpression( breve.vector( 2, 0, 2 ) ) - breve.vector( 1, 0, 1 ) ) )
		self.setColor( breve.randomExpression( breve.vector( 1, 1, 1 ) ) )
	def initializeRandomly( self ):
		self.pushCode.makeRandomCode( self.pushInterpreter, 80 )
		self.move( ( breve.randomExpression( breve.vector( 10, 0, 10 ) ) - breve.vector( 5, 3, 5 ) ) )
		self.setVelocity( breve.vector( 0, 0, 0 ) )
		self.hue = breve.randomExpression( 1.000000 )
		self.setColor( self.controller.getRgbColor( breve.vector( ( self.hue * 360 ), 1, 1 ) ) )
		self.energy = ( 0.800000 + breve.randomExpression( 0.200000 ) )
示例#4
0
	def init( self ):
		self.setShape( breve.createInstances( breve.Sphere, 1 ).initWith( 0.100000 ) )
		self.move( ( breve.randomExpression( breve.vector( 10, 10, 10 ) ) - breve.vector( 5, -5, 5 ) ) )
		self.setVelocity( ( breve.randomExpression( breve.vector( 20, 20, 20 ) ) - breve.vector( 10, 10, 10 ) ) )
		self.setColor( breve.randomExpression( breve.vector( 1, 1, 1 ) ) )
		self.handleCollisions( 'Floor', 'land' )
		self.setNeighborhoodSize( 3.000000 )
    def init(self):
        brush = None

        self.disableText()
        self.vel = (1.000000 + breve.randomExpression(9))
        self.acc = breve.randomExpression(1000)
        self.radius = (1.000000 + breve.randomExpression(5))
        if (self.getArgumentCount() == 2):
            self.file = self.getArgument(1)

        else:
            self.file = 'images/jon.png'

        self.image = breve.createInstances(breve.Image, 1).load(self.file)
        self.blur = 0.992000
        if (self.blur > 0.992000):
            self.blur = 0.992000

        self.blur = 1.000000
        self.setBackgroundColor(breve.vector(0, 0, 0))
        self.enableBlur()
        self.setBlurFactor(self.blur)
        self.radius = (self.radius * (self.image.getWidth() / 300.000000))
        self.vel = (self.vel * (self.image.getWidth() / 300.000000))
        self.acc = (self.acc * (self.image.getWidth() / 300.000000))
        self.shape = breve.createInstances(breve.Sphere,
                                           1).initWith(self.radius)
        brush = breve.createInstances(breve.Image, 1).load('images/brush.png')
        breve.createInstances(breve.Painters, 200).setBitmapImage(brush)
        self.zoom = (self.image.getWidth() + 10)
        self.offsetCamera(breve.vector(0, 0, self.zoom))
        self.setZClip((self.zoom + 100))
示例#6
0
文件: Painter.py 项目: B-Rich/breve
	def init( self ):
		brush = None

		self.disableText()
		self.vel = ( 1.000000 + breve.randomExpression( 9 ) )
		self.acc = breve.randomExpression( 1000 )
		self.radius = ( 1.000000 + breve.randomExpression( 5 ) )
		if ( self.getArgumentCount() == 2 ):
			self.file = self.getArgument( 1 )

		else:
			self.file = 'images/jon.png'

		self.image = breve.createInstances( breve.Image, 1 ).load( self.file )
		self.blur = 0.992000
		if ( self.blur > 0.992000 ):
			self.blur = 0.992000

		self.blur = 1.000000
		self.setBackgroundColor( breve.vector( 0, 0, 0 ) )
		self.enableBlur()
		self.setBlurFactor( self.blur )
		self.radius = ( self.radius * ( self.image.getWidth() / 300.000000 ) )
		self.vel = ( self.vel * ( self.image.getWidth() / 300.000000 ) )
		self.acc = ( self.acc * ( self.image.getWidth() / 300.000000 ) )
		self.shape = breve.createInstances( breve.Sphere, 1 ).initWith( self.radius )
		brush = breve.createInstances( breve.Image, 1 ).load( 'images/brush.png' )
		breve.createInstances( breve.Painters, 200 ).setBitmapImage( brush )
		self.zoom = ( self.image.getWidth() + 10 )
		self.offsetCamera( breve.vector( 0, 0, self.zoom ) )
		self.setZClip( ( self.zoom + 100 ) )
    def init(self):
        self.setShape(
            breve.createInstances(breve.Shape, 1).initWithPolygonCone(
                5, 0.200000, 0.100000))
        self.move((breve.randomExpression(breve.vector(10, 10, 10)) -
                   breve.vector(5, -5, 5)))
        self.setVelocity((breve.randomExpression(breve.vector(20, 20, 20)) -
                          breve.vector(10, 10, 10)))
        self.species = breve.randomExpression(2)
        if (self.species == 0):
            self.setColor(breve.vector(0.100000, 0.100000, 1))

        else:
            if (self.species == 1):
                self.setColor(breve.vector(1, 0.100000, 0.100000))

            else:
                if (self.species == 2):
                    self.setColor(breve.vector(1, 0.100000, 1))

        self.energy = (0.500000 + breve.randomExpression(0.200000))
        self.handleCollisions('Stationary', 'land')
        self.handleCollisions('Feeders', 'eat')
        self.setNeighborhoodSize(3.000000)
        self.age = 0
示例#8
0
	def initializeRandomly( self ):
		self.pushCode.makeRandomCode( self.pushInterpreter, 80 )
		self.move( ( breve.randomExpression( breve.vector( 10, 0, 10 ) ) - breve.vector( 5, 3, 5 ) ) )
		self.setVelocity( breve.vector( 0, 0, 0 ) )
		self.hue = breve.randomExpression( 1.000000 )
		self.setColor( self.controller.getRgbColor( breve.vector( ( self.hue * 360 ), 1, 1 ) ) )
		self.energy = ( 0.800000 + breve.randomExpression( 0.200000 ) )
	def init( self ):
		self.setShape( breve.createInstances( breve.PolygonCone, 1 ).initWith( 3, 0.800000, 0.100000 ) )
		self.move( ( breve.randomExpression( breve.vector( 10, 10, 10 ) ) - breve.vector( 5, -5, 5 ) ) )
		self.setVelocity( ( breve.randomExpression( breve.vector( 20, 20, 20 ) ) - breve.vector( 10, 10, 10 ) ) )
		self.setColor( breve.randomExpression( breve.vector( 1, 1, 1 ) ) )
		self.handleCollisions( 'Floor', 'land' )
		self.setNeighborhoodSize( 3.000000 )
示例#10
0
	def init( self ):
		''''''


		self.move( ( breve.randomExpression( breve.vector( 50, 50, 50 ) ) - breve.vector( 25, 25, 25 ) ) )
		self.setVelocity( ( breve.randomExpression( breve.vector( 2, 0, 2 ) ) - breve.vector( 1, 0, 1 ) ) )
		self.setColor( breve.randomExpression( breve.vector( 1, 1, 1 ) ) )
示例#11
0
    def spatialTournamentSelect(self, index):
        n = 0
        test = 0
        best = 0

        best = (index + (breve.randomExpression(
            ((2 * self.spatialRadius) - 1)) - self.spatialRadius))
        if (best >= self.populationSize):
            best = (best - self.populationSize)

        if (best < 0):
            best = (best + self.populationSize)

        n = 0
        while (n < (self.tournamentSize - 1)):
            test = (index + (breve.randomExpression(
                ((2 * self.spatialRadius) - 1)) - self.spatialRadius))
            if (test >= self.populationSize):
                test = (test - self.populationSize)

            if (test < 0):
                test = (test + self.populationSize)

            if (self.populations[self.currentPopulation][test].getFitness(
            ) > self.populations[self.currentPopulation][best].getFitness()):
                best = test

            n = (n + 1)

        return self.populations[self.currentPopulation][best]
示例#12
0
	def spatialTournamentSelect( self, index ):
		n = 0
		test = 0
		best = 0

		best = ( index + ( breve.randomExpression( ( ( 2 * self.spatialRadius ) - 1 ) ) - self.spatialRadius ) )
		if ( best >= self.populationSize ):
			best = ( best - self.populationSize )

		if ( best < 0 ):
			best = ( best + self.populationSize )

		n = 0
		while ( n < ( self.tournamentSize - 1 ) ):
			test = ( index + ( breve.randomExpression( ( ( 2 * self.spatialRadius ) - 1 ) ) - self.spatialRadius ) )
			if ( test >= self.populationSize ):
				test = ( test - self.populationSize )

			if ( test < 0 ):
				test = ( test + self.populationSize )

			if ( self.populations[ self.currentPopulation ][ test ].getFitness() > self.populations[ self.currentPopulation ][ best ].getFitness() ):
				best = test



			n = ( n + 1 )

		return self.populations[ self.currentPopulation ][ best ]
示例#13
0
文件: ctf.py 项目: firebitsbr/ctf-28
    def goToJail(self):
        """
        Puts the player in jail.
        """
        # if we're in jail we don't need to go to jail
        if self.in_jail:
            return

        # set out in_jail flag to true
        self.in_jail = True

        # stick yourself in a random spot in red prison.
        # Add one to the capture count
        if self.team == 1:
            self.jailed_location = self.controller.getRedJailLocation()
            self.jailed_location += breve.randomExpression(breve.vector(1, 0, 1))
            self.jailed_location -= breve.vector(.5, -.5, .5)
            self.controller.changePrisoners(RED_TEAM, 1)
        # stick yourself in a random spot in red prison.
        # Add one to the capture count
        else:
            self.jailed_location = self.controller.getBlueJailLocation()
            self.jailed_location += breve.randomExpression(breve.vector(1, 0, 1))
            self.jailed_location -= breve.vector(.5, -.5, .5)
            self.controller.changePrisoners(BLUE_TEAM, 1)

        # Move to that location
        self.move(self.jailed_location)
示例#14
0
 def reset(self):
     self.setColor(breve.randomExpression(breve.vector(1, 1, 1)))
     self.move(
         (breve.vector(-0.900000, 0.500000, -1) +
          breve.randomExpression(breve.vector(1.500000, 0.800000, 2))))
     self.setVelocity(
         breve.vector((1 + breve.randomExpression(1.000000)),
                      (1.000000 + breve.randomExpression(1.000000)), 0))
示例#15
0
文件: Fireworks.py 项目: B-Rich/breve
	def init( self ):
		self.setShape( breve.createInstances( breve.Sphere, 1 ).initWith( ( 0.100000 + breve.randomExpression( 1.400000 ) ) ) )
		self.setLightmapImage( self.controller.getLightmapImage() )
		self.setColor( ( breve.randomExpression( breve.vector( 0.200000, 0.200000, 0.200000 ) ) + breve.vector( 0.800000, 0.800000, 0.800000 ) ) )
		self.move( ( breve.randomExpression( breve.vector( 6, 0, 6 ) ) - breve.vector( 3, 30, 3 ) ) )
		self.setVelocity( ( breve.randomExpression( breve.vector( 4, 3, 4 ) ) + breve.vector( -2, 9, -2 ) ) )
		self.setAcceleration( breve.vector( 0, -1, 0 ) )
		self.limit = ( 30 + breve.randomExpression( 15 ) )
    def init(self):
        n = 0
        m = 0
        k = 0
        j = 0
        i = 0

        self.setBackgroundColor(breve.vector(1, 1, 1))
        self.setIterationStep(1.000000)
        self.setIntegrationStep(1.000000)
        self.pointCamera(breve.vector(0, 0, 0), breve.vector(30, 6, -30))
        self.U = breve.createInstances(breve.Matrix3D, 1)
        self.V = breve.createInstances(breve.Matrix3D, 1)
        self.inflow = breve.createInstances(breve.Matrix3D, 1)
        self.temp = breve.createInstances(breve.Matrix3D, 1)
        self.tempreact = breve.createInstances(breve.Matrix3D, 1)
        self.U.setSize(32, 32, 32)
        self.V.setSize(32, 32, 32)
        self.temp.setSize(32, 32, 32)
        self.tempreact.setSize(32, 32, 32)
        self.inflow.setSize(32, 32, 32)
        self.grid = breve.createInstances(breve.PatchGrid, 1)
        self.grid.initWith(breve.vector(0.500000, 0.500000, 0.500000), 32, 32,
                           32)
        self.grid.enableSmoothDrawing()
        self.inflow.setAllValues(0.010000)
        i = 0
        while (i < 32):
            n = 0
            while (n < 32):
                m = 0
                while (m < 32):
                    self.U.setValue(
                        ((0.500000 + breve.breveInternalFunctionFinder.sqrt(
                            self,
                            breve.length(
                                (0.250000 -
                                 ((0.010000 * (1.000000 +
                                               (0.040000 / 0.010000))) *
                                  (1.000000 + (0.040000 / 0.010000))))))) +
                         (0.010000 *
                          (breve.randomExpression(1.000000) - 0.500000))), m,
                        n, i)
                    self.V.setValue(
                        (((1.000000 - self.U.getValue(m, n, i)) /
                          (1.000000 + (0.040000 / 0.010000))) +
                         (0.010000 *
                          (breve.randomExpression(1.000000) - 0.500000))), m,
                        n, i)

                    m = (m + 1)

                n = (n + 1)

            i = (i + 1)

        breve.allInstances("Patches").setTransparency(0.900000)
示例#17
0
	def __init__( self, chromosomes = None):
		self.walkerBody = None
		breve.Object.__init__( self )
		self.distanceTraveled = 0
		self.uprightRatio = 0
		self.score = 0
		self.ID = -1
		self.colors = [breve.randomExpression( breve.vector( 1, 1, 1 ) ), breve.randomExpression( breve.vector( 1, 1, 1 ) )]
		self.initGenome( chromosomes )
示例#18
0
文件: Wanderer.py 项目: B-Rich/breve
	def randomizeLocation( self ):
		'''Move the Wanderer to a random location within the wander space.'''

		randomVector = breve.vector()

		self.move( ( self.wanderMag * ( ( 2 * breve.randomExpression( self.wanderVec ) ) - self.wanderVec ) ) )
		randomVector = ( breve.randomExpression( ( 2 * self.wanderVec ) ) - self.wanderVec )
		randomVector = ( randomVector / breve.length( randomVector ) )
		self.setVelocity( ( self.topVelocity * randomVector ) )
 def init(self):
     self.setShape(
         breve.createInstances(breve.Sphere, 1).initWith(
             (0.300000 + breve.randomExpression(0.900000))))
     self.setColor(
         breve.randomExpression(breve.vector(1.000000, 1.000000, 1.000000)))
     self.move((breve.randomExpression(breve.vector(30, 30, 30)) -
                breve.vector(15, 15, 15)))
     self.setNeighborhoodSize(10.000000)
示例#20
0
文件: Fireworks.py 项目: B-Rich/breve
	def init( self ):
		self.setShape( breve.createInstances( breve.Sphere, 1 ).initWith( ( 0.100000 + breve.randomExpression( 4.000000 ) ) ) )
		self.intensity = 1.000000
		self.rate = ( 0.900000 + breve.randomExpression( 0.080000 ) )
		self.setLightmapImage( self.controller.getLightmapImage() )
		self.color = breve.randomExpression( breve.vector( 1, 1, 1 ) )
		self.setColor( self.color )
		self.setVelocity( ( breve.randomExpression( breve.vector( 5, 5, 5 ) ) - breve.vector( 2.500000, 2.500000, 2.500000 ) ) )
		self.setAcceleration( breve.vector( 0, ( -breve.randomExpression( 0.500000 ) ), 0 ) )
示例#21
0
 def reset(self):
     self.setColor(breve.randomExpression(breve.vector(1, 1, 1)))
     self.move(breve.vector(0, 0, 0))
     self.setAcceleration((breve.randomExpression(breve.vector(4, -15, 4)) -
                           breve.vector(2, 1, 2)))
     self.setVelocity((breve.randomExpression(
         breve.vector((2 * self.range), 20,
                      (2 * self.range))) + breve.vector((-self.range), 4,
                                                        (-self.range))))
示例#22
0
	def maybeTeleport( self ):
		loc = breve.vector()

		if ( breve.randomExpression( self.controller.getStability() ) == 0 ):
			if self.controller.getUnitDriftMode():
				loc = self.getLocation()
				self.drift( breve.vector( ( loc.x + ( 0.100000 * ( breve.randomExpression( 2 ) - 1 ) ) ), 0, ( loc.z + ( 0.100000 * ( breve.randomExpression( 2 ) - 1 ) ) ) ) )

			else:
				self.drift( ( breve.randomExpression( breve.vector( 20, 0, 20 ) ) - breve.vector( ( 20 / 2 ), 0, ( 20 / 2 ) ) ) )
	def iterate( self ):
		y = 0
		x = 0
		color = breve.vector()

		x = ( breve.randomExpression( ( 2.000000 * 2.000000 ) ) - 2.000000 )
		y = ( breve.randomExpression( ( 2.000000 * 2.000000 ) ) - 2.000000 )
		self.move( breve.vector( x, y, 0 ) )
		color = self.getMandelbrotColor( x, y )
		self.setColor( color )
	def maybeTeleport( self ):
		loc = breve.vector()

		if ( breve.randomExpression( self.controller.getStability() ) == 0 ):
			if self.controller.getUnitDriftMode():
				loc = self.getLocation()
				self.drift( breve.vector( ( loc.x + ( 0.100000 * ( breve.randomExpression( 2 ) - 1 ) ) ), 0, ( loc.z + ( 0.100000 * ( breve.randomExpression( 2 ) - 1 ) ) ) ) )

			else:
				self.drift( ( breve.randomExpression( breve.vector( 20, 0, 20 ) ) - breve.vector( ( 20 / 2 ), 0, ( 20 / 2 ) ) ) )
示例#25
0
 def reset(self):
     self.vel = self.controller.getVel()
     self.acc = self.controller.getAcc()
     self.move(
         (breve.randomExpression(breve.vector(
             (self.w - 1), (self.h - 1), 0)) - breve.vector(
                 (self.w / 2), (self.h / 2), 0)))
     self.setVelocity(
         (breve.randomExpression(breve.vector(self.vel, self.vel, 0)) -
          breve.vector((self.vel / 2), (self.vel / 2), 0)))
     self.setColor()
    def randomizeLocation(self):
        '''Move the Wanderer to a random location within the wander space.'''

        randomVector = breve.vector()

        self.move(
            (self.wanderMag *
             ((2 * breve.randomExpression(self.wanderVec)) - self.wanderVec)))
        randomVector = (breve.randomExpression(
            (2 * self.wanderVec)) - self.wanderVec)
        randomVector = (randomVector / breve.length(randomVector))
        self.setVelocity((self.topVelocity * randomVector))
示例#27
0
    def init(self):
        x = 0
        c = 0
        n = 0
        m = 0

        self.colors.append(breve.vector(1.000000, 0, 0))
        self.colors.append(breve.vector(0.500000, 0, 0.500000))
        self.colors.append(breve.vector(0, 0, 0.500000))
        self.colors.append(breve.vector(0, 0.500000, 0.500000))
        self.colors.append(breve.vector(1, 1, 1))
        self.colors.append(breve.vector(1, 1, 0))
        self.reactionRates = [[0, 23, 0, 0, 0, 0], [0, 0, 23, 0, 0, 0],
                              [0, 0, 0, 23, 0, 0], [0, 0, 0, 0, 23, 0],
                              [0, 0, 0, 0, 0, 23], [23, 0, 0, 0, 0, 0]]
        self.chemicals = breve.createInstances(breve.Matrix2D, 6)
        self.chemicals.setSize(128, 128)
        self.diffusion = breve.createInstances(breve.Matrix2D, 1)
        self.diffusion.setSize(128, 128)
        self.reactions = breve.createInstances(breve.Matrix2D, 6)
        self.reactions.setSize(128, 128)
        self.rgb = breve.createInstances(breve.Matrix2D, 3)
        self.rgb.setSize(128, 128)
        self.totalConcentration = breve.createInstances(breve.Matrix2D, 1)
        self.totalConcentration.setSize(128, 128)
        self.setBackgroundColor(breve.vector(0, 0, 0))
        self.setIterationStep(0.250000)
        self.setIntegrationStep(0.250000)
        self.pointCamera(breve.vector(0, 0, 0), breve.vector(0, 0, 80))
        x = 0
        while (x < 3000):
            c = breve.randomExpression((6 - 1))
            n = (1 + breve.randomExpression((128 - 3)))
            m = (1 + breve.randomExpression((128 - 3)))
            self.chemicals[c].setValue(0.200000, n, m)
            self.chemicals[c].setValue(0.200000, n, (m + 1))
            self.chemicals[c].setValue(0.200000, n, (m - 1))
            self.chemicals[c].setValue(0.200000, (n + 1), m)
            self.chemicals[c].setValue(0.200000, (n - 1), m)

            x = (x + 1)

        self.texture = breve.createInstances(breve.MatrixTextureImage, 1)
        self.texture.initWith(128, 128)
        self.texture.setR(self.rgb[0])
        self.texture.setG(self.rgb[1])
        self.texture.setB(self.rgb[2])
        self.cube = breve.createInstances(breve.Mobile, 1)
        self.cube.setShape(
            breve.createInstances(breve.Cube,
                                  1).initWith(breve.vector(60, 60, 1)))
        self.cube.setTextureImage(self.texture)
        self.cube.setTextureScale(60)
示例#28
0
	def randomize( self ):
		n = 0

		n = 0
		while ( n < 8 ):
			self.phaseShifts[ n ] = ( breve.randomExpression( 6.300000 ) - 3.150000 )
			self.ampShifts[ n ] = ( breve.randomExpression( 1.000000 ) - 0.500000 )
			self.limbLengths[ n ] = ( breve.randomExpression( 2.000000 ) + 0.500000 )

			n = ( n + 1 )

		self.waveCompression = ( breve.randomExpression( 5.000000 ) - 2.500000 )
    def randomize(self):
        n = 0

        n = 0
        while (n < 8):
            self.phaseShifts[n] = (breve.randomExpression(6.300000) - 3.150000)
            self.ampShifts[n] = (breve.randomExpression(1.000000) - 0.500000)
            self.limbLengths[n] = (breve.randomExpression(2.000000) + 0.500000)

            n = (n + 1)

        self.waveCompression = (breve.randomExpression(5.000000) - 2.500000)
示例#30
0
文件: Painter.py 项目: B-Rich/breve
	def iterate( self ):
		velocity = breve.vector()

		if ( breve.randomExpression( 20 ) == 0 ):
			self.reset()

		velocity = self.getVelocity()
		if breve.length( velocity ):
			velocity = ( velocity / breve.length( velocity ) )

		self.setVelocity( ( self.vel * velocity ) )
		self.setAcceleration( ( breve.randomExpression( breve.vector( self.acc, self.acc, 0 ) ) - breve.vector( ( self.acc / 2 ), ( self.acc / 2 ), 0 ) ) )
示例#31
0
    def init(self):
        n = 0
        m = 0

        self.setBackgroundColor(breve.vector(1, 1, 1))
        self.setIterationStep(1.000000)
        self.setIntegrationStep(1.000000)
        self.pointCamera(breve.vector(0, 0, 0), breve.vector(0, 0, 70))
        self.U = breve.createInstances(breve.Matrix2D, 1)
        self.V = breve.createInstances(breve.Matrix2D, 1)
        self.inflow = breve.createInstances(breve.Matrix2D, 1)
        self.delta = breve.createInstances(breve.Matrix2D, 1)
        self.deltareact = breve.createInstances(breve.Matrix2D, 1)
        self.U.setSize(128, 128)
        self.V.setSize(128, 128)
        self.delta.setSize(128, 128)
        self.deltareact.setSize(128, 128)
        self.inflow.setSize(128, 128)
        self.texture = breve.createInstances(breve.MatrixImage, 1)
        self.texture.initWith(self.U, 1.000000)
        self.texture.setRed(self.V)
        self.texture.setBlue(self.U)
        self.cube = breve.createInstances(breve.Mobile, 1)
        self.cube.setShape(
            breve.createInstances(breve.Cube,
                                  1).initWith(breve.vector(400, 400, 1)))
        self.cube.setTextureImage(self.texture)
        self.cube.setTextureScale(40)
        n = 0
        while (n < 128):
            m = 0
            while (m < 128):
                self.U.setValue(
                    ((0.500000 + breve.breveInternalFunctionFinder.sqrt(
                        self,
                        breve.length(
                            (0.250000 -
                             ((0.010000 * (1.000000 + (0.040000 / 0.010000))) *
                              (1.000000 + (0.040000 / 0.010000))))))) +
                     (0.020000 *
                      (breve.randomExpression(1.000000) - 0.500000))), m, n)
                self.V.setValue(
                    (((1.000000 - self.U.getValue(m, n)) /
                      (1.000000 + (0.040000 / 0.010000))) +
                     (0.020000 *
                      (breve.randomExpression(1.000000) - 0.500000))), m, n)
                self.inflow.setValue(0.010000, n, m)

                m = (m + 1)

            n = (n + 1)
示例#32
0
 def randomize(self):
     self.genomeData[8] = (breve.randomExpression(5.000000) - 2.500000)
     self.genomeData[0] = (breve.randomExpression(2.000000) - 1.000000)
     self.genomeData[1] = (breve.randomExpression(2.000000) - 1.000000)
     self.genomeData[2] = (breve.randomExpression(2.000000) - 1.000000)
     self.genomeData[3] = (breve.randomExpression(2.000000) - 1.000000)
     self.genomeData[4] = (breve.randomExpression(6.300000) - 3.150000)
     self.genomeData[5] = (breve.randomExpression(6.300000) - 3.150000)
     self.genomeData[6] = (breve.randomExpression(6.300000) - 3.150000)
     self.genomeData[7] = (breve.randomExpression(6.300000) - 3.150000)
示例#33
0
文件: Walker.py 项目: B-Rich/breve
	def randomize( self ):
		self.genomeData[ 8 ] = ( breve.randomExpression( 5.000000 ) - 2.500000 )
		self.genomeData[ 0 ] = ( breve.randomExpression( 2.000000 ) - 1.000000 )
		self.genomeData[ 1 ] = ( breve.randomExpression( 2.000000 ) - 1.000000 )
		self.genomeData[ 2 ] = ( breve.randomExpression( 2.000000 ) - 1.000000 )
		self.genomeData[ 3 ] = ( breve.randomExpression( 2.000000 ) - 1.000000 )
		self.genomeData[ 4 ] = ( breve.randomExpression( 6.300000 ) - 3.150000 )
		self.genomeData[ 5 ] = ( breve.randomExpression( 6.300000 ) - 3.150000 )
		self.genomeData[ 6 ] = ( breve.randomExpression( 6.300000 ) - 3.150000 )
		self.genomeData[ 7 ] = ( breve.randomExpression( 6.300000 ) - 3.150000 )
示例#34
0
    def iterate(self):
        velocity = breve.vector()

        if (breve.randomExpression(20) == 0):
            self.reset()

        velocity = self.getVelocity()
        if breve.length(velocity):
            velocity = (velocity / breve.length(velocity))

        self.setVelocity((self.vel * velocity))
        self.setAcceleration(
            (breve.randomExpression(breve.vector(self.acc, self.acc, 0)) -
             breve.vector((self.acc / 2), (self.acc / 2), 0)))
示例#35
0
文件: Walker.py 项目: B-Rich/breve
	def mutate( self ):
		n = 0

		n = breve.randomExpression( 8 )
		if ( n < 4 ):
			self.genomeData[ n ] = ( breve.randomExpression( 2.000000 ) - 1.000000 )
		else:
			if ( n < 8 ):
				self.genomeData[ n ] = ( breve.randomExpression( 6.300000 ) - 3.150000 )
			else:
				self.genomeData[ n ] = ( breve.randomExpression( 5.000000 ) - 2.500000 )


		print '''mutated item %s of %s''' % (  n, self )
	def mutate( self ):
		n = 0

		n = breve.randomExpression( 8 )
		if ( n < 4 ):
			self.genomeData[ n ] = ( breve.randomExpression( 2.000000 ) - 1.000000 )
		else:
			if ( n < 8 ):
				self.genomeData[ n ] = ( breve.randomExpression( 6.300000 ) - 3.150000 )
			else:
				self.genomeData[ n ] = ( breve.randomExpression( 5.000000 ) - 2.500000 )


		print '''mutated item %s of %s''' % (  n, self )
示例#37
0
	def init( self ):
		x = 0
		c = 0
		n = 0
		m = 0

		self.colors.append( breve.vector( 1.000000, 0, 0 ) )
		self.colors.append( breve.vector( 0.500000, 0, 0.500000 ) )
		self.colors.append( breve.vector( 0, 0, 0.500000 ) )
		self.colors.append( breve.vector( 0, 0.500000, 0.500000 ) )
		self.colors.append( breve.vector( 1, 1, 1 ) )
		self.colors.append( breve.vector( 1, 1, 0 ) )
		self.reactionRates = [ [ 0, 23, 0, 0, 0, 0 ], [ 0, 0, 23, 0, 0, 0 ], [ 0, 0, 0, 23, 0, 0 ], [ 0, 0, 0, 0, 23, 0 ], [ 0, 0, 0, 0, 0, 23 ], [ 23, 0, 0, 0, 0, 0 ] ]
		self.chemicals = breve.createInstances( breve.Matrix2D, 6 )
		self.chemicals.setSize( 128, 128 )
		self.diffusion = breve.createInstances( breve.Matrix2D, 1 )
		self.diffusion.setSize( 128, 128 )
		self.reactions = breve.createInstances( breve.Matrix2D, 6 )
		self.reactions.setSize( 128, 128 )
		self.rgb = breve.createInstances( breve.Matrix2D, 3 )
		self.rgb.setSize( 128, 128 )
		self.totalConcentration = breve.createInstances( breve.Matrix2D, 1 )
		self.totalConcentration.setSize( 128, 128 )
		self.setBackgroundColor( breve.vector( 0, 0, 0 ) )
		self.setIterationStep( 0.250000 )
		self.setIntegrationStep( 0.250000 )
		self.pointCamera( breve.vector( 0, 0, 0 ), breve.vector( 0, 0, 80 ) )
		x = 0
		while ( x < 3000 ):
			c = breve.randomExpression( ( 6 - 1 ) )
			n = ( 1 + breve.randomExpression( ( 128 - 3 ) ) )
			m = ( 1 + breve.randomExpression( ( 128 - 3 ) ) )
			self.chemicals[ c ].setValue( 0.200000, n, m )
			self.chemicals[ c ].setValue( 0.200000, n, ( m + 1 ) )
			self.chemicals[ c ].setValue( 0.200000, n, ( m - 1 ) )
			self.chemicals[ c ].setValue( 0.200000, ( n + 1 ), m )
			self.chemicals[ c ].setValue( 0.200000, ( n - 1 ), m )

			x = ( x + 1 )

		self.texture = breve.createInstances( breve.MatrixTextureImage, 1 )
		self.texture.initWith( 128, 128 )
		self.texture.setR( self.rgb[ 0 ] )
		self.texture.setG( self.rgb[ 1 ] )
		self.texture.setB( self.rgb[ 2 ] )
		self.cube = breve.createInstances( breve.Mobile, 1 )
		self.cube.setShape( breve.createInstances( breve.Cube, 1 ).initWith( breve.vector( 60, 60, 1 ) ) )
		self.cube.setTextureImage( self.texture )
		self.cube.setTextureScale( 60 )
示例#38
0
	def fern( self, s ):
		if ( s >= 0.400000 ):
			self.drawing.pushState()
			self.drawing.setColor( breve.vector( breve.randomExpression( 1.000000 ), breve.randomExpression( 1.000000 ), breve.randomExpression( 1.000000 ) ) )
			self.drawing.turnUp( 5 )
			self.drawing.forward( ( s / 25 ) )
			self.drawing.turnLeft( 88 )
			self.fern( ( s * 0.300000 ) )
			self.drawing.turnRight( 82 )
			self.drawing.forward( ( s / 25 ) )
			self.drawing.turnRight( 98 )
			self.fern( ( s * 0.300000 ) )
			self.drawing.turnLeft( 79 )
			self.fern( ( s * 0.900000 ) )
			self.drawing.popState()
	def randomize( self, nMax, np, cp, p = 0.500000 ):
		'''Randomizes this genome by creating a directed graph containing up to  nMax nodes.  Sets the number of node and connection parameters to np  and cp, respectively.  The optional connection probability, p, specifies the probability that a connection will be made from one node to another.'''

		count = 0
		nodes = breve.objectList()
		m = None
		n = None
		connection = None
		keep = breve.hash()

		self.deleteRootNode()
		count = ( breve.randomExpression( ( nMax - 1 ) ) + 1 )
		if ( count < 2 ):
			count = ( count + 1 )

		nodes = breve.createInstances( breve.GADirectedGraphNodes, count )
		nodes.setParameterLength( np )
		nodes.randomizeParameters()
		for n in nodes:
			for m in nodes:
				if ( ( n != m ) and ( breve.randomExpression( 1.000000 ) < p ) ):
					connection = n.connect( m, [] )
					connection.setParameterLength( cp )
					connection.randomizeParameters()






		self.rootNode = self.pickRootNode( nodes )
		if ( not self.rootNode ):
			self.rootNode = breve.createInstances( breve.GADirectedGraphNode, 1 )
			self.rootNode.setParameterLength( np )
			self.rootNode.randomizeParameters()


		for n in self.rootNode.getConnectedNodes():
			keep[ n ] = 1


		for n in nodes:
			if ( not keep[ n ] ):
				breve.deleteInstances( n )



		self.addDependency( self.rootNode )
    def dieAndSpawn(self, p):
        parentNewEnergy = 0

        self.energy = (0.500000 + breve.randomExpression(0.200000))
        self.age = 0
        self.wanderConstant = self.mutate(p.getWanderConstant(), 0.500000,
                                          15.000000, 0.100000)
        self.worldCenterConstant = self.mutate(p.getWorldCenterConstant(),
                                               0.500000, 15.000000, 0.100000)
        self.centerConstant = self.mutate(p.getCenterConstant(), 0.500000,
                                          15.000000, 0.100000)
        self.velocityConstant = self.mutate(p.getVelocityConstant(), 0.500000,
                                            15.000000, 0.100000)
        self.spacingConstant = self.mutate(p.getSpacingConstant(), 0.500000,
                                           15.000000, 0.100000)
        self.feederConstant = self.mutate(p.getFeederConstant(), 0.500000,
                                          15.000000, 0.100000)
        self.xenoSpacingConstant = self.mutate(p.getXenoSpacingConstant(),
                                               0.500000, 15.000000, 0.100000)
        self.cruiseDistance = self.mutate(p.getCruiseDistance(), 0.500000,
                                          15.000000, 0.100000)
        self.xenoDistance = self.mutate(p.getXenoDistance(), 0.500000,
                                        15.000000, 0.100000)
        self.maxVelocity = self.mutate(p.getMaxVelocity(), 0.500000, 15.000000,
                                       0.100000)
        self.maxAcceleration = self.mutate(p.getMaxAcceleration(), 0.500000,
                                           15.000000, 0.100000)
        parentNewEnergy = p.getEnergy()
        parentNewEnergy = (parentNewEnergy - 0.001000)
        if (parentNewEnergy < 0):
            parentNewEnergy = 0

        p.setEnergy(parentNewEnergy)
        p.adjustColor()
	def init( self ):
		bodyShape = None
		lowerLinkShape = None
		linkShape = None

		self.addMenu( '''Send to Center''', 'center' )
		lowerLinkShape = breve.createInstances( breve.Cube, 1 ).initWith( breve.vector( 0.360000, 1, 0.360000 ) )
		linkShape = breve.createInstances( breve.Cube, 1 ).initWith( breve.vector( 0.380000, 1, 0.380000 ) )
		bodyShape = breve.createInstances( breve.Cube, 1 ).initWith( breve.vector( 4, 3, 0.400000 ) )
		self.links = breve.createInstances( breve.Links, 8 )
		self.joints = breve.createInstances( breve.RevoluteJoints, 8 )
		self.links[ 0 ].setShape( linkShape )
		self.links[ 2 ].setShape( linkShape )
		self.links[ 4 ].setShape( linkShape )
		self.links[ 6 ].setShape( linkShape )
		self.links[ 1 ].setShape( lowerLinkShape )
		self.links[ 3 ].setShape( lowerLinkShape )
		self.links[ 5 ].setShape( lowerLinkShape )
		self.links[ 7 ].setShape( lowerLinkShape )
		self.links.setColor( breve.randomExpression( breve.vector( 1.000000, 1.000000, 1.000000 ) ) )
		self.bodyLink = breve.createInstances( breve.Link, 1 )
		self.bodyLink.setShape( bodyShape )
		self.joints[ 0 ].link( breve.vector( 0, 0, 1 ), breve.vector( 2.000000, -1.500000, 0 ), breve.vector( 0, 0.500000, 0 ), self.links[ 0 ], self.bodyLink )
		self.joints[ 1 ].link( breve.vector( 1, 0, 0 ), breve.vector( 0, -0.500000, 0 ), breve.vector( 0, 0.500000, 0 ), self.links[ 1 ], self.links[ 0 ] )
		self.joints[ 4 ].link( breve.vector( 0, 0, 1 ), breve.vector( -2.000000, -1.500000, 0 ), breve.vector( 0, 0.500000, 0 ), self.links[ 4 ], self.bodyLink )
		self.joints[ 5 ].link( breve.vector( 1, 0, 0 ), breve.vector( 0, -0.500000, 0 ), breve.vector( 0, 0.500000, 0 ), self.links[ 5 ], self.links[ 4 ] )
		self.joints[ 2 ].link( breve.vector( 0, 0, 1 ), breve.vector( 2.000000, 1.500000, 0 ), breve.vector( 0, -0.500000, 0 ), self.links[ 2 ], self.bodyLink )
		self.joints[ 3 ].link( breve.vector( 1, 0, 0 ), breve.vector( 0, 0.500000, 0 ), breve.vector( 0, -0.500000, 0 ), self.links[ 3 ], self.links[ 2 ] )
		self.joints[ 6 ].link( breve.vector( 0, 0, 1 ), breve.vector( -2.000000, 1.500000, 0 ), breve.vector( 0, -0.500000, 0 ), self.links[ 6 ], self.bodyLink )
		self.joints[ 7 ].link( breve.vector( 1, 0, 0 ), breve.vector( 0, 0.500000, 0 ), breve.vector( 0, -0.500000, 0 ), self.links[ 7 ], self.links[ 6 ] )
		self.register( self.bodyLink )
		self.rotate( breve.vector( 1, 0, 0 ), 1.570000 )
		self.joints.setDoubleSpring( 400, 0.800000, -0.800000 )
		self.joints.setStrengthLimit( 300 )
    def changeDrivers(self):
        newDriver = 0
        newOffset = breve.vector()

        if self.locked:
            return

        newOffset = (breve.randomExpression(breve.vector(30, 6, 30)) +
                     breve.vector(-15, 1, -15))
        if (breve.length(newOffset) < 9):
            newOffset = ((9 * newOffset) / breve.length(newOffset))

        self.panCameraOffset(newOffset, 30)
        self.seats[self.currentSeat].setDistance(
            breve.length(self.wigglyThing.getLocation()))
        self.currentSeat = (self.currentSeat + 1)
        if (self.currentSeat > 3):
            self.breedNewMonkeys()
            self.pickDrivers()

        newDriver = self.seats[self.currentSeat].getNumber()
        if self.wigglyThing:
            breve.deleteInstances(self.wigglyThing)

        self.wigglyThing = breve.createInstances(breve.Creature, 1)
        self.wigglyThing.initWith(self.seats[self.currentSeat].getGenome())
        self.wigglyThing.move(breve.vector(0, 3, 0))
        self.watch(self.wigglyThing)
        self.schedule('changeDrivers', (self.getTime() + 20.000000))
        self.displayCurrentDriver()
示例#43
0
	def initPatch( self ):
		if ( breve.randomExpression( 5 ) == 0 ):
			self.setState( 1 )
		else:
			self.setState( 0 )

		self.neighbors = self.get3dMooreNeighborhood()
示例#44
0
 def init(self):
     self.shape = breve.createInstances(breve.Sphere, 1).initWith(
         (breve.randomExpression(2.000000) + 0.100000))
     self.setShape(self.shape)
     self.drawAsPoint()
     self.range = 5
     self.reset()
    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())
示例#46
0
    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 initPatch(self):
        if (breve.randomExpression(5) == 0):
            self.setState(1)
        else:
            self.setState(0)

        self.neighbors = self.get3dMooreNeighborhood()
示例#48
0
文件: PatchLife.py 项目: B-Rich/breve
	def randomize( self ):
		patch = None
		patchList = breve.objectList()

		patchList = self.patches.getPatches()
		for patch in patchList:
			patch.setState( breve.randomExpression( 1 ) )
    def randomize(self):
        patch = None
        patchList = breve.objectList()

        patchList = self.patches.getPatches()
        for patch in patchList:
            patch.setState(breve.randomExpression(1))
示例#50
0
文件: ctf.py 项目: firebitsbr/ctf-28
    def init(self):
        """
        Initalizes the CTFPlayer.
        """
        # Set the heading and get id numbers from the controller.
        # Oh right, all objects have a link to the controller class
        # in breve. This makes it easy to cheat. Don't. I'll be sad.
        self.heading = breve.vector(1, 0, 0)
        self.id_number = self.controller.getNextIdNumber(self)

        # create a shape and set the players shape to that shape.
        shape = AgentShape()
        self.setShape(shape)

        # set up collision handlers
        self.handleCollisions('Flag', 'pickUp')
        self.handleCollisions('Jail', 'jailBreak')

        # set up collision handling with other agents.
        # we don't want to tag our own team do we?
        for item in CTFPlayer.players:
            item_type = item.getType()
            self_type = self.getType()

            if item_type != self_type:
                item.handleCollisions(self_type, 'tagAgent')
                self.handleCollisions(item_type, 'tagAgent')

        # Point ourselves in a random direction.
        self.setAngle(breve.randomExpression(6.29))
示例#51
0
文件: ctf.py 项目: firebitsbr/ctf-28
    def resetWorld(self):
        """
        Resets the state of the world for a new match.
        """
        # Generate the randomness for the flag position
        location_randomizer = breve.randomExpression(breve.vector(0, 0, WORLD_SIZE/2))
        location_randomizer -= breve.vector(0, 0, WORLD_SIZE/4)

        # Reset flag locations
        self.blue_flag.move(breve.vector(-1*WORLD_SIZE/2+5, 1, 0) + location_randomizer)
        self.blue_flag.resetFlag()

        self.red_flag.move(breve.vector(WORLD_SIZE/2-5, 1, 0) + location_randomizer)
        self.red_flag.resetFlag()

        # Reset all of the player locations
        # This call varies from traditional breve python syntax. To iterate over all
        # objects of a certian class the call is usually:
        # for item in breve.allInstances(CTFPlayer)
        # But since CTFPlayer is a pure python subclass it is not added to the 
        # breve object counter properly. We have to handle our own player count.
        for item in CTFPlayer.players:
            item.resetPlayer()

        # set the pause timer, reset the iteration count
        # reset the red and blue caputer count
        # Display the winners of the match properly.
        self.pause_track = PAUSE_TIME
        self.iterations = 1
        self.red_players_captured = 0
        self.blue_players_captured = 0
        self.total_red_flag_time = 0.0
        self.total_blue_flag_time = 0.0
        self.setDisplayText(self.winners_str % \
                (self.red_wins, self.blue_wins, self.ties), -.3, .8, 3)
示例#52
0
	def changeDrivers( self ):
		newDriver = 0
		newOffset = breve.vector()

		if self.locked:
			return

		newOffset = ( breve.randomExpression( breve.vector( 30, 6, 30 ) ) + breve.vector( -15, 1, -15 ) )
		if ( breve.length( newOffset ) < 9 ):
			newOffset = ( ( 9 * newOffset ) / breve.length( newOffset ) )

		self.panCameraOffset( newOffset, 30 )
		self.seats[ self.currentSeat ].setDistance( breve.length( self.wigglyThing.getLocation() ) )
		self.currentSeat = ( self.currentSeat + 1 )
		if ( self.currentSeat > 3 ):
			self.breedNewMonkeys()
			self.pickDrivers()


		newDriver = self.seats[ self.currentSeat ].getNumber()
		if self.wigglyThing:
			breve.deleteInstances( self.wigglyThing )


		self.wigglyThing = breve.createInstances( breve.Creature, 1 )
		self.wigglyThing.initWith( self.seats[ self.currentSeat ].getGenome() )
		self.wigglyThing.move( breve.vector( 0, 3, 0 ) )
		self.watch( self.wigglyThing )
		self.schedule( 'changeDrivers', ( self.getTime() + 20.000000 ) )
		self.displayCurrentDriver()
示例#53
0
    def iterate(self):
        if (breve.length(self.getLocation()) > (self.maxDist + 10)):
            self.offsetFromCenter((self.maxDist + 2))

        self.setVelocity(
            (breve.randomExpression(breve.vector(1.200000, 1.200000, 1.200000))
             - breve.vector(0.600000, 0.600000, 0.600000)))
        self.roaming = 1
示例#54
0
	def init( self ):
		self.shape = breve.createInstances( breve.Sphere, 1 ).initWith( 0.300000 )
		self.setShape( self.shape )
		self.move( ( breve.randomExpression( breve.vector( 30, 0, 30 ) ) - breve.vector( 15, 0, 15 ) ) )
		self.setVelocity( breve.vector( 0, 0, 0 ) )
		self.energy = 1
		self.setColor( breve.vector( 1, 1, 1 ) )
		self.lastScale = 1
	def init( self ):
		self.shape = breve.createInstances( breve.Sphere, 1 ).initWith( 0.300000 )
		self.setShape( self.shape )
		self.move( ( breve.randomExpression( breve.vector( 30, 0, 30 ) ) - breve.vector( 15, 0, 15 ) ) )
		self.setVelocity( breve.vector( 0, 0, 0 ) )
		self.energy = 1
		self.setColor( breve.vector( 1, 1, 1 ) )
		self.lastScale = 1
 def init(self):
     self.setShape(
         breve.createInstances(breve.Shape, 1).initWithPolygonDisk(
             5, 0.100000, 1.000000))
     self.move((breve.randomExpression(breve.vector(20, 0, 20)) -
                breve.vector(10, 0, 10)))
     self.setVelocity(breve.vector(0, 0, 0))
     self.setColor(breve.vector(1, 1, 0.300000))
示例#57
0
    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()
示例#58
0
	def mutate( self ):
		n = 0

		n = breve.randomExpression( 25 )
		if ( n < 8 ):
			self.ampShifts[ n ] = ( breve.randomExpression( 2.000000 ) - 1.000000 )
		else:
			if ( n < 16 ):
				self.phaseShifts[ ( n - 8 ) ] = ( breve.randomExpression( 6.300000 ) - 3.150000 )
			else:
				if ( n < 24 ):
					self.limbLengths[ ( n - 16 ) ] = ( breve.randomExpression( 2.000000 ) + 0.500000 )
				else:
					self.waveCompression = ( breve.randomExpression( 5.000000 ) - 2.500000 )



		print '''mutated item %s of %s''' % (  n, self )