-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
747 additions
and
208 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
*.pyc | ||
graph_adventure/__pycache__/* | ||
graph_adventure/map.txt | ||
__pycache__/* |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from room import Room | ||
from player import Player | ||
from world import World | ||
|
||
import random | ||
from ast import literal_eval | ||
|
||
# Load world | ||
world = World() | ||
|
||
|
||
# You may uncomment the smaller graphs for development and testing purposes. | ||
# map_file = "maps/test_line.txt" | ||
# map_file = "maps/test_cross.txt" | ||
# map_file = "maps/test_loop.txt" | ||
# map_file = "maps/test_loop_fork.txt" | ||
map_file = "maps/main_maze.txt" | ||
|
||
# Loads the map into a dictionary | ||
room_graph=literal_eval(open(map_file, "r").read()) | ||
world.load_graph(room_graph) | ||
|
||
# Print an ASCII map | ||
world.print_rooms() | ||
|
||
player = Player(world.starting_room) | ||
|
||
# Fill this out with directions to walk | ||
# traversal_path = ['n', 'n'] | ||
traversal_path = [] | ||
|
||
|
||
|
||
# TRAVERSAL TEST | ||
visited_rooms = set() | ||
player.current_room = world.starting_room | ||
visited_rooms.add(player.current_room) | ||
|
||
for move in traversal_path: | ||
player.travel(move) | ||
visited_rooms.add(player.current_room) | ||
|
||
if len(visited_rooms) == len(room_graph): | ||
print(f"TESTS PASSED: {len(traversal_path)} moves, {len(visited_rooms)} rooms visited") | ||
else: | ||
print("TESTS FAILED: INCOMPLETE TRAVERSAL") | ||
print(f"{len(room_graph) - len(visited_rooms)} unvisited rooms") | ||
|
||
|
||
|
||
####### | ||
# UNCOMMENT TO WALK AROUND | ||
####### | ||
player.current_room.print_room_description(player) | ||
while True: | ||
cmds = input("-> ").lower().split(" ") | ||
if cmds[0] in ["n", "s", "e", "w"]: | ||
player.travel(cmds[0], True) | ||
elif cmds[0] == "q": | ||
break | ||
else: | ||
print("I did not understand that command.") |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.