#!/usr/bin/env python ## Control: How to split something ACCORDINGLY. ## Quotes are removed in here! ## Therefore the following two things do the same: ## type "xyzzyelephant" ## type xyzzyelephant import os, random def game_split_com(string): x = string.split() for c in ",:.!\"": x = c.join(x).split(c) x = [a for a in x if a] return x def game_split_line(string): "Semicolons separate commands." return map(game_split_com, string.split(";")) def DictKey(x): assert isinstance(x, dict) and len(x) == 1 return list(x)[0] def DictValue(x): return x[DictKey(x)] def find_left(string, poss): "Remember: poss is a dict." listposs = map(game_split_com, poss) poss2 = dict() for key, value in poss.iteritems(): poss2[tuple(game_split_com(key))] = value string = game_split_com(string) while string and not string in listposs: string = string[:-1] if len(string) > 0: return {tuple(string): poss2[tuple(string)]} else: return "not found" def trim_left(string, poss): d = find_left(string, poss) if d == "not found": return string else: return " ".join(string.split()[len(DictKey(d)):]) ## The problem is that, if any function here uses props and the ## areas use it, then Python will complain for some reason. def _help(args): print \ """Welcome to Metadunnet[6]! Does there really exist a dreambook? We have some notes for you: - You are sleeping through the night, andd this adventure is your dream. Even though you may not believe certain sections, you should still stick with them. - Just like in Metadunnet[5], classes havve been used to make the objects and areas. - I find it useful that semicolons separaate commands in inputs. - Double-quotations `"` are ignored in innputs; you do not have to debate on whether to use them or not. - Unlike Metadunnet[5], "inside" and "outtside" are not in this game; neither are "up" or "down". - Morning will never really come until thhe adventure finishes. (Realisticly speaking, if you're /extremely/ tired on a certain night, you might not have any dreams at all, because your mind sleeps the whole time you do.) Similarly, if any creature is sleeping, it probably will never wake up by itself. This is similar to Metadunnet[4]. - Looking at objects (especially papers aand manuals) might give you clues as to what to do. - When you find a card that can open a dooor, you need not explicitly open it; you can just walk in the direction of the door. - This game uses the same split action ass Metadunnet[5]. - If this game does not run in a DOS winddow, try installing Command Prompt Python. If you have any suggestions, please contact http://www.bluzeandmuse.com/ and click on the games link.""" def mkclass(classobj, props): "Make a class for a classobj which allows no arguments. props is a dict" X = classobj() for key, value in props.iteritems(): setattr(X, key, value) return X def save_val(string): return "global %s\n%s = %s\n" % (string, string, `eval(string)`) def save(args): if not args: print "You must specify a filename." else: try: if not os.access("saved games", os.F_OK): os.mkdir("saved games") savepath = os.path.join("saved games", "metadunnet6") if not os.access(savepath, os.F_OK): os.mkdir(savepath) game = open(os.path.join("saved games", "metadunnet6", "%s.txt" % args[0]), "w") game.write(save_val("props")) game.write(save_val("area_aliases")) game.write(save_val("doors")) game.write(save_val("DOOR_LABELS")) game.write(save_val("correct_door")) game.write(save_val("correct_bin")) game.write(save_val("password")) ## Any varying properties that's not in area_aliases has ## been put in props print "Game saved to %r" % args[0] except Exception: print "Error saving to file." def restore(args): if not args: print "You must specify a filename." else: try: exec open(os.path.join("saved games", "metadunnet6", "%s.txt" % args[0])) print "Game %r restored" % args[0] area_aliases[props["current_area"]].describe() except Exception: print "Could not load restore file." def _quit(args): global props print "Goodbye!" props["game_run"] = False def take(args): x = obj_from_args_std(" ".join(args), "take") if x: area_aliases[props["current_area"]].take(x) def take_all(args): if not area_aliases[props["current_area"]].objects: print "Nothing here to take." else: oa = dict(area_aliases[props["current_area"]].objects) for i in oa: print "%s:" % object_classes[i]().fname.title(), area_aliases[props["current_area"]].take(i) def drop(args): x = obj_from_args_std(" ".join(args), "drop") if x: area_aliases[props["current_area"]].drop(x) def drop_all(args): if not props["inventory"]: print "You have nothing to drop." else: oi = dict(props["inventory"]) for i in oi: print "%s:" % object_classes[i]().fname.title(), area_aliases[props["current_area"]].drop(i) def examine(args): if not args: area_aliases[props["current_area"]].describe(True) else: x = obj_from_args_std(" ".join(args)) if x: area_aliases[props["current_area"]].examine(x) def eat(args): x = obj_from_args_std(" ".join(args), "eat") if x: if x in props["inventory"]: props["inventory"][x].eat() elif x in area_aliases[props["current_area"]].objects: area_aliases[props["current_area"]].objects[x].eat() else: print "You can't see any such thing." def drink(args): x = obj_from_args_std(" ".join(args), "drink") if x: if x in props["inventory"]: props["inventory"][x].drink() elif x in area_aliases[props["current_area"]].objects: area_aliases[props["current_area"]].objects[x].drink() else: print "You can't see any such thing." def put(args): ## put x in y x = obj_from_args_std(" ".join(args), "put") if x: if x in props["inventory"]: rest_args = trim_left(" ".join(args), object_equivalents).split() while rest_args and rest_args[0] in ("in", "into", "inside", "on", "onto", "through"): rest_args = rest_args[1:] rest_args = " ".join(rest_args) if not rest_args: print "What do you want to put %s in?" % object_classes[x]().fname else: owner = obj_from_args_std(rest_args, Owner=True) if owner: if owner in props["inventory"] or \ owner in area_aliases[props["current_area"]].objects: if owner in props["inventory"]: OWN = props["inventory"][owner] else: OWN = area_aliases[props["current_area"]].objects[owner] OWN.receive(x) else: print "You can't see any such owner." elif x in area_aliases[props["current_area"]].objects: print "You don't have that!" else: print "You can't see any such thing." def give(args): ## give x to y x = obj_from_args_std(" ".join(args), "give") if x: if x in props["inventory"]: rest_args = trim_left(" ".join(args), object_equivalents).split() while rest_args and rest_args[0] == "to": rest_args = rest_args[1:] rest_args = " ".join(rest_args) if not rest_args: print "What do you want to give %s to?" % object_classes[x]().fname else: owner = obj_from_args_std(rest_args, Owner=True) if owner: if owner in props["inventory"] or \ owner in area_aliases[props["current_area"]].objects: if owner in props["inventory"]: OWN = props["inventory"][owner] else: OWN = area_aliases[props["current_area"]].objects[owner] OWN.receive(x) else: print "You can't see any such owner." elif x in area_aliases[props["current_area"]].objects: print "You don't have that!" else: print "You can't see any such thing." def _type(args): ## type password ("xyzzyflamingo") args = args or [""] area_aliases[props["current_area"]].Type(args[0]) def sleep(args): if props["current_area"] == "outside": print "This is outside the game; try restarting or restoring." else: print "What do you mean? You're already asleep." def wake(args): if props["current_area"] == "outside": print "This is outside the game; try restarting or restoring." else: if not args: print \ """Trying to wake up when you're getting your nighttime sleep is not a satisfactory idea.""" else: x = obj_from_args_std(" ".join(args), "wake") if x: if x in props["inventory"]: props["inventory"][x].wake() elif x in area_aliases[props["current_area"]].objects: area_aliases[props["current_area"]].objects[x].wake() else: print "You can't see any such thing." def poke(args): x = obj_from_args_std(" ".join(args), "poke") if x: if x in props["inventory"]: props["inventory"][x].poke() elif x in area_aliases[props["current_area"]].objects: area_aliases[props["current_area"]].objects[x].poke() else: print "You can't see any such thing." def poke_self(args): if not "needle" in props["inventory"]: print "You don't have anything that you can use to poke things." else: print \ """Ouch! You wake up from this nightmare, and you lie back down again. What kind of a dream was that!""" lose() def haslst(lst,sublink): "Return whether sublink is a link in lst." links = [lst[n:n+len(sublink)] for n in xrange(len(lst)-len(sublink)+1)] return sublink in links def say(args): if props["current_area"] == "outside": print "This is outside the game; try restarting or restoring." else: if not args: print "You didn't specify anything to say." else: print "It's hard to speak when you're asleep and dreaming." if "fox" in area_aliases[props["current_area"]].objects: print "As a result, the fox keeps sleeping on, not hearing anything." if "king" in area_aliases[props["current_area"]].objects: print "However, the King hears what you're saying." if "111" in args: print "He says, \"111 sounds like an emergency number!\"" elif "911" in args: print "He says, \"911 sounds like an emergency number!\"" elif "191" in args: print "He says, \"191 sounds like an emergency number!\"" elif "119" in args: print "He says, \"119 sounds like an emergency number!\"" elif any([X in args for X in ("hi","hello","howdy","greetings", "bonjour","hola","salut")]): print "He says, \"Hello; funny you could say that to me currently!\"" elif any([X in args for X in ("bye","ciao","adios","goodbye","good-bye")]) or \ haslst(args, ["au","revoir"]) or haslst(args, ["see","yo"]) or \ haslst(args, ["see","yo'"]) or haslst(args, ["see","you"]) or \ haslst(args, ["see","ya"]): print "He sadly says, \"Are you leaving me?\"" elif any([X in args for X in ("zut","darn","dumb","dead")]): print "He sadly says, \"Is anything wrong?\"" elif any([X in args for X in ("merci","gracias","thanks")]) or \ haslst(args, ["thank","you"]): print "He says, \"You're welcome! How did I help you?\"" elif "highness" in args: print "He says, \"Maybe you can finish this adventure.\"" elif haslst(args, ["does","there","really","exist","a","dreambook?"]) or \ haslst(args, ["does","there","exist","a","dreambook?"]) or \ haslst(args, ["does","a","dreambook","exist?"]) or \ haslst(args, ["do","there","really","exist","dreambooks?"]) or \ haslst(args, ["do","there","exist","dreambooks?"]) or \ haslst(args, ["do","dreambooks","exist?"]): if area_aliases[props["current_area"]].objects["king"].permission: print "He says, \"I already told you. Do you remember?\"" else: print "He says, \"If you give me my fortune, I will tell you.\"" else: print "He says, \"Do you have something to say to me?\"" def die(args): print "That would be an awful attempt. Seriously." def _win(args): print "You can't go on like that, cheating to win automatically!" def use(args): x = obj_from_args_std(" ".join(args), "use") if x: if x in props["inventory"]: props["inventory"][x].use() elif x in area_aliases[props["current_area"]].objects: area_aliases[props["current_area"]].objects[x].use() else: print "You can't see any such thing." def restart(args): "Reset everything" global correct_bin, doors, DOOR_LABELS, correct_door, password correct_bin = random.choice(list(bin_rhymes)) doors = {} WORDS = list(door_rhymes) for i in ("w","nw","n","ne","e"): ## Make a /distinct/ word for each door. Order matters. word = random.choice(WORDS) doors[i] = word WORDS.remove(word) DOOR_LABELS = """ NORTH %s NORTHWEST NORTHEAST %s %s WEST EAST %s %s""" % \ tuple(map(doors.__getitem__, ("n","nw","ne","w","e"))) ##must go in format order correct_door = random.choice(list(doors)) password = "xyzzy" for i in xrange(8): password += random.choice(list("abcdefghijklmnopqrstuvwxyz")) print \ """ *** RESTART *** DOES THERE REALLY EXIST A DREAMBOOK? You come home from an evening dance party one night, tired. You walk upstairs to the bedrooms. Standing at his door, your younger brother, Nathan, says, "Guess what I learned in school today! A special question! 'Does there really exist a dreambook?'" (Nathan here is the same Nathan in Metadunnet[4], if you know the game.) You say, "Amazing! Do you know the answer?" Nathan replies, "No, I don't; it's a hard question." You agree. Your parents come. "Nathan, darling, it's time for bed," they say. "Tomorrow's another school day." (Your parents are, of course, Nathan's parents, since Nathan's your brother.) Nathan walks in his room and says to you, "Good night!" You respond. You then brush your teeth and lie in bed, thinking about the question that Nathan told you: Does there really exist a dreambook? Thinking about dreambooks makes you even more tired. You soon close your eyes and fall fast asleep. As you continue to sleep, your mind becomes subconscious, and you begin to dream. In your dream are large letters that read: DOES THERE REALLY EXIST A DREAMBOOK? Then everything clears and you start to see a corner of a small town. """ reset_props() reset_areas() area_aliases[props["current_area"]].describe(True) def inventory(args): if not props["inventory"]: print "You are currently carrying nothing." else: for key, value in props["inventory"].iteritems(): print "You are currently carrying %s." % value.fname def echo(args): "A rather silly command" args = args or [""] for i in args: print i, print def obj_from_args_std(string, action="do", Owner=False): "Remember bin confusion!" if not string.split(): print "What do you want to %s?" % action else: x = find_left(string, object_equivalents) if x == "not found": if string.split()[0] == "bin" and props["current_area"] == "bin_room": print "Which bin do you mean; A, B, or C?" else: print "You can't see any such %s." % ("owner" if Owner else "thing") else: return DictValue(x) ## Move around! def north(args): area_aliases[props["current_area"]].north() def south(args): area_aliases[props["current_area"]].south() def east(args): area_aliases[props["current_area"]].east() def west(args): area_aliases[props["current_area"]].west() def northeast(args): area_aliases[props["current_area"]].northeast() def northwest(args): area_aliases[props["current_area"]].northwest() def southeast(args): area_aliases[props["current_area"]].southeast() def southwest(args): area_aliases[props["current_area"]].southwest() ## Objects ## Object is the superset of all objects. Just so you know. ## There are different things that can be applied to different objects. class Object(object): def __init__(self): self.name = "object" self.fname = "the object" self.takable = True def __repr__(self): "For saving issues" name = eval(`type(self)`[:-1].split()[-1]).split(".")[-1] return "mkclass(%s, %r)" % (name, self.__dict__) def show(self): pass def eat(self): print \ """You notice that this object is quite hard to your mouth. You hardly get it down your throat, until your closed eyes open up and you realize that you're trying to swallow your nighttime flashlight. /That/ wasn't much of a satisfactory dream at all.""" lose() def drink(self): print "You can't drink %s!" % self.fname def describe(self): print "This is the default description of an object." def receive(self, obj): print "%s cannot receive anything." % self.fname.capitalize() def wake(self): print "You cannot wake %s." % self.fname.capitalize() def poke(self): if not "needle" in props["inventory"]: print "You don't have anything that you can use to poke things." else: print "Trying to poke %s doesn't seem to have an effect." % self.fname def use(self): print "%s cannot be used." % self.fname.capitalize() ## Takable objects class Paper(Object): def __init__(self): Object.__init__(self) self.name = "paper" self.fname = "the strip of paper" def show(self): print "There is a strip of paper here." def describe(self): print \ """The paper says: "To find the King's fortune that's true, this is what you do: %s Good luck! \"""" % bin_rhymes[correct_bin] def use(self): self.describe() class Plane(Object): def __init__(self): Object.__init__(self) self.name = "plane" self.fname = "the airplane model" def show(self): print "There is an airplane model here." def describe(self): print \ """It looks like it's made out of paper, but you don't think you can simply take it apart.""" class Bill(Object): def __init__(self): Object.__init__(self) self.name = "bill" self.fname = "the 100-dollar bill" def show(self): print "There is a 100-dollar bill here." def describe(self): print "It's just a normal 100-dollar bill." def use(self): global props, area_aliases if not props["current_area"] == "hall_of_destiny": print "There is no use of that here." else: if not "bill" in props["inventory"]: ##You may be able to `use` it because it's on the ground print "First taking the dollar bill ..." if "bill" in area_aliases["hall_of_destiny"].objects: props["inventory"]["bill"] = area_aliases["hall_of_destiny"].objects["bill"] del area_aliases["hall_of_destiny"].objects["bill"] area_aliases["hall_of_destiny"].objects["king"].receive("bill") class Tape(Object): def __init__(self): Object.__init__(self) self.name = "tape" self.fname = "the roll of tape" def show(self): print "There is a roll of tape here." def describe(self): print "It's just a roll of opaque tape." def use(self): print "I find no use of that now." class Manual(Object): def __init__(self): Object.__init__(self) self.name = "manual" self.fname = "the manual" def show(self): print "There is a manual here labeled `CENTRAL HALL PATH`." def describe(self): print \ """The manual says that there are five doors leading from the Central Hall, and that only one of these doors leads to the Hall of Destiny. The manual describes the word on this door like this: %s If you forget this rhyme, you can simply look at the manual again.""" % door_rhymes[doors[correct_door]] def use(self): self.describe() class Card(Object): def __init__(self): Object.__init__(self) self.name = "card" self.fname = "the door-opening card" def show(self): print "There is a door-opening card here." def describe(self): print "You can use this card to enter a specific door." def use(self): global props, area_aliases if not props["current_area"] in ("n_se_corner", "n_s_e_junction"): print "I find no use of that here." else: if not "card" in props["inventory"]: print "First taking the door-opening card ..." if "card" in area_aliases[props["current_area"]].objects: props["inventory"]["card"] = area_aliases[props["current_area"]].objects["card"] del area_aliases[props["current_area"]].objects["card"] if props["current_area"] == "n_se_corner": area_aliases["n_se_corner"].move("north") else: area_aliases["n_s_e_junction"].move("south") class Needle(Object): def __init__(self): Object.__init__(self) self.name = "needle" self.fname = "the sharp needle" def show(self): print "There is a sharp needle here!" def describe(self): print "If desired, you can use this needle to poke things." def poke(self): print "You can't poke a needle with itself!" def use(self): print "Just use the \"poke\" command to poke things with the needle." class Coin(Object): def __init__(self): Object.__init__(self) self.name = "coin" self.fname = "the coin" def show(self): print "There is a coin here." def describe(self): print "A shining coin shaped in a heptagon." def use(self): if not props["current_area"] == "main_texas": print "I find no use of that here." else: area_aliases[props["current_area"]].drop("coin") class Battery(Object): def __init__(self): Object.__init__(self) self.name = "battery" self.fname = "the battery" def show(self): print "There is a battery here." def describe(self): print "A battery that you can use in a specific way." ## Permanent objects class King(Object): def __init__(self): Object.__init__(self) self.name = "king" self.fname = "this dream's King" self.takable = False self.permission = False def describe(self): print "The King of this dream, here in the Hall of Destiny. Don't deny me." def receive(self, obj): global props if obj != "bill": print "The King says, \"I am sorry, but that is /not/ my fortune.\"" else: del props["inventory"]["bill"] print \ """The King says, "Thank you for giving me my fortune. Now I will tell you the real answer to the question: Does there really exist a dreambook?" You get surprisingly excited. The King continues, "Well, there are two arguments to this topic. "According to one argument - that my children boast about - no, there does not exist a dreambook, because a dreambook is a storybook in a dream, and anything in a dream doesn't really /exist/. "But the real answer is: yes, there does exist a dreambook! That's because a dreambook is a real book that /talks/ about dreams, and it can possibly exist. "There has been a world debate about which of these arguments is correct. The final conclusion is that the second argument is correct: there does exist a dreambook. If you have been wondering about this answer, you are now lucky. Now you are free to go north and gaze at your prize. Get the best of luck!" The dollar bill seems as if it has disappeared!""" self.permission = True def wake(self): print "But the King is already awake!" def poke(self): if not "needle" in props["inventory"]: print "You don't have anything that you can use to poke things." else: print "The King strongly forbids you to do that." class Fox(Object): def __init__(self): Object.__init__(self) self.name = "fox" self.fname = "the sleeping fox" self.takable = False def describe(self): print "The fox is curled up and sleeping peacefully." def wake(self): print "You fail to wake this drowsy creature." def poke(self): global area_aliases if not "needle" in props["inventory"]: print "You don't have anything that you can use to poke things." else: print \ """The fox wakes up, whining because his back hurts. He walks away yelling. You wait for him to be out of sight. He left something on the ground here.""" del area_aliases["fox_habitat"].objects["fox"] area_aliases["fox_habitat"].objects["card"] = Card() class Computer(Object): def __init__(self): Object.__init__(self) self.name = "computer" self.fname = "the computer" self.takable = False self.on = False def describe(self): print "Strange computer ... its engine uses batteries." def receive(self, obj): global props if obj != "battery": print "%s is not the correct item to go into the computer." % object_classes[obj]().fname else: print \ """When you put the battery into the computer, it immediately springs to life. The lights start flashing, and the fans seem to startup.""" del props["inventory"]["battery"] self.on = True class Box(Object): def __init__(self): Object.__init__(self) self.name = "box" self.fname = "the box" self.takable = False self.hascoin = True def describe(self): global props if self.hascoin: print \ """Looking deeply into the box, you find a shining coin! You take it out of the box.""" self.hascoin = False props["inventory"]["coin"] = Coin() else: print random.choice([ """Looking deeply into the box, you find a marble. This fails to hold your interest, so you put it back.""", """Looking deeply into the box, you find a checker piece. This fails to hold your interest, so you put it back.""", """Looking deeply into the box, you find a Bingo chip. You don't care much about that at all, so you put it back.""", """Looking deeply into the box, you find a chocolate-covered raisin. You don't really feel like eating it, so you put it back."""]) def receive(self, obj): print "The box is too full." class BinA(Object): def __init__(self): Object.__init__(self) self.name = "bin_a" self.fname = "Bin A" self.takable = False self.objects = {} def describe(self): if not self.objects: print "The bin is empty." else: print "Looking inside the bin:" for key, value in self.objects.iteritems(): print " ", value.show() def receive(self, obj): global props self.objects[obj] = props["inventory"][obj] del props["inventory"][obj] print "You put %s in Bin A." % object_classes[obj]().fname class BinB(Object): def __init__(self): Object.__init__(self) self.name = "bin_b" self.fname = "Bin B" self.takable = False self.objects = {} def describe(self): if not self.objects: print "The bin is empty." else: print "Looking inside the bin:" for key, value in self.objects.iteritems(): print " ", value.show() def receive(self, obj): global props self.objects[obj] = props["inventory"][obj] del props["inventory"][obj] print "You put %s in Bin B." % object_classes[obj]().fname class BinC(Object): def __init__(self): Object.__init__(self) self.name = "bin_c" self.fname = "Bin C" self.takable = False self.objects = {} def describe(self): if not self.objects: print "The bin is empty." else: print "Looking inside the bin:" for key, value in self.objects.iteritems(): print " ", value.show() def receive(self, obj): global props self.objects[obj] = props["inventory"][obj] del props["inventory"][obj] print "You put %s in Bin C." % object_classes[obj]().fname ## How the above classes are referred as ## New classes (for changing "name" to "fname") object_classes = { "paper": Paper, "plane": Plane, "bill": Bill, "tape": Tape, "manual": Manual, "card": Card, "needle": Needle, "coin": Coin, "battery": Battery, "king": King, "fox": Fox, "computer": Computer, "box": Box, "bin_a": BinA, "bin_b": BinB, "bin_c": BinC, } object_equivalents = { "paper": "paper", "strip": "paper", "strip of paper": "paper", "slip": "paper", "slip of paper": "paper", "plane": "plane", "model": "plane", "airplane": "plane", "plane model": "plane", "airplane model": "plane", "model of plane": "plane", "model of airplane": "plane", "bill": "bill", "100-dollar": "bill", "100-dollar bill": "bill", "$100": "bill", "$100 bill": "bill", "tape": "tape", "roll": "tape", "roll of tape": "tape", "manual": "manual", "book": "manual", ## A manual is /not/ a dreambook "chp": "manual", "central-hall-path": "manual", "central hall path": "manual", "card": "card", "door-opening": "card", "door-opening card": "card", "door-opener": "card", "needle": "needle", "sharp needle": "needle", "coin": "coin", "shining coin": "coin", "heptagonal coin": "coin", "heptagon": "coin", "battery": "battery", "computer battery": "battery", "king": "king", "this dream's king": "king", "fox": "fox", "sleeping fox": "fox", "dozer": "fox", "computer": "computer", "battery-run computer": "computer", "box": "box", "large box": "box", "pinned box": "box", "a": "bin_a", "b": "bin_b", "c": "bin_c", "bina": "bin_a", "binb": "bin_b", "binc": "bin_c", "bin a": "bin_a", "bin b": "bin_b", "bin c": "bin_c", } ## Without everything here, Python will think they're gone. ## Note: You can make a function here, so you can use it in the ## restart mode. props = None def reset_props(): global props props = { "inventory": {}, ## inventory of items "visited": {}, ## dictionary of visited areas "current_area": "main_oaktry", ## name of current area "game_run": True, ## game is running } bin_rhymes = { "A": "In order to succeed today, you need to use Bin A!", "B": "When you go and see, take whatever's in Bin B!", "C": "You should believe me; get whatever's in Bin C!", } ## Clues you on what bin to take correct_bin = random.choice(list(bin_rhymes)) door_rhymes = { ## Attempt 12 (need at least 5 for doors) ## odd-space convention: indent TO THE LEFT; "x" in four is " x " "trampoline": # 1/12 """The word on the door bounces with lots of fun: Don't wait for anything ... the bouncing outdoor has begun!""", " bicycle ": # 2/12 """The word on the door is a fun activity to do: You can ride on this transportation with wheels of two!""", "boomerang ": # 3/12 """The word on the door is something funny and true: When you throw this object, it comes right back to you!""", " book ": # 4/12 """The word on the door is something you can read: It can tell a legend or talk about a sunflower seed!""", " cot ": # 5/12 """The word on the door can be understood at one sight: It's comfortable and you can peacefully sleep in it one night!""", " cheese ": # 6/12 """The word on the door is ... (I'm being precise) ... A piece of food that is a favorite to mice!""", "dreambook ": # 7/12 """The word on the door is easy to name: We are trying to find its existence in this text adventure game!""", " pencil ": # 8/12 """The word on the door can be understood at one sight: It's something that can be used to write!""", "telephone ": # 9/12 """The word on the door is useful! ... but that's not all: If you have this device, you can give your friend a call!""", " yellow ": # 10/12 """The word on the door that you don't need to shun Is the color of the brightest rays of the sun!""", " clothes ": # 11/12 """The word on the door is not hard to say: These things are what you wear every day!""", " forty ": # 12/12 """The word on the door is not only funny: It's the number of nickels in two dollars! That's money.""", } doors = {} WORDS = list(door_rhymes) for i in ("w","nw","n","ne","e"): ## Make a /distinct/ word for each door. Order matters. word = random.choice(WORDS) doors[i] = word WORDS.remove(word) DOOR_LABELS = """ NORTH %s NORTHWEST NORTHEAST %s %s WEST EAST %s %s""" % \ tuple(map(doors.__getitem__, ("n","nw","ne","w","e"))) ##must go in format order ## x.__getitem__(y) == x[y] correct_door = random.choice(list(doors)) password = "xyzzy" for i in xrange(8): password += random.choice(list("abcdefghijklmnopqrstuvwxyz")) def lose(): ## There is a difference - a new line in real losing ## and no new line in a purposeful loss. print _lose([]) def _lose(args): global props print " *** SORRY! YOU HAVE LOST ***" print "Would you like to RESTART, RESTORE a saved game, or QUIT?" props["inventory"] = {} props["current_area"] = "outside" def win(): global props print " *** CONGRATULATIONS! YOU HAVE WON ***" print "Would you like to RESTART, RESTORE a saved game, or QUIT?" props["inventory"] = {} props["current_area"] = "outside" ## The preceding functions were property checks and commands. ## Areas ## Area is the superset of all areas. Just so you know :-) class Area(object): def __init__(self): self.name = "area" self.short_desc = "Area" self.long_desc = "This is the default description of an area." self.objects = {} self.paths = {} def __repr__(self): "For saving issues" name = eval(`type(self)`[:-1].split()[-1]).split(".")[-1] return "mkclass(%s, %r)" % (name, self.__dict__) def special_props(self): "Something is special about the section." pass def describe(self, lng=False): """Give long if the user hasn't been there, or else short. Also, give long if we were called with lng being True.""" global props printer = self.short_desc print printer if not self.name in props["visited"] or lng: print self.long_desc self.special_props() ## Show us the objects for key, value in self.objects.iteritems(): value.show() ## Now the section is visited. props["visited"][self.name] = self def Type(self, text): "Default for typing." print "There's nothing here for you to type on." def move(self, direct): global props if direct in self.paths: props["current_area"] = self.paths[direct] area_aliases[props["current_area"]].describe() else: print "You cannot go there." def north(self): self.move("north") def south(self): self.move("south") def east(self): self.move("east") def west(self): self.move("west") def northeast(self): self.move("northeast") def northwest(self): self.move("northwest") def southeast(self): self.move("southeast") def southwest(self): self.move("southwest") def take(self, obj): "obj is a string" global props, area_aliases if obj in props["inventory"]: print "You already have that!" elif obj in area_aliases[props["current_area"]].objects: if not area_aliases[props["current_area"]].objects[obj].takable: print "That is not something you can carry!" else: print "Taken." props["inventory"][obj] = area_aliases[props["current_area"]].objects[obj] del area_aliases[props["current_area"]].objects[obj] else: inabin = False for BIN in ("bin_a", "bin_b", "bin_c"): binletter = BIN[-1].upper() if BIN in area_aliases[props["current_area"]].objects and \ obj in area_aliases[props["current_area"]].objects[BIN].objects: print "You remove %s from Bin %s." % (object_classes[obj]().fname, binletter) props["inventory"][obj] = area_aliases[props["current_area"]].objects[BIN].objects[obj] del area_aliases[props["current_area"]].objects[BIN].objects[obj] inabin = True if not inabin: print "You can't see any such thing." def drop(self, obj): global props, area_aliases if obj in props["inventory"]: print "Dropped." if not obj == "plane" else "The airplane swishes and falls to the ground." area_aliases[props["current_area"]].objects[obj] = props["inventory"][obj] del props["inventory"][obj] elif obj in area_aliases[props["current_area"]].objects: print "You don't have that!" else: print "You can't see any such thing." def examine(self, obj): if obj in props["inventory"]: props["inventory"][obj].describe() return if obj in area_aliases[props["current_area"]].objects: area_aliases[props["current_area"]].objects[obj].describe() return ## Inside the bins if props["current_area"] == "bin_room": if obj in area_aliases["bin_room"].objects["bin_a"].objects: area_aliases["bin_room"].objects["bin_a"].objects[obj].describe() return if obj in area_aliases["bin_room"].objects["bin_b"].objects: area_aliases["bin_room"].objects["bin_b"].objects[obj].describe() return if obj in area_aliases["bin_room"].objects["bin_c"].objects: area_aliases["bin_room"].objects["bin_c"].objects[obj].describe() return print "You can't see any such thing." ## Here are some real areas class MainOaktry(Area): def __init__(self): Area.__init__(self) self.name = "main_oaktry" self.short_desc = "Main/Oaktry Intersection" self.long_desc = \ """You are at the intersection of Main Street and Oaktry Avenue. Roads lead off to the north and east, where you can see several more intersections. However, the signs that used to be there are no longer there. An opening leads to the northwest.""" self.objects = {} self.paths = {"north": "first_oaktry", "east": "main_texas", "northwest": "mechanics_fork"} class MainTexas(Area): def __init__(self): Area.__init__(self) self.name = "main_texas" self.short_desc = "Main/Texas Intersection" self.long_desc = \ """You are on Main Street at the south end of Texas Avenue. There is a little fog visible that says "DROP ANY COINS HERE".""" self.objects = {} self.passed = False self.paths = {"north": "first_texas", "east": "main_syco", "west": "main_oaktry"} def drop(self, obj): global props, area_aliases if obj in props["inventory"]: area_aliases[props["current_area"]].objects[obj] = props["inventory"][obj] del props["inventory"][obj] if obj == "coin": print "The coin falls into the fog, out of sight." print "You hear a bell. Then letters appear on the fog. They say:" print " The password in the discovery is: %s" % password self.passed = True del area_aliases[props["current_area"]].objects[obj] else: print "Dropped." if not obj == "plane" else "The airplane swishes and falls to the ground." elif obj in area_aliases[props["current_area"]].objects: print "You don't have that!" else: print "You can't see any such thing." def special_props(self): if self.passed: print "The fog also says, \"The password is %s\"" % password class MainSyco(Area): def __init__(self): Area.__init__(self) self.name = "main_syco" self.short_desc = "Main/Syco Intersection" self.long_desc = "You are at the east end of Main Street and the south end of Syco Avenue." self.objects = {} self.paths = {"north": "first_syco", "west": "main_texas"} class FirstOaktry(Area): def __init__(self): Area.__init__(self) self.name = "first_oaktry" self.short_desc = "First/Oaktry Intersection" self.long_desc = "You are on Oaktry Avenue at the west end of First Street." self.objects = {} self.paths = {"north": "second_oaktry", "south": "main_oaktry", "east": "first_texas"} class FirstTexas(Area): def __init__(self): Area.__init__(self) self.name = "first_texas" self.short_desc = "First/Texas Intersection" self.long_desc = "You are at the intersection of First Street and Texas Avenue." self.objects = {} self.paths = {"north": "second_texas", "south": "main_texas", "east": "first_syco", "west": "first_oaktry"} class FirstSyco(Area): def __init__(self): Area.__init__(self) self.name = "first_syco" self.short_desc = "First/Syco Intersection" self.long_desc = "You are on Syco Avenue at the east end of First Street." self.objects = {} self.paths = {"north": "second_syco", "south": "main_syco", "west": "first_texas"} class SecondOaktry(Area): def __init__(self): Area.__init__(self) self.name = "second_oaktry" self.short_desc = "Second/Oaktry Intersection" self.long_desc = "You are on the west end of Second Street and the north end of Oaktry Avenue." self.objects = {} self.paths = {"south": "first_oaktry", "east": "second_texas"} class SecondTexas(Area): def __init__(self): Area.__init__(self) self.name = "second_texas" self.short_desc = "Second/Texas Intersection" self.long_desc = "You are on Second Street at the north end of Texas Avenue." self.objects = {} self.paths = {"south": "first_texas", "east": "second_syco", "west": "second_oaktry"} class SecondSyco(Area): def __init__(self): Area.__init__(self) self.name = "second_syco" self.short_desc = "Second/Syco Intersection" self.long_desc = \ """You are on the east end of Second Street and the north end of Syco Avenue. There is a large box pinned to a sign here.""" self.objects = {"box": Box()} self.paths = {"south": "first_syco", "west": "second_texas"} class MechanicsFork(Area): def __init__(self): Area.__init__(self) self.name = "mechanics_fork" self.short_desc = "Mechanics Fork" self.long_desc = \ """You are at a fork where paths lead north and west. These places are useful for mechanics. You can also go back southeast.""" self.objects = {} self.paths = {"north": "battery_storage", "west": "computer_room", "southeast": "main_oaktry"} class ComputerRoom(Area): def __init__(self): Area.__init__(self) self.name = "computer_room" self.short_desc = "Computer Room" self.long_desc = \ """You are in a computer room. Unfortunately, the computer here is not complex. However, its keyboard looks beautiful. Use the "type" command to type on the keyboard. The exit is to the east.""" self.objects = {"computer": Computer()} self.paths = {"east": "mechanics_fork"} def special_props(self): if not self.objects["computer"].on: print "The panel lights on the computer are steady and motionless." else: print \ """The panel lights on the computer are flashing in a seemingly organized pattern. The computer reads: "PLEASE ENTER THE PASSWORD IN THE DISCOVERY\"""" def Type(self, text): global props if not self.objects["computer"].on: print "You type on the keyboard, but the characters do not echo." else: if text == "": print "You must supply text to type on the same line." else: if text != password: print "The computer reads: \"SORRY, BUT THAT PASSWORD IS INCORRECT\"" else: print \ """The computer reads: "THANK YOU FOR ENTERING THE PASSWORD" You continue to sleep soundly as the image in your dream blurs. Then appears a mysterious sight that you never knew about before. """ props["current_area"] = "cave_fork" area_aliases["cave_fork"].describe() class BatteryStorage(Area): def __init__(self): Area.__init__(self) self.name = "battery_storage" self.short_desc = "Battery Storage Room" self.long_desc = \ """You are in a battery storage room. Unfortunately, all of the bins on the bottom are locked, and you're not tall enough to reach the bins on the top. The exit is to the south.""" self.objects = {"battery": Battery()} self.paths = {"south": "mechanics_fork"} ## Begin next section class SWEnd(Area): def __init__(self): Area.__init__(self) self.name = "sw_end" self.short_desc = "SW End of Cave" self.long_desc = "This is a dead end. You can go back northeast." self.objects = {"needle": Needle()} self.paths = {"northeast": "cave_fork"} class CaveFork(Area): def __init__(self): Area.__init__(self) self.name = "cave_fork" self.short_desc = "Cave Fork" self.long_desc = \ """You are now in the fork of a mysterious cave. Paths lead off to the east, northwest, and southwest.""" self.paths = {"east": "fox_habitat", "northwest": "n_se_corner", "southwest": "sw_end"} class FoxHabitat(Area): def __init__(self): Area.__init__(self) self.name = "fox_habitat" self.short_desc = "Fox' Habitat" self.long_desc = \ """This is a completely different sight! You are now in the habitat of a fox that had the wish to live in a cave. The rest of the cave is to the west.""" self.objects = {"fox": Fox()} self.paths = {"west": "cave_fork"} def special_props(self): "The most suitable way to indicate this permanent object." if "fox" in self.objects: print "A fox is here, curled up in a sound sleep." def nono(self): "Ha!" print "You should not be peeking into the fox' private rooms!" def north(self): self.nono() def northeast(self): self.east() def east(self): "Don't walk into the fox!" if not "fox" in self.objects: self.nono() else: print \ """You start walking into the fox, but he feels unusually /hard/. Your closed eyelids open up, and you realize that you're walking into your bedroom desk, pulling the blankets with your body. That wasn't much of a satisfactory dream.""" lose() def southeast(self): self.east() def south(self): self.nono() class NSECorner(Area): def __init__(self): Area.__init__(self) self.name = "n_se_corner" self.short_desc = "N/SE Corner" self.long_desc = "You are at a corner. There is a path to the southeast and a door to the north." self.paths = {"north": "n_s_e_junction", "southeast": "cave_fork"} def north(self): if not "card" in props["inventory"]: print "Sorry, you don't have a card that allows you to go through this door." else: print "The door scans the card and opens, and you walk through." self.move("north") class NSEJunction(Area): def __init__(self): Area.__init__(self) self.name = "n_s_e_junction" self.short_desc = "N/S/E Junction" self.long_desc = \ """You are at a junction. There is a door to the south, an opening to the north, and a path to the east.""" self.paths = {"north": "blank_room", "east": "bin_room", "south": "n_se_corner"} def south(self): if not "card" in props["inventory"]: print "Sorry, you don't have a card that allows you to go through this door." else: print "The door scans the card and opens, and you walk through." self.move("south") class BlankRoom(Area): def __init__(self): Area.__init__(self) self.name = "blank_room" self.short_desc = "Blank Room" self.long_desc = \ """You are in a blank room. Everything looks gray and bare here, except for the exit to the south.""" self.objects = {"paper": Paper()} self.paths = {"south": "n_s_e_junction"} class BinRoom(Area): def __init__(self): Area.__init__(self) self.name = "bin_room" self.short_desc = "Bin Room" self.long_desc = \ """This is a bin room. There are three bins here, labeled A, B, C. Paths lead to the west and east.""" self.objects = {"bin_a": BinA(), "bin_b": BinB(), "bin_c": BinC()} ## Recall the correct bin - that's where the dollar bill goes. billbin = "bin_" + correct_bin.lower() otherbins = list(self.objects) otherbins.remove(billbin) self.objects[billbin].objects = {"bill": Bill()} planeside = random.randrange(2) if planeside == 1: otherbins.reverse() self.objects[otherbins[0]].objects = {"plane": Plane()} self.objects[otherbins[1]].objects = {"tape": Tape()} self.paths = {"west": "n_s_e_junction", "east": "n_s_w_junction"} def special_props(self): "Indicate what is in the bins if there is anything." if self.objects["bin_a"].objects: ## Namely, is there anything in Bin A? print "Looking inside Bin A:" for key, value in self.objects["bin_a"].objects.iteritems(): print " ", value.show() if self.objects["bin_b"].objects: print "Looking inside Bin B:" for key, value in self.objects["bin_b"].objects.iteritems(): print " ", value.show() if self.objects["bin_c"].objects: print "Looking inside Bin C:" for key, value in self.objects["bin_c"].objects.iteritems(): print " ", value.show() class ManualRoom(Area): def __init__(self): Area.__init__(self) self.name = "manual_room" self.short_desc = "Manual Room" self.long_desc = \ """You are now in a room where manuals come from. Unfortunately, the shelves on the bottom are closed and locked, and you're not tall enough to reach the shelves up top. The exit is to the north.""" self.objects = {"manual": Manual()} self.paths = {"north": "n_s_w_junction"} class NSWJunction(Area): def __init__(self): Area.__init__(self) self.name = "n_s_w_junction" self.short_desc = "N/S/W Junction" self.long_desc = "You are in a junction where paths go north, south, and west." self.paths = {"north": "central_hall", "west": "bin_room", "south": "manual_room"} ## Now for the finality of destiny! class CentralHall(Area): def __init__(self): Area.__init__(self) self.name = "central_hall" self.short_desc = "Central Hall" ## I wish to remark, by the way, that this setting is like Smullyan's ## Sanctum in the quest, "WHY IS THERE SOMETHING INSTEAD OF NOTHING?" ## There are four doors, and if you go through the wrong door, a dragon ## eats you. Eight logical priests make statements to test you. self.long_desc = \ """You have now reached the Central Hall! This hall has round walls and a high ceiling. In front of you are five shining doors! They lead to the west, northwest, north, northeast, and east. Only one of these doors leads to the Hall of Destiny. The path you came from is to the south.""" self.paths = {"south": "n_s_w_junction"} def special_props(self): """Skip a line after DOOR_LABELS if there are any objects to list. Don't skip a line if there is nothing else to list.""" print "Each door has a word inscribed on it very neatly. The words are:" print DOOR_LABELS if self.objects: print def west(self): self.trydoor("w") def northwest(self): self.trydoor("nw") def north(self): self.trydoor("n") def northeast(self): self.trydoor("ne") def east(self): self.trydoor("e") def trydoor(self, direct): global props if direct != correct_door: print \ """Guess what ... that was /not/ the correct door. BOOM! A laser immediately zaps you. You wake up from this horrible nightmare, and you're shaking under the blankets.""" lose() else: print \ """Congratulations! You have entered the correct door! You continue walking and walking through until you have no idea where you are. Then, you just pull the blankets up and continue to sleep. With the question stuck to your mind, the King of this dream appears! You're desired to know what the real answer to the question is. When you lend the King his fortune, you will find out the answer! """ props["current_area"] = "hall_of_destiny" area_aliases["hall_of_destiny"].describe() class HallOfDestiny(Area): def __init__(self): Area.__init__(self) self.name = "hall_of_destiny" self.short_desc = "Hall of Destiny" self.long_desc = \ """You are now in the Hall of Destiny! The King of this dream is here. A light indicates a path to the north.""" self.objects = {"king": King()} def special_props(self): if not self.objects["king"].permission: print "The King says, \"Give me my fortune and I will tell you something.\"" else: print "The King says, \"Off you go north.\"" def north(self): if not self.objects["king"].permission: print "The King says, \"Sorry! I do not permit you to go north yet.\"" else: print \ """The King says, "God speed you well!" You continue going north and thinking of the answer the King told you. Then you find a light showing that you've won! You gaze at the light. Then, gradually, you feel as if your back is on the ground, and you feel something soft surround you. Then everything goes black. Soon, you hear a voice shout, "Wake up! Wake up! I heard a bluejay singing outside the window!" You gradually open your eyes and sit up. Sure enough, your younger brother Nathan is standing beside the door. The sun is shining brightly in the sky. You get out of bed and say, "Nathan, I found out the answer to your question in my dream! According to one argument, no, because anything in a dream doesn't really /exist/; but to speak truth, the answer is yes! There /does/ exist a dreambook!" "How?" asks Nathan. "A `dreambook` can also designate an existing book that /talks/ about one's dreams!" you say proudly. "Say, did you have a dream last night?" "I think so," says Nathan. "Do you remember what it was?" you ask. "No," says Nathan sadly. "I mostly slept." You agree. "Anyway, wait until I tell my teacher!" thinks Nathan happily. You both go downstairs to have some breakfast, and then head for school. """ win() class Outside(Area): ## Oh oh! What do you do? def __init__(self): Area.__init__(self) self.name = "outside" def describe(self, lng=True): print "You are now outside the game. All is black." print "Would you like to RESTART, RESTORE a saved game, or QUIT?" area_aliases = None def reset_areas(): global area_aliases area_aliases = { "main_oaktry": MainOaktry(), "main_texas": MainTexas(), "main_syco": MainSyco(), "first_oaktry": FirstOaktry(), "first_texas": FirstTexas(), "first_syco": FirstSyco(), "second_oaktry": SecondOaktry(), "second_texas": SecondTexas(), "second_syco": SecondSyco(), "mechanics_fork": MechanicsFork(), "computer_room": ComputerRoom(), "battery_storage": BatteryStorage(), "sw_end": SWEnd(), "cave_fork": CaveFork(), "fox_habitat": FoxHabitat(), "n_se_corner": NSECorner(), "n_s_e_junction": NSEJunction(), "blank_room": BlankRoom(), "bin_room": BinRoom(), "manual_room": ManualRoom(), "n_s_w_junction": NSWJunction(), "central_hall": CentralHall(), "hall_of_destiny": HallOfDestiny(), "outside": Outside(), } reset_props() reset_areas() ## Verblist of all commands: ## Remember to differentiate "a b c" from ["a", "b", "c"] ## (Don't forget: we did this ourselves by giving each "command" ## one argument, as a "list of arguments".) ## There are lots of ways to type things. def dream(args): if props["current_area"] == "outside": print "This is outside the game; try restarting or restoring." else: print "Ah ha! You do feel comfortable in your bed covers." verblist = { "go to north": north, "go north": north, "north": north, "go to n": north, "go n": north, "n": north, "go to south": south, "go south": south, "south": south, "go to s": south, "go s": south, "s": south, "go to east": east, "go east": east, "east": east, "go to e": east, "go e": east, "e": east, "go to west": west, "go west": west, "west": west, "go to w": west, "go w": west, "w": west, "go to northeast": northeast, "go northeast": northeast, "northeast": northeast, "go to ne": northeast, "go ne": northeast, "ne": northeast, "go to southeast": southeast, "go southeast": southeast, "southeast": southeast, "go to se": southeast, "go se": southeast, "se": southeast, "go to northwest": northwest, "go northwest": northwest, "northwest": northwest, "go to nw": northwest, "go nw": northwest, "nw": northwest, "go to southwest": southwest, "go southwest": southwest, "southwest": southwest, "go to sw": southwest, "go sw": southwest, "sw": southwest, "help": _help, "helpfile": _help, "?": _help, "save": save, "save as": save, "restore": restore, "restore as": restore, "quit": _quit, "end": _quit, "take": take, "pick up": take, "get": take, "take all": take_all, "get all": take_all, "pick up all": take_all, "take everything": take_all, "get everything": take_all, "pick up everything": take_all, "pick everything up": take_all, "drop": drop, "put down": drop, "throw": drop, "throw out": drop, "toss": drop, "toss out": drop, "relinquish": drop, "drop all": drop_all, "put down all": drop_all, "throw all": drop_all, "throw out all": drop_all, "toss all": drop_all, "toss out all": drop_all, "relinquish all": drop_all, "drop everything": drop_all, "put everything down": drop_all, "throw everything": drop_all, "throw everything out": drop_all, "toss everything": drop_all, "toss everything out": drop_all, "relinquish everything": drop_all, "look": examine, "look at": examine, "look around": examine, "l": examine, "l at": examine, "l around": examine, "l r": examine, "examine": examine, "x": examine, "describe": examine, "read": examine, "r": examine, "eat": eat, "eat up": eat, "devour": eat, "devour up": eat, "consume": eat, "consume up": eat, "drink": drink, "drink up": drink, "quaff": drink, "quaff up": drink, "current inventory": inventory, "inventory": inventory, "items": inventory, "inven": inventory, "inv": inventory, "i": inventory, "put": put, "insert": put, "give": give, "lend": give, "hand": give, "type": _type, "type in": _type, "enter": _type, "enter in": _type, "sleep": sleep, "nap": sleep, "take nap": sleep, "doze": sleep, "rest": sleep, "wake": wake, "awaken": wake, "wake up": wake, "awake": wake, ## This is actually /no/ "curiousity" ... ## "rest" gives the message, "What do you mean? You're already asleep." ## And surely, if you're sleeping, then you're resting. "poke": poke, "poke on": poke, "pin": poke, "pin on": poke, "hurt": poke, "poke self": poke_self, "poke on self": poke_self, "pin self": poke_self, "pin on self": poke_self, "hurt self": poke_self, "poke myself": poke_self, "poke on myself": poke_self, "pin myself": poke_self, "pin on myself": poke_self, "hurt myself": poke_self, "poke me": poke_self, "poke on me": poke_self, "pin me": poke_self, "pin on me": poke_self, "hurt me": poke_self, "poke my": poke_self, "poke on my": poke_self, "pin my": poke_self, "pin on my": poke_self, "hurt my": poke_self, "talk": say, "say": say, "speak": say, "utter": say, "use": use, "use purpose of": use, ## A bright example is that writing and erasing is the purpose of a pencil "die": die, "kill myself": die, "lose": _lose, "win": _win, ## "win outright" will thus be read as "win". "echo": echo, ## "echo" is not too bright; should not have a majority. "restart": restart, "does there really exist a dreambook?": dream, "does there exist a dreambook?": dream, "does a dreambook exist?": dream, "do there really exist dreambooks?": dream, "do there exist dreambooks?": dream, "do dreambooks exist?": dream, } def execprint(com): "Execute the command. This causes the information to be printed." x = find_left(" ".join(com), verblist) if x == "not found": print "I do not understand that." else: DictValue(x)(trim_left(" ".join(com), verblist).split()) ## Where the game is run. def run_game(): print "GAME OF METADUNNET[6]" print "DOES THERE REALLY EXIST A DREAMBOOK?" print print "(First time players play, they may wish to HELP.)" print print \ """You come home from an evening dance party one night, tired. You walk upstairs to the bedrooms. Standing at his door, your younger brother, Nathan, says, "Guess what I learned in school today! A special question! 'Does there really exist a dreambook?'" (Nathan here is the same Nathan in Metadunnet[4], if you know the game.) You say, "Amazing! Do you know the answer?" Nathan replies, "No, I don't; it's a hard question." You agree. Your parents come. "Nathan, darling, it's time for bed," they say. "Tomorrow's another school day." (Your parents are, of course, Nathan's parents, since Nathan's your brother.) Nathan walks in his room and says to you, "Good night!" You respond. You then brush your teeth and lie in bed, thinking about the question that Nathan told you: Does there really exist a dreambook? Thinking about dreambooks makes you even more tired. You soon close your eyes and fall fast asleep. As you continue to sleep, your mind becomes subconscious, and you begin to dream. In your dream are large letters that read: DOES THERE REALLY EXIST A DREAMBOOK? Then everything clears and you start to see a corner of a small town. """ area_aliases[props["current_area"]].describe() print while props["game_run"]: reply = game_split_line(raw_input("> ").lower()) print for i in reply: if i: execprint(i) print if __name__ == "__main__": run_game()