import rone, math, sys LED_BRIGHTNESS = 40 # Returns a random int in the range of 0 to (max_val -1) # arguments: max_val # return: random in the range 0 to (max_val -1) def randint(max_val): return sys.time() % max_val # Blinks a group of lights of the same color the numblinks number of times # arguments: color, duration, numblinks # return: nothing def blink(color, duration, numblinks): #student code starts here #student code ends here # Blinks a list of colors # arguments: colorlist, duration # return: nothing def blink_list(colorlist, duration): for c in colorlist: #student code starts here #student code ends here # Adds a random color to the colorlist # arguments: colorlist # return: colorlist def append_random_color(colorlist): num = randint(3) ## generate random integer 0,1,or 2 #student code starts here #student code ends here print colorlist ## print colorlist for debugging return colorlist # Check the status of the buttons and return when a button is pressed # arguments: none # return: a string representing the button color, one of 'r', 'g', 'b' def button_check(): while rone.button_get_value('r') == 0 and \ rone.button_get_value('g') == 0 and \ rone.button_get_value('b') == 0: pass ## while no button is being pushed, do nothing for button in ['r', 'g', 'b']: if rone.button_get_value(button) == 1: rone.led_set_group(button, LED_BRIGHTNESS * 120 / 100) ## turn on LEDs while rone.button_get_value(button) == 1: pass ## while button is pushed, do nothing rone.led_set_group(button,0) ## turn off LEDs ## return string representing the color pushed ('r', 'g', or 'b') return button # Check the colors in the list as the user presses the buttons # arguments: colorlist # return: True if all the colors in the list match the user input, # False when any (i.e. the first) color does not match. def list_check(colorlist): #student code starts here for c in colorlist: #student code ends here # Play Robot Simon! # arguments: none # return: none def game(): gameinprogress = True colorlist = [] while gameinprogress: #student code starts here #student code end here sys.sleep(1000) print "game over" game()