Skip to content
Snippets Groups Projects
Commit d7df0c0e authored by Jake Feddersen's avatar Jake Feddersen
Browse files

Wrapping up assignment 1.03

parent 6968723c
No related branches found
No related tags found
No related merge requests found
File added
......@@ -20,3 +20,8 @@
Implement distance printing function
2/15: Re-implement Dijkstra based on Dr. Sheaffer's heap and example code
Add player character and unreachable locations to distance map printing
2/18: Fix the issue where distances would be added to INT_MAX, causing
overflow
Print the distance maps and unreachable areas as they are displayed
in the sample output file
generate_dungeon.c: generates a dungeon map or loads one from file, and
optionally saves it to the file
optionally saves it to the file. Also generates and prints distance
maps, one for tunneling and one for non-tunneling monsters.
Compile: `make`
Run: `./generate_dungeon [--load --save]`
Generates a random dungeon and displays it as specified in assignment 1.01.
If --load is specified, the dungeon is loaded from disk instead. If --save
is specified, the dungeon is then written to the disk. Both --load and --save
can be specified simulaneously, in which case the dungeon will be loaded and
then saved back to the disk.
Generates, loads, or saves a random dungeon as specified in assignment 1.02.
Also generates distance maps to the player. For the non-tunneling monster
distance map, any open spaces (corridors and hallways) from which it is
impossible to reach the player are rendered as 'X'. For the tunneling monster
distance map, the border cells (immutable) are rendered as 'X'.
The dungeon, including player position, is all contained in a single struct.
I slightly modified my logic to work on the data format of the file.
This makes interchanging random generation, load, and save relatively
straightforward, and simplifies many of the functions because now only
a single parameter, a reference to the dungeon struct, is being passed.
I briefly played with implementing my own heap data structure, but I decided
to use Dr. Sheaffer's heap because it uses generics and is already tested.
I implemented Dijkstra's algorithm also based on Dr. Sheaffer's implementation
from past assignments.
File added
......@@ -17,7 +17,7 @@ for i in range(1, len(data)):
tunneling = data[i].split('\n')[44:65]
run_sync('cp ' + filename + ' ' + os.environ['HOME'] + '/.rlg327/dungeon')
result = run_sync('../feddersen_jacob.assignment-1.03/generate_dungeon --load')
result = run_sync('../tmp/feddersen_jacob.assignment-1.03/generate_dungeon --load')
map_result = result.split('\n')[0:21]
for j in range(len(map_result)):
......@@ -53,4 +53,4 @@ for i in range(1, len(data)):
print('Actual:')
print(tunneling_result)
print('--------------------------------------')
\ No newline at end of file
print('--------------------------------------')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment