MU* style movement with recursion
c0dezer019
python
a year ago
670 B
6
Indexable
rooms = { "Bridge": { "aft": "Turbolift", "port": "Ready Room" }, "Ready Room": { "starboard": "Bridge" }, "Turbolift": { "forward": "Bridge" } } current_loc = rooms['Bridge'] def movement(direction): global current_loc while direction != '.exit': if direction in current_loc.keys(): new_loc = current_loc[direction] current_loc = rooms[new_loc] print(f'you are now in the {new_loc}') else: print("You are unable to go there.") direction = input('Move: ') movement(direction) move = input('Move: ') movement(move)
Editor is loading...
Leave a Comment