# coding=utf-8 import server mod = server.problems.load_language('robot', 'en') id = 206 name = 'Count lines' slug = 'Count lines' description = '''\ Write a program to count the color lines on white background using the robot with a color sensor. The robot should drive forward, crossing the lines and count them. ''' hint = { 'mW_init':mod.hint['init'], 'connectMotorLeft':mod.hint['connectMotorLeft'], 'connectMotorRight':mod.hint['connectMotorRight'], 'moveSteeringOn':mod.hint['moveSteering']+['''

Use move_steering method with 'on' as the first parameter robot.move_steering( 'on',... ).

'''], 'moveSteeringOff':mod.hint['moveSteeringOff'], 'connectColorSensor':mod.hint['connectColorSensor'], 'colorSensorMeasure':mod.hint['colorSensorMeasure'], 'while':['''

Use the while loop: inside, the robot should read the current color and increase the counter when the color changes.

''', '''

Interrupt the loop after a certain amount of time; determine the time the robot needs to drive over all the colors experimentally; use time.time().

''', '''

while time.time()-start < 1.5:.

'''], } plan = ['''\

The program should:

  1. create a mindstorms_widgets() object, which represents the robot in your code.
  2. connect the driving motors.
  3. connect the color sensor.
  4. synchronize the motors and run them so that the robot would move forward.
  5. inside the loop, let the robot recognize colors and increase the counter.
  6. interrupt the loop after a certain amount of time.
  7. stop the motors.
''' ]