The game is a maze, the code is not
Usage
-
The README contained everything I needed to easily use the program:
-
The program compiles/runs without errors:
Had to fix
Makefile
before it worked. Also, don't include generated files (*.o
andproject
) in the repository. -
The program worked as advertised:
Style
-
The code is cleaning divided into modules and multiple files:
the
Room.h
andCave.h
contain both definitions and implementations. Splitting the implementation into.cpp
files would probably be cleaner and is typically what one would expect. -
Variable and function names are meaningful:
-
Comments are used where appropriate:
Code is easy enough to read, but docstring style comments would be useful to generate API documentation.
Philosophy
-
The program most closely follows the
ed-like
interface pattern:Since the program implements a command interpreter it would make sense to read commands from standard input if it contained anything, else default to the interactive prompt.
-
This choice of pattern is a good one for this application:
-
This program follows the Rule of Silence and Least Surprise:
There doesn't seem to be a quit command
-
This program follows the Rules of Modularity and Composition:
-
This program follows the Rules of Representation and Simplicity:
The
switchCommand(string)
function might be replaced with astd::map<string, command>
data structure instead to reduce complexity. It is good that the room data is stored in a text file, but there is still quite a bit of literal string checks for directions, I think in most cases there is room for simplification by making use of the structure of the data. There are also several if/else blocks that might be better replaced with a search over a data structure.
Bugs
If I close standard input by pressing ctrl+d
during the gameā¦ I win! But that's probably not what should happen!