<s> from advent import * <EOL> from advent import Game , Location , Connection , Object , Animal , Robot , Pet , Player , Say <EOL> from advent import NORTH , SOUTH , EAST , WEST , UP , DOWN , RIGHT , LEFT , IN , OUT , FORWARD , BACK , NORTH_WEST , NORTH_EAST , SOUTH_WEST , SOUTH_EAST , NOT_DIRECTION <EOL> import advent_devtools <EOL> import random <EOL> game = Game ( "<STR_LIT>" ) <EOL> sidewalk = game . new_location ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> vestibule = game . new_location ( <EOL> "<STR_LIT>" , <EOL> """<STR_LIT>""" ) <EOL> office = game . new_location ( <EOL> "<STR_LIT>" , <EOL> """<STR_LIT>""" ) <EOL> game . new_connection ( "<STR_LIT>" , sidewalk , vestibule , [ IN , EAST ] , [ OUT , WEST ] ) <EOL> office_door = game . new_connection ( "<STR_LIT>" , vestibule , office , <EOL> [ IN , SOUTH ] , [ OUT , NORTH ] ) <EOL> player = game . new_player ( sidewalk ) <EOL> key = sidewalk . new_object ( "<STR_LIT:key>" , "<STR_LIT>" ) <EOL> vestibule . make_requirement ( key ) <EOL> hairpin = vestibule . new_object ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> office_door . set_flag ( '<STR_LIT>' ) <EOL> def pick_lock ( game , thing ) : <EOL> game . output ( "<STR_LIT>" ) <EOL> thing . unset_flag ( '<STR_LIT>' ) <EOL> office_door . add_phrase ( '<STR_LIT>' , pick_lock , [ hairpin ] ) <EOL> key . add_phrase ( "<STR_LIT>" , Say ( "<STR_LIT>" ) ) <EOL> coin = sidewalk . new_object ( "<STR_LIT>" , "<STR_LIT>" ) ; <EOL> def flip_coin ( game , thing ) : <EOL> if random . random ( ) > <NUM_LIT:0.5> : <EOL> game . output ( "<STR_LIT>" ) ; <EOL> else : <EOL> game . output ( "<STR_LIT>" ) ; <EOL> def flip_coin ( game , thing ) : <EOL> if not "<STR_LIT>" in game . player . inventory : <EOL> game . output ( "<STR_LIT>" ) <EOL> return <EOL> if random . random ( ) > <NUM_LIT:0.5> : <EOL> game . output ( "<STR_LIT>" ) ; <EOL> else : <EOL> game . output ( "<STR_LIT>" ) ; <EOL> player . add_phrase ( "<STR_LIT>" , flip_coin , [ coin ] ) <EOL> test_script = Script ( "<STR_LIT:test>" , <EOL> """<STR_LIT>""" ) <EOL> player . add_script ( test_script ) <EOL> game . run ( ) </s>
