Instead of checking for stream failure (in
Dungeon::select_room_to_move) usingfail, usestd::cin'soperator bool:if (!std::cin) /fail/;`.if (game_over == true)can be simplified toif (game_over).The introduction text is not up-to-date. There are three pits and super bats, not two. Might want to use the actual variables instead of hardcoding text.
It's my understanding that neighbors cannot ever be
nullptr, so the extra if statement for it is unnecessary (wumpus.cpp:226). Might want to consider using anassertinstead.It seems like you are using
player_rooma lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.Dungeon::shoot_arrowhas a bug. If I want to shoot an arrow into3-5-9, then I only lose one arrow. I don't think that this intended. Also, if I shoot my last arrow into a non-existent room, then I can illegally continue ;).Dungeon::move_playerhas a bug, it moves the player into the wrong room. That's becauseroomsis not sorted, sorooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)
Instead of checking for stream failure (in
Dungeon::select_room_to_move) usingfail, usestd::cin'soperator bool:if (!std::cin) /fail/;`.if (game_over == true)can be simplified toif (game_over).The introduction text is not up-to-date. There are three pits and super bats, not two. Might want to use the actual variables instead of hardcoding text.
It's my understanding that neighbors cannot ever be
nullptr, so the extra if statement for it is unnecessary (wumpus.cpp:226). Might want to consider using anassertinstead.It seems like you are using
player_rooma lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.Dungeon::shoot_arrowhas a bug. If I want to shoot an arrow into3-5-9, then I only lose one arrow. I don't think that this intended. Also, if I shoot my last arrow into a non-existent room, then I can illegally continue ;).Dungeon::move_playerhas a bug, it moves the player into the wrong room. That's becauseroomsis not sorted, sorooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)
Instead of checking for stream failure (in
Dungeon::select_room_to_move) usingfail, usestd::cin'soperator bool:if (!std::cin) /fail/;`.if (game_over == true)can be simplified toif (game_over).The introduction text is not up-to-date. There are three pits and super bats, not two. Might want to use the actual variables instead of hardcoding text.
It's my understanding that neighbors cannot ever be
nullptr, so the extra if statement for it is unnecessary (wumpus.cpp:226). Might want to consider using anassertinstead.It seems like you are using
player_rooma lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.Dungeon::shoot_arrowhas a bug. If I shoot my last arrow into a non-existent room, then I can illegally continue ;)Dungeon::move_playerhas a bug, it moves the player into the wrong room. That's becauseroomsis not sorted, sorooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)
Instead of checking for stream failure (in
Dungeon::select_room_to_move) usingfail, usestd::cin'soperator bool:if (!std::cin) /fail/;`.(I'm not sure about this point). Isn't
distributioninget_randomnot supposed to bestatictoo?if (game_over == true)can be simplified toif (game_over).The introduction text is not up-to-date. There are three pits and super bats, not two. Might want to use the actual variables instead of hardcoding text.
It's my understanding that neighbors cannot ever be
nullptr, so the extra if statement for it is unnecessary (wumpus.cpp:226). Might want to consider using anassertinstead.It seems like you are using
player_rooma lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.Dungeon::shoot_arrowhas a bug. If I want to shoot an arrow into3-5-9, then I only lose one arrow. I don't think that this intended. Also, if I shoot my last arrow into a non-existent room, then I can illegally continue ;).Dungeon::move_playerhas a bug, it moves the player into the wrong room. That's becauseroomsis not sorted, sorooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)
Instead of checking for stream failure (in
Dungeon::select_room_to_move) usingfail, usestd::cin'soperator bool:if (!std::cin) /fail/;`.(I'm not sure about this point). Isn't
distributioninget_randomnot supposed to bestatictoo?if (game_over == true)can be simplified toif (game_over).The introduction text is not up-to-date. There are three pits and super bats, not two. Might want to use the actual variables instead of hardcoding text.
It's my understanding that neighbors cannot ever be
nullptr, so the extra if statement for it is unnecessary (wumpus.cpp:226). Might want to consider using anassertinstead.It seems like you are using
player_rooma lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.Dungeon::shoot_arrowhas a bug. If I want to shoot an arrow into3-5-9, then I only lose one arrow. I don't think that this intended. Also, if I shoot my last arrow into a non-existent room, then I can illegally continue ;).Dungeon::move_playerhas a bug, it moves the player into the wrong room. That's becauseroomsis not sorted, sorooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)
Instead of checking for stream failure (in
Dungeon::select_room_to_move) usingfail, usestd::cin'soperator bool:if (!std::cin) /fail/;`.if (game_over == true)can be simplified toif (game_over).The introduction text is not up-to-date. There are three pits and super bats, not two. Might want to use the actual variables instead of hardcoding text.
It's my understanding that neighbors cannot ever be
nullptr, so the extra if statement for it is unnecessary (wumpus.cpp:226). Might want to consider using anassertinstead.It seems like you are using
player_rooma lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.Dungeon::shoot_arrowhas a bug. If I want to shoot an arrow into3-5-9, then I only lose one arrow. I don't think that this intended. Also, if I shoot my last arrow into a non-existent room, then I can illegally continue ;).Dungeon::move_playerhas a bug, it moves the player into the wrong room. That's becauseroomsis not sorted, sorooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)
Instead of checking for stream failure (in
Dungeon::select_room_to_move) usingfail, usestd::cin'soperator bool:if (!std::cin) /fail/;`.(I'm not sure about this point). Isn't
distributioninget_randomnot supposed to bestatictoo?if (game_over == true)can be simplified toif (game_over).The introduction text is not up-to-date. There are three pits and super bats, not two. Might want to use the actual variables instead of hardcoding text.
It's my understanding that neighbors cannot ever be
nullptr, so the extra if statement for it is unnecessary (wumpus.cpp:226). Might want to consider using anassertinstead.Instead of having aIt seems like you are using
has_wumpusplayer_room, a lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.has_pitDungeon::shoot_arrow, has a bug. If I want to shoot an arrow intohas_whatever3-5-9, then I only lose one arrow. I don't think that this intended. Also, if I shoot my last arrow into a non-existent room, then I can illegally continue ;).Dungeon::move_playerhas a bug, it's better to use oneit moves the player into the wrong room. That's becauseenumroomsandis not sorted, sohas_pitrooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)enum class RoomInhabitant { Nobody, Player, Wumpus, Bat };
Then you can also use a switch instead of an if cascade if you'd like. This has also an additional advantage is that you cannot break invariants easily: In your posted code, you can have a room with has_pit == has_bat == true, which is not supposed to be possible. With an enum you do not have this problem.
It seems like you are using
player_rooma lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.Dungeon::shoot_arrowhas a bug. If I want to shoot an arrow into3-5-9, then I only lose one arrow. I don't think that this intended. Also, if I shoot my last arrow into a non-existent room, then I can illegally continue ;).Dungeon::move_playerhas a bug, it moves the player into the wrong room. That's becauseroomsis not sorted, sorooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)
Instead of checking for stream failure (in
Dungeon::select_room_to_move) usingfail, usestd::cin'soperator bool:if (!std::cin) /fail/;`.(I'm not sure about this point). Isn't
distributioninget_randomnot supposed to bestatictoo?if (game_over == true)can be simplified toif (game_over).The introduction text is not up-to-date. There are three pits and super bats, not two. Might want to use the actual variables instead of hardcoding text.
It's my understanding that neighbors cannot ever be
nullptr, so the extra if statement for it is unnecessary (wumpus.cpp:226). Might want to consider using anassertinstead.Instead of having a
has_wumpus,has_pit,has_whatever, ..., it's better to use oneenumandhas_pit:enum class RoomInhabitant { Nobody, Player, Wumpus, Bat };
Then you can also use a switch instead of an if cascade if you'd like. This has also an additional advantage is that you cannot break invariants easily: In your posted code, you can have a room with has_pit == has_bat == true, which is not supposed to be possible. With an enum you do not have this problem.
It seems like you are using
player_rooma lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.Dungeon::shoot_arrowhas a bug. If I want to shoot an arrow into3-5-9, then I only lose one arrow. I don't think that this intended. Also, if I shoot my last arrow into a non-existent room, then I can illegally continue ;).Dungeon::move_playerhas a bug, it moves the player into the wrong room. That's becauseroomsis not sorted, sorooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)
Instead of checking for stream failure (in
Dungeon::select_room_to_move) usingfail, usestd::cin'soperator bool:if (!std::cin) /fail/;`.(I'm not sure about this point). Isn't
distributioninget_randomnot supposed to bestatictoo?if (game_over == true)can be simplified toif (game_over).The introduction text is not up-to-date. There are three pits and super bats, not two. Might want to use the actual variables instead of hardcoding text.
It's my understanding that neighbors cannot ever be
nullptr, so the extra if statement for it is unnecessary (wumpus.cpp:226). Might want to consider using anassertinstead.It seems like you are using
player_rooma lot. You might want to consider using a member variable for that so that you avoid to iterate over (potentially) the whole room container.Dungeon::shoot_arrowhas a bug. If I want to shoot an arrow into3-5-9, then I only lose one arrow. I don't think that this intended. Also, if I shoot my last arrow into a non-existent room, then I can illegally continue ;).Dungeon::move_playerhas a bug, it moves the player into the wrong room. That's becauseroomsis not sorted, sorooms[target_room_number]doesn't get you the room withroom_number == target_room_number. Usestd::findagain :)