<s> import os , sys <EOL> sys . path . insert ( <NUM_LIT:1> , os . path . join ( sys . path [ <NUM_LIT:0> ] , '<STR_LIT:..>' ) ) <EOL> import pibrella , time , random <EOL> attempts = <NUM_LIT:4> <EOL> score = <NUM_LIT:0> <EOL> current_light = '<STR_LIT>' <EOL> red_time = <NUM_LIT:0> <EOL> button_pressed = False <EOL> def handle_reaction ( pin ) : <EOL> global attempts , current_light , red_time , button_pressed , score <EOL> if button_pressed == True : <EOL> return False <EOL> if current_light == '<STR_LIT>' : <EOL> speed = time . time ( ) - red_time <EOL> score = score + ( <NUM_LIT:2> - speed ) <EOL> attempts = attempts - <NUM_LIT:1> <EOL> pibrella . buzzer . success ( ) <EOL> print ( "<STR_LIT>" + str ( speed ) + "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" + str ( score ) ) <EOL> button_pressed = True <EOL> elif current_light == '<STR_LIT>' : <EOL> pibrella . buzzer . fail ( ) <EOL> print ( "<STR_LIT>" ) <EOL> score = score - <NUM_LIT:0.5> <EOL> attempts = attempts - <NUM_LIT:1> <EOL> print ( "<STR_LIT>" + str ( score ) ) <EOL> button_pressed = True <EOL> pibrella . button . pressed ( handle_reaction , <NUM_LIT:30> ) <EOL> def random_lights ( ) : <EOL> global attempts , current_light , red_time , button_pressed , score <EOL> if attempts <= <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" + str ( score ) ) <EOL> pibrella . light . pulse ( ) <EOL> time . sleep ( <NUM_LIT:2> ) <EOL> exit ( ) <EOL> button_pressed = False <EOL> print ( "<STR_LIT>" ) <EOL> pibrella . light . green . on ( ) <EOL> pibrella . light . red . off ( ) <EOL> current_light = '<STR_LIT>' <EOL> delay = random . randint ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> time . sleep ( delay ) <EOL> print ( "<STR_LIT>" ) <EOL> pibrella . light . amber . on ( ) <EOL> pibrella . light . green . off ( ) <EOL> current_light = '<STR_LIT>' <EOL> time . sleep ( <NUM_LIT:0.5> ) <EOL> print ( "<STR_LIT>" ) <EOL> current_light = '<STR_LIT>' <EOL> time . sleep ( <NUM_LIT:0.1> ) <EOL> red_time = time . time ( ) <EOL> pibrella . light . red . on ( ) <EOL> pibrella . light . amber . off ( ) <EOL> while button_pressed == False : <EOL> time . sleep ( <NUM_LIT:0.1> ) <EOL> pibrella . loop ( random_lights ) <EOL> pibrella . pause ( ) </s>
