From 3f3e1145363712fe21c767bae71607fc34c04ec5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 20 Apr 2022 07:08:11 -0400 Subject: [PATCH] In the grapher, split forset from surface mode. --- adventure.yaml | 2 +- make_graph.py | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/adventure.yaml b/adventure.yaml index b1c4358..4410767 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -369,7 +369,7 @@ locations: !!omap description: long: !!null short: !!null - maptag: !!null + maptag: 'Nowhere' conditions: {} travel: [ ] diff --git a/make_graph.py b/make_graph.py index cd085f4..f29c3e1 100755 --- a/make_graph.py +++ b/make_graph.py @@ -6,8 +6,9 @@ Make a DOT graph of Colossal Cave. -a = emit graph of entire dungeon -d = emit graoh of mazw all different +-f = emit graph of forest locations -m = emit graph of maze all alike --s = emit graph of surface locations +-s = emit graph of non-forest surface locations -v = include internal sy,no;s in room labels """ # Copyright (c) 2017 by Eric S. Raymond @@ -25,12 +26,10 @@ def alldifferent(loc): def surface(loc): "Select out surface locations" - attrs = location_lookup[loc] - if ("ABOVE" in attrs["conditions"]) and attrs["conditions"]["ABOVE"]: - return True - if ("FOREST" in attrs["conditions"]) and attrs["conditions"]["FOREST"]: - return True - return False + return location_lookup[loc]["conditions"].get("ABOVE") + +def forest(loc): + return location_lookup[loc]["conditions"].get("FOREST") def abbreviate(d): m = {"NORTH":"N", "EAST":"E", "SOUTH":"S", "WEST":"W", "UPWAR":"U", "DOWN":"D"} @@ -112,7 +111,7 @@ if __name__ == "__main__": object_lookup = dict(db["objects"]) try: - (options, arguments) = getopt.getopt(sys.argv[1:], "admsv") + (options, arguments) = getopt.getopt(sys.argv[1:], "adfmsv") except getopt.GetoptError as e: print(e) sys.exit(1) @@ -124,6 +123,8 @@ if __name__ == "__main__": subset = lambda loc: True elif switch == '-d': subset = alldifferent + elif switch == '-f': + subset = forest elif switch == '-m': subset = allalike elif switch == '-s': -- 2.31.1