hw9 - self.yVel = yVel return self.yVel def update(self...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import cTurtle import random class Boid: def __init__(self): self.xPos = random.random() self.yPos = random.random() self.xVel = random.random()-.9 self.yVel = random.random()-.9 self.turtle = cTurtle.Turtle() self.turtle.setWorldCoordinates (0,0,1,1) self.turtle.up() self.turtle.goto(self.xPos, self.yPos) self.turtle.resizemode("user") self.turtle.shape("circle") self.turtle.color("blue") self.turtle.tracer(4) def getXPos(self): print (self.xPos) def setXPos(self, xPos): self.xPos = xPos return self.xPos def getYPos(self): return self.yPos def setYPos (self, yPos): self.yPos = yPos return self.yPos def getXVel(self): return self.xVel def setXVel (self, xVel): self.xVel = xVel return self.xVel def getYVel(self): return self.yVel def setYVel (self, yVel):
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: self.yVel = yVel return self.yVel def update(self): self.xPos = self.xPos + self.xVel if self.xPos <0: self.xPos =0 self.yPos = self.yPos + self.yVel if self.yPos >1: self.yPos = 1 self.turtle.goto(self.xPos, self.yPos) def applyWallAversion (self): if self.xPos<.01: self.xVel = self.xVel + (0.01-self.xPos) if self.xPos<.99: self.xVel = self.xVel + (0.99-self.xPos) if self.yPos<.01: self.yVel = self.yVel + (0.01-self.yPos) if self.yPos>.99: self.yVel = self.yVel + (0.99 - self.yPos) def boidsSimulation (numBoids, numSteps): boidList = for boid in range (numBoids): boidList.append(Boid) for steps in range (numSteps): for boids in boidList: Boid.update(Boid)...
View Full Document

  • Spring '11
  • safa
  • Boids, return self.xVel def, return self.yVel def, self.xVel def setXVel, self.xVel def getYVel, self.yVel def setYVel

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern