Last active
July 30, 2018 23:44
-
-
Save vilmibm/349a3d6ee0beb269c2bc23fe0a86f210 to your computer and use it in GitHub Desktop.
lol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ | |
│ │ | |
│ south │ | |
│ ┌───────────────────────┐ │ | |
│ ∨ │ │ | |
│ ┌────────────┐ north ┌────────────────┐ north ┌───────────┐ │ | |
└────── │ Kitchen │ ───────> │ Rear Lawn │ ───────> │ Forest │ │ | |
└────────────┘ └────────────────┘ └───────────┘ │ | |
east below east ∧ ∧ south │ below │ | |
┌───────────────────────────┐ ┌─────────────────────────────────────┐ ┌───────────────────────────────────┐ │ north └───────────────────────────┘ ┌──────────────────────┐ │ | |
∨ │ ∨ │ ∨ │ │ ∨ │ │ | |
┌────────────────┐ west ┌─────────────────────────────────────────────┐ below ┌─────────────────┐ west ┌────────┐ west ┌──────────────────────────┐ above ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ west ┌─────────────────────────┐ west ┌───────────────┐ west ┌───────────────────────────────────────────────────────────────┐ above ┌───────────┐ above ┌───────────────┐ above ┌───────────┐ │ | |
│ East Graveyard │ ──────> │ │ ───────> │ Graveyard Cave │ ──────> │ Tunnel │ ──────> │ Abandoned House Basement │ ───────> │ │ ───────> │ East Lawn │ ──────> │ │ ───────> │ │ ───────> │ Airy Loft │ ───────> │ Attic │ ───────> │ Tree Limb │ │ | |
└────────────────┘ │ │ └─────────────────┘ └────────┘ └──────────────────────────┘ │ │ └─────────────────────────┘ │ │ │ │ └───────────┘ └───────────────┘ └───────────┘ │ | |
∧ east │ │ above │ ∧ east │ │ │ east │ │ │ east │ │ below │ ∧ below │ │ | |
└─────────────────────── │ │ <──────────┘ └──────────────────┘ │ │ <──────────┘ │ Living Room │ <─────── │ │ <──────────┘ └──────────────────────────┘ │ | |
│ │ │ │ │ │ │ │ │ | |
│ │ south │ │ west │ │ │ │ south │ | |
│ Graveyard │ <──────────┐ │ Abandoned House Foyer │ <──────────┐ │ │ <┐ │ Foyer │ <─────────────────────────────────────────────────────────────────────────┘ | |
│ │ │ │ │ │ └───────────────┘ │ │ │ | |
│ │ north ┌─────────────────┐ │ │ east ┌─────────────────────────┐ │ │ │ │ below ┌───────────┐ west ┌───────────────┐ | |
│ │ ───────> │ North Graveyard │ │ │ ───────> │ Abandoned House Kitchen │ │ north │ south │ │ ───────> │ │ ───────> │ Computer Room │ | |
│ │ └─────────────────┘ │ │ └─────────────────────────┘ ∨ │ │ │ │ │ └───────────────┘ | |
│ │ │ │ ┌───────────────┐ │ │ │ above │ │ east │ | |
│ │ <┐ │ │ <┐ │ Dining Room │ ─┘ │ │ <─────── │ Basement │ <──────────┘ | |
└─────────────────────────────────────────────┘ │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │ └───────────────┘ └───────────────────────────────────────────────────────────────┘ │ │ | |
│ ∧ │ │ │ ∧ │ ∧ │ │ │ ∧ │ ∧ │ │ | |
│ south │ north │ west │ east │ north │ south │ above │ north │ south │ below │ south │ north │ west │ east │ │ <┐ | |
∨ │ ∨ │ ∨ │ ∨ │ ∨ │ ∨ │ ∨ │ └───────────┘ │ | |
┌─────────────────┐ │ ┌────────────────┐ │ ┌─────────────────────────────┐ │ ┌────────────────────────────────┐ │ ┌───────────────────────────────┐ │ ┌───────────────┐ ┌────────────┐ │ ┌───────────────────────────────────────┐ │ │ ┌───────────────┐ | |
│ South Graveyard │ ─┘ │ West Graveyard │ ─┘ │ Abandoned House Living Room │ ─┘ │ Abandoned House Master Bedroom │ └────── │ Abandoned House Small Bedroom │ │ │ Small Bedroom │ │ Front Lawn │ ─┘ │ │ │ east │ west │ Bathroom │ ─┐ | |
└─────────────────┘ └────────────────┘ └─────────────────────────────┘ └────────────────────────────────┘ └───────────────────────────────┘ │ └───────────────┘ └────────────┘ │ │ ∨ │ └───────────────┘ │ | |
│ │ ∧ south │ │ ┌───────────┐ │ ∧ │ | |
└────────────────────────────────────────────────────────────────────────────┘ └─────────────────────────────────────────────── │ Hallway │ │ Rec Room │ ─┘ │ north │ | |
│ │ └───────────┘ │ │ | |
│ │ │ │ | |
┌─────> │ │ ──────────────────────────────────┘ │ | |
│ └───────────────────────────────────────┘ │ | |
│ │ ∧ south │ | |
│ east │ west └──────────────────────────────────────────────────────────────┘ | |
│ ∨ | |
│ ┌────────────────┐ west ┌───────────┐ | |
└────── │ Master Bedroom │ ───────> │ West Lawn │ | |
└────────────────┘ └───────────┘ | |
∧ east │ | |
└───────────────────────────┘ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mapfile_for_room(room): | |
return [ | |
'[ {from_room} ] -- {direction} --> [ {to_room} ]'.format( | |
from_room=room.name, | |
direction=d, | |
to_room=r.name) | |
for d,r in adjacent(room)] | |
def adjacent(room): | |
out = [] | |
for d in DIRECTIONS: | |
e = GameWorld.resolve_exit(room, d) | |
if e is None: continue | |
route = e.get_data('exit').get(room.shortname) | |
target_room = GameObject.get_or_none(GameObject.shortname==route[1]) | |
out.append((d,target_room)) | |
return out | |
def build_queue(queue, room): | |
if queue[room.shortname] == 0: | |
return | |
else: | |
for d,r in adjacent(room): | |
if r.shortname in queue: continue | |
queue[r.shortname] = queue[room.shortname] - 1 | |
build_queue(queue, r) | |
def from_room(room, distance=3): | |
if distance < 0: | |
raise ValueError('distance must be greater than 0') | |
queue = {room.shortname: distance} | |
build_queue(queue, room) | |
to_map = set([GameObject.get(GameObject.shortname==k) for k in queue.keys()]) | |
mapfile = [] | |
for room in to_map: | |
mapfile.extend(mapfile_for_room(room)) | |
return '\n'.join(mapfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment