6.00.2x-pset2.py
def runSimulation(num_robots, speed, width, height, min_coverage, num_trials,
                  robot_type):
    """
    Runs NUM_TRIALS trials of the simulation and returns the mean number of
    time-steps needed to clean the fraction MIN_COVERAGE of the room.

    The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with
    speed SPEED, in a room of dimensions WIDTH x HEIGHT.

    num_robots: an int (num_robots > 0)
    speed: a float (speed > 0)
    width: an int (width > 0)
    height: an int (height > 0)
    min_coverage: a float (0 <= min_coverage <= 1.0)
    num_trials: an int (num_trials > 0)
    robot_type: class of robot to be instantiated (e.g. StandardRobot or
                RandomWalkRobot)

    returns: Cleaning time in timesteps
    """
    assert num_robots > 0 and type(num_robots) == int
    assert speed > 0 and type(speed) == float
    assert width > 0 and type(width) == int
    assert height > 0 and type(height) == int
    # Line bellow broken to comply with pep8
    assert (min_coverage >= 0 and min_coverage <=
            1.0 and type(min_coverage) == float)
    assert num_trials > 0 and type(num_trials) == int
    listOfNumberOfTimeSteps = []
    for i in range(num_trials):
        # ## Optional visualization
        # anim = ps2_visualize.RobotVisualization(num_robots, width, height)
        # ## End of optional visualization
        numberOfTimeSteps = 0
        room = RectangularRoom(width, height)
        currentCoverage = 0
        robot = []
        for i in range(num_robots):
            robot.append(robot_type(room, speed))
        while currentCoverage < min_coverage:
            # ## Optional visualization
            # anim.update(room, robot)
            # ## End of optional visualization
            for i in robot:
                i.updatePositionAndClean()
            currentCoverage = room.getNumCleanedTiles() / room.getNumTiles()
            numberOfTimeSteps += 1
        listOfNumberOfTimeSteps.append(numberOfTimeSteps)
        # ## Optional visualization
        # anim.done()
        # ## End of optional visualization
    return float(sum(listOfNumberOfTimeSteps) / num_trials)

    Runs NUM_TRIALS trials of the simulation and returns the mean number of
    time-steps needed to clean the fraction MIN_COVERAGE of the room.

    The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with
    speed SPEED, in a room of dimensions WIDTH x HEIGHT.

    num_robots: an int (num_robots > 0)
    speed: a float (speed > 0)
    width: an int (width > 0)
    height: an int (height > 0)
    min_coverage: a float (0 <= min_coverage <= 1.0)
    num_trials: an int (num_trials > 0)
    robot_type: class of robot to be instantiated (e.g. StandardRobot or
                RandomWalkRobot)

    returns: Cleaning time in timesteps
    
Runs NUM_TRIALS trials of the simulation and returns the mean number of
time-steps needed to clean the fraction MIN_COVERAGE of the room.

The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with
speed SPEED, in a room of dimensions WIDTH x HEIGHT.



Cleaning time in timesteps
Runs NUM_TRIALS trials of the simulation and returns the mean number of time - steps needed to clean the fraction MIN_COVERAGE of the room . The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE each with speed SPEED in a room of dimensions WIDTH x HEIGHT . Cleaning time in timesteps
def runSimulation(num_robots, speed, width, height, min_coverage, num_trials,
                  robot_type):
    assert num_robots > 0 and type(num_robots) == int
    assert speed > 0 and type(speed) == float
    assert width > 0 and type(width) == int
    assert height > 0 and type(height) == int
    assert (min_coverage >= 0 and min_coverage <=
            1.0 and type(min_coverage) == float)
    assert num_trials > 0 and type(num_trials) == int
    listOfNumberOfTimeSteps = []
    for i in range(num_trials):
        numberOfTimeSteps = 0
        room = RectangularRoom(width, height)
        currentCoverage = 0
        robot = []
        for i in range(num_robots):
            robot.append(robot_type(room, speed))
        while currentCoverage < min_coverage:
            for i in robot:
                i.updatePositionAndClean()
            currentCoverage = room.getNumCleanedTiles() / room.getNumTiles()
            numberOfTimeSteps += 1
        listOfNumberOfTimeSteps.append(numberOfTimeSteps)
    return float(sum(listOfNumberOfTimeSteps) / num_trials)
def runSimulation ( num_robots , speed , width , height , min_coverage , num_trials , robot_type ) : assert num_robots > 0 and type ( num_robots ) == int assert speed > 0 and type ( speed ) == float assert width > 0 and type ( width ) == int assert height > 0 and type ( height ) == int assert ( min_coverage >= 0 and min_coverage <= 1.0 and type ( min_coverage ) == float ) assert num_trials > 0 and type ( num_trials ) == int listOfNumberOfTimeSteps = [ ] for i in range ( num_trials ) : numberOfTimeSteps = 0 room = RectangularRoom ( width , height ) currentCoverage = 0 robot = [ ] for i in range ( num_robots ) : robot . append ( robot_type ( room , speed ) ) while currentCoverage < min_coverage : for i in robot : i . updatePositionAndClean ( ) currentCoverage = room . getNumCleanedTiles ( ) / room . getNumTiles ( ) numberOfTimeSteps += 1 listOfNumberOfTimeSteps . append ( numberOfTimeSteps ) return float ( sum ( listOfNumberOfTimeSteps ) / num_trials )
Runs NUM_TRIALS trials of the simulation and returns the mean number of
time-steps needed to clean the fraction MIN_COVERAGE of the room.
Runs NUM_TRIALS trials of the simulation and returns the mean number of time - steps needed to clean the fraction MIN_COVERAGE of the room .
"""
    Runs NUM_TRIALS trials of the simulation and returns the mean number of
    time-steps needed to clean the fraction MIN_COVERAGE of the room.

    The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with
    speed SPEED, in a room of dimensions WIDTH x HEIGHT.

    num_robots: an int (num_robots > 0)
    speed: a float (speed > 0)
    width: an int (width > 0)
    height: an int (height > 0)
    min_coverage: a float (0 <= min_coverage <= 1.0)
    num_trials: an int (num_trials > 0)
    robot_type: class of robot to be instantiated (e.g. StandardRobot or
                RandomWalkRobot)

    returns: Cleaning time in timesteps
    """ # Line bellow broken to comply with pep8 # ## Optional visualization # anim = ps2_visualize.RobotVisualization(num_robots, width, height) # ## End of optional visualization # ## Optional visualization # anim.update(room, robot) # ## End of optional visualization # ## Optional visualization # anim.done() # ## End of optional visualization
num_robots
speed
width
height
min_coverage
num_trials
robot_type