3 # Make a DOT graph of the dungeon
5 # Copyright (c) 2017 by Eric S. Raymond
6 # SPDX-License-Identifier: BSD-2-clause
10 def allalike(loc, dest):
11 "Select out loci related to the Maze All Alike"
12 return ("ALIKE" in loc) or ("MAZEEND" in loc) or ("STALACTITE" in loc) or (loc == "LOC_MISTWEST" and "ALIKE" in dest)
15 m = {"NORTH":"N", "EAST":"E", "SOUTH":"S", "WEST":"W", "UPWAR":"U", "DOWN":"D"}
18 if __name__ == "__main__":
19 with open("adventure.yaml", "r") as f:
20 db = yaml.safe_load(f)
23 for (loc, attrs) in db["locations"]:
24 travel = attrs["travel"]
27 verbs = [abbreviate(x) for x in dest["verbs"]]
30 action = dest["action"]
31 if action[0] == "goto":
33 if not allalike(loc, dest):
35 arc = "%s -> %s" % (loc[4:], dest[4:])
36 label=",".join(verbs).lower()
38 arc += ' [label="%s"]' % label