Mapping improvements.
This commit is contained in:
parent
0f5fd82b77
commit
ad75cc1eb7
3 changed files with 78 additions and 15 deletions
|
@ -544,10 +544,10 @@ locations: !!omap
|
||||||
action: [goto, LOC_GRATE]},
|
action: [goto, LOC_GRATE]},
|
||||||
{verbs: [ENTRA], action: [goto, LOC_BELOWGRATE]},
|
{verbs: [ENTRA], action: [goto, LOC_BELOWGRATE]},
|
||||||
{verbs: [DOWN, EAST, DEBRI], action: [goto, LOC_DEBRIS]},
|
{verbs: [DOWN, EAST, DEBRI], action: [goto, LOC_DEBRIS]},
|
||||||
{verbs: [INWAR, UPWAR, WEST], action: [goto, LOC_BIRD]},
|
{verbs: [INWAR, UPWAR, WEST], action: [goto, LOC_BIRDCHAMBER]},
|
||||||
{verbs: [PIT], action: [goto, LOC_PITTOP]},
|
{verbs: [PIT], action: [goto, LOC_PITTOP]},
|
||||||
]
|
]
|
||||||
- LOC_BIRD:
|
- LOC_BIRDCHAMBER:
|
||||||
description:
|
description:
|
||||||
long: |-
|
long: |-
|
||||||
You are in a splendid chamber thirty feet high. The walls are frozen
|
You are in a splendid chamber thirty feet high. The walls are frozen
|
||||||
|
@ -576,7 +576,7 @@ locations: !!omap
|
||||||
action: [goto, LOC_GRATE]},
|
action: [goto, LOC_GRATE]},
|
||||||
{verbs: [ENTRA], action: [goto, LOC_BELOWGRATE]},
|
{verbs: [ENTRA], action: [goto, LOC_BELOWGRATE]},
|
||||||
{verbs: [DEBRI], action: [goto, LOC_DEBRIS]},
|
{verbs: [DEBRI], action: [goto, LOC_DEBRIS]},
|
||||||
{verbs: [PASSA, EAST], action: [goto, LOC_BIRD]},
|
{verbs: [PASSA, EAST], action: [goto, LOC_BIRDCHAMBER]},
|
||||||
{verbs: [DOWN, PIT, STEPS], cond: [carry, NUGGET],
|
{verbs: [DOWN, PIT, STEPS], cond: [carry, NUGGET],
|
||||||
action: [goto, LOC_NECKBROKE]},
|
action: [goto, LOC_NECKBROKE]},
|
||||||
{verbs: [DOWN], action: [goto, LOC_MISTHALL]},
|
{verbs: [DOWN], action: [goto, LOC_MISTHALL]},
|
||||||
|
@ -1084,7 +1084,7 @@ locations: !!omap
|
||||||
short: 'You''re at brink of pit.'
|
short: 'You''re at brink of pit.'
|
||||||
conditions: {DEEP: true, NOBACK: true}
|
conditions: {DEEP: true, NOBACK: true}
|
||||||
travel: [
|
travel: [
|
||||||
{verbs: [DOWN, CLIMB], action: [goto, LOC_BIRD]},
|
{verbs: [DOWN, CLIMB], action: [goto, LOC_BIRDCHAMBER]},
|
||||||
{verbs: [WEST], action: [goto, LOC_ALIKE10]},
|
{verbs: [WEST], action: [goto, LOC_ALIKE10]},
|
||||||
{verbs: [SOUTH], action: [goto, LOC_MAZEEND6]},
|
{verbs: [SOUTH], action: [goto, LOC_MAZEEND6]},
|
||||||
{verbs: [NORTH], action: [goto, LOC_ALIKE12]},
|
{verbs: [NORTH], action: [goto, LOC_ALIKE12]},
|
||||||
|
@ -3127,7 +3127,7 @@ objects: !!omap
|
||||||
- BIRD:
|
- BIRD:
|
||||||
words: ['bird']
|
words: ['bird']
|
||||||
inventory: 'Little bird in cage'
|
inventory: 'Little bird in cage'
|
||||||
locations: LOC_BIRD
|
locations: LOC_BIRDCHAMBER
|
||||||
states: [BIRD_UNCAGED, BIRD_CAGED, BIRD_FOREST_UNCAGED]
|
states: [BIRD_UNCAGED, BIRD_CAGED, BIRD_FOREST_UNCAGED]
|
||||||
descriptions:
|
descriptions:
|
||||||
- 'A cheerful little bird is sitting here singing.'
|
- 'A cheerful little bird is sitting here singing.'
|
||||||
|
|
2
main.c
2
main.c
|
@ -1088,7 +1088,7 @@ static bool preprocess_command(command_t *command)
|
||||||
if (game.loc == LOC_COBBLE ||
|
if (game.loc == LOC_COBBLE ||
|
||||||
game.loc == LOC_DEBRIS ||
|
game.loc == LOC_DEBRIS ||
|
||||||
game.loc == LOC_AWKWARD ||
|
game.loc == LOC_AWKWARD ||
|
||||||
game.loc == LOC_BIRD ||
|
game.loc == LOC_BIRDCHAMBER ||
|
||||||
game.loc == LOC_PITTOP) {
|
game.loc == LOC_PITTOP) {
|
||||||
command->word[0].id = ENTRANCE;
|
command->word[0].id = ENTRANCE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,29 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
"""\
|
||||||
|
usage: make-graph.py [-a] [-m] [-s]
|
||||||
|
|
||||||
# Make a DOT graph of the dungeon
|
Make a DOT graph of Colossal Cave
|
||||||
#
|
|
||||||
|
-a = emit graph of entire dungeon
|
||||||
|
-m = emit graph of maze all alike
|
||||||
|
-s = emit graph of surface locations
|
||||||
|
"""
|
||||||
# Copyright (c) 2017 by Eric S. Raymond
|
# Copyright (c) 2017 by Eric S. Raymond
|
||||||
# SPDX-License-Identifier: BSD-2-clause
|
# SPDX-License-Identifier: BSD-2-clause
|
||||||
|
|
||||||
import sys, yaml
|
import sys, yaml, getopt
|
||||||
|
|
||||||
def allalike(loc, dest):
|
def allalike(loc):
|
||||||
"Select out loci related to the Maze All Alike"
|
"Select out loci related to the Maze All Alike"
|
||||||
return ("ALIKE" in loc) or ("MAZEEND" in loc) or ("STALACTITE" in loc) or (loc == "LOC_MISTWEST" and "ALIKE" in dest)
|
return ("ALIKE" in loc) or (loc == "LOC_PITBRINK") or ("MAZEEND" in loc) or ("STALACTITE" in loc) or (loc == "LOC_MISTWEST")
|
||||||
|
|
||||||
|
def surface(attrs):
|
||||||
|
"Select out surface locations"
|
||||||
|
if ("ABOVE" in attrs["conditions"]) and attrs["conditions"]["ABOVE"]:
|
||||||
|
return True
|
||||||
|
if ("FOREST" in attrs["conditions"]) and attrs["conditions"]["FOREST"]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def abbreviate(d):
|
def abbreviate(d):
|
||||||
m = {"NORTH":"N", "EAST":"E", "SOUTH":"S", "WEST":"W", "UPWAR":"U", "DOWN":"D"}
|
m = {"NORTH":"N", "EAST":"E", "SOUTH":"S", "WEST":"W", "UPWAR":"U", "DOWN":"D"}
|
||||||
|
@ -19,8 +33,59 @@ if __name__ == "__main__":
|
||||||
with open("adventure.yaml", "r") as f:
|
with open("adventure.yaml", "r") as f:
|
||||||
db = yaml.safe_load(f)
|
db = yaml.safe_load(f)
|
||||||
|
|
||||||
|
try:
|
||||||
|
(options, arguments) = getopt.getopt(sys.argv[1:], "ams")
|
||||||
|
except getopt.GetoptError as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
subset = "maze"
|
||||||
|
for (switch, val) in options:
|
||||||
|
if switch == '-a':
|
||||||
|
subset = "all"
|
||||||
|
elif switch == '-m':
|
||||||
|
subset = "maze"
|
||||||
|
elif switch == '-s':
|
||||||
|
subset = "surface"
|
||||||
|
else:
|
||||||
|
sys.stderr.write(__doc__)
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
startlocs = {}
|
||||||
|
for obj in db["objects"]:
|
||||||
|
objname = obj[0]
|
||||||
|
location = obj[1].get("locations")
|
||||||
|
if "OBJ" not in objname and location != "LOC_NOWHERE" and ("immovable" not in obj[1] or not obj[1]["immovable"]):
|
||||||
|
if location in startlocs:
|
||||||
|
startlocs[location].append(objname)
|
||||||
|
else:
|
||||||
|
startlocs[location] = [objname]
|
||||||
|
|
||||||
|
startlocs = {}
|
||||||
|
for obj in db["objects"]:
|
||||||
|
objname = obj[0]
|
||||||
|
location = obj[1].get("locations")
|
||||||
|
if "OBJ" not in objname and location != "LOC_NOWHERE" and ("immovable" not in obj[1] or not obj[1]["immovable"]):
|
||||||
|
if location in startlocs:
|
||||||
|
startlocs[location].append(objname)
|
||||||
|
else:
|
||||||
|
startlocs[location] = [objname]
|
||||||
|
|
||||||
print("digraph G {")
|
print("digraph G {")
|
||||||
for (loc, attrs) in db["locations"]:
|
|
||||||
|
for (loc, attrs) in db["locations"]:
|
||||||
|
if subset == "surface" and not surface(attrs):
|
||||||
|
continue
|
||||||
|
if subset == "maze" and not allalike(loc):
|
||||||
|
continue;
|
||||||
|
node_label = loc[4:]
|
||||||
|
if loc in startlocs:
|
||||||
|
node_label += "\\n" + ",".join(startlocs[loc]).lower()
|
||||||
|
print(' %s [shape=box,label="%s"]' % (loc[4:], node_label))
|
||||||
|
|
||||||
|
for (loc, attrs) in db["locations"]:
|
||||||
|
if subset == "surface" and not surface(attrs):
|
||||||
|
continue
|
||||||
travel = attrs["travel"]
|
travel = attrs["travel"]
|
||||||
if len(travel) > 0:
|
if len(travel) > 0:
|
||||||
for dest in travel:
|
for dest in travel:
|
||||||
|
@ -30,7 +95,7 @@ if __name__ == "__main__":
|
||||||
action = dest["action"]
|
action = dest["action"]
|
||||||
if action[0] == "goto":
|
if action[0] == "goto":
|
||||||
dest = action[1]
|
dest = action[1]
|
||||||
if not allalike(loc, dest):
|
if subset == "maze" and not (allalike(loc) or allalike(dest)):
|
||||||
continue;
|
continue;
|
||||||
arc = "%s -> %s" % (loc[4:], dest[4:])
|
arc = "%s -> %s" % (loc[4:], dest[4:])
|
||||||
label=",".join(verbs).lower()
|
label=",".join(verbs).lower()
|
||||||
|
@ -38,5 +103,3 @@ if __name__ == "__main__":
|
||||||
arc += ' [label="%s"]' % label
|
arc += ' [label="%s"]' % label
|
||||||
print(" " + arc)
|
print(" " + arc)
|
||||||
print("}")
|
print("}")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue