import random #variables num_modules = 17 #modules in space station module = 1 #module we are in last_module = 0 #previous module we were in possible_moves = [] #moves we can make alive = True #whether we are alive won = False #whether we have won power = 100 #power in space station fuel = 500 #fuel in flamethrower locked = 0 #module locked by player queen = 0 #location of queen vent_shafts = [] #location of vents info_panels = [] #location of info panels workers = [] #location of worker aliens #procedures def Load_module(): global module, possible_moves possible_moves = Get_modules_from(module) Output_module() def Get_modules_from(module): moves = [] text_file = open("Charles_Darwin\module" + str(module) + ".txt", "r") #opens module you are currently in for counter in range(0,4): #for all 4 pieces of info in module move_read = text_file.readline() move_read = int(move_read.strip()) #gets the connected module on its own if move_read != 0: #0 means no connected modules; not 0 means connected module moves.append(move_read) text_file.close() return moves def Output_module(): global module print() print("------------------------------------------------------------") print() print("You are in module ",module) print() def Output_moves(): global possible_moves print() print("From here you can move to modules: | ",end='') #",end='' means that the next print statement will continue on the same line for move in possible_moves: print(move,'| ',end='') #prints players possible moves one by one print() def Get_action(): global module, last_module, possible_moves valid_action = False while valid_action == False: print("What do you want to do next? (MOVE, SCANNER)") #gives options to player action = input(">") #arrow prompts player if action == "MOVE": move = int(input("Enter the module to move to: ")) if move in possible_moves: valid_action = True last_module = module #module you were in before becomes last module module = move #current module becomes new module else: print("The module must be connected to the current module.") #main program while alive and not won: Load_module() if won == False and alive == True: Output_moves() Get_action() if won == True: print("The queen is trapped and you burn it to death with your flamethrower.") print("Game over. You win!") if alive == False: print("The station has run out of power. Unable to sustain life support, you die.")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question