Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Hi can anyone help me with PS11 (2008 course) problem 3? It's the "runSimulation" problem. I've started from scratch several times and I keep coming up against the same problem. Any help or advice would be greatly appreciated. Here is my code . Thanks

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at in under 10 minutes. Go to now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer


To see the expert answer you'll need to create a free account at Brainly

Very quick read: Line 269, the operator should be += not =+. This problem should be handled in several small functions, not one big one. In another course it was mentioned that a function should ideally be less than 15 lines of code.
what problem are you having?
line 263 also should be += not =+...i agree with rsmith. and yes please be more specific on problems it gives you.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

visualize: a boolean (True to turn on visualization)....u didnt add any visualization on purpose because u didnt get the results or u forgot about it?
Thanks for correcting that mistake. The problem comes from the "runSimulation" function. In this function I generate a random position; p = B.getRandomPosition(). Then I try to update the position by calling another function; p = D.updatePositionAndClean(). Inside the update position function I call another function from the "position class"; newPosX = p.getNewPosition(direction, speed).getX() newPosY = p.getNewPosition(direction, speed).getY() where "p" is the initial position. The problem is that the update position function does not recognize the initial position, "p". (Maybe because they are from different classes or because they are inside different functions). I'm not sure how to get the update function to recognise the initial position. Here is the code with the above correction made: Thanks!
Yes I have put visualize to False initially because that's what is says to do in the problem. I think the next step will be to turn in to True but first I need to get the other part of the code working. Thanks!
on your corrected code ...still line 263: numSteps =+ 1 must be numSteps += 1
OK here it is again: Thanks
now.... def getRandomPosition(self): """ Return a random position inside the room. returns: a Position object. """ this method does not set your robot on a random start position just returns a random position in the room. 2nd... your start position should be automatically created when u create a robot for your simulation. 3rd... " The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with speed SPEED, in a room of dimensions WIDTH x HEIGHT." hope those hints help a bit.
im not sure but i think that your updatePositionAndClean of Robot class is wrong.where do you change direction if your next position would be outside of the room?
So inside the "runSimulation" function what if I did something like: p = C.setRobotPosition(B.getRandomPosition()). ? But then the update function still wouldn't recognise "p" as the initial position. I.e. newPosX = p.getNewPosition(direction, speed).getX() ... would still raise an error. I'm having difficulty with the concept of classes, how they work and what they are for. I need to know how the inital position "p" can be recognized inside the update function. Regarding the changing of direction ... Yes I know I need to include some code for that. Thanks
well u dont need to set an initial position i told you ...when u create a robot it automaticaly creates one for it (or should).
def __init__(self, room, speed): """ Initializes a Robot with the given speed in the specified room. The robot initially has a random direction d and a random position p in the room. The direction d is an integer satisfying 0 <= d < 360; it specifies an angle in degrees. p is a Position object giving the robot's position. room: a RectangularRoom object. speed: a float (speed > 0) """ always read carefully the docs! it says : "The robot initially has a random direction d and a random position p in the room." so you have to initialize its position and direction in the __init__ method. it will not "fix" your pset but its a start!:) gl !feel free to contact me any further.
OK thanks. I get the feeling I have not understood some quite important aspects of object oriented programming. I'm going to look for some reading material on it and I'll have another go once I have read it. Thanks
good luck mate:)

Not the answer you are looking for?

Search for more explanations.

Ask your own question