Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (Retired) Dungeon Game Building the Game: Part 1

fahad lashari
fahad lashari
6,771 Points

Question regarding get_locations()

Hi

I haven't finished watching the video yet however I cant seem to wrap my head around a small part of the code in the get_locations() function.

Kenneth mentioned that all variables; 'monster', 'start' and 'door' equalling the same can be an issue therefore we need to start again. I understand if monster == start or monster == door then we should restart. However, why must we restart if door == start?

Isn't the logic of the game to not get caught by the monster, and if you are caught then it's game over. It is a possibility that you may be caught right away. This could seem unfair and therefore the first two conditions in the if statement eliminate that possibility. The question remains, why do we need to start again if door == start?

kind regards,

Fahad

2 Answers

Hi fahad,

door == start represents winning immediately. It's the opposite of monster == start which represents losing immediately. monster == door means it's impossible to win.

All of these conditions are unfair in some way.

fahad lashari
fahad lashari
6,771 Points

Understood. That makes sense

fahad lashari
fahad lashari
6,771 Points

That makes things clearer. I have another question in the next video. Do you think you could possibly help me out? Thanks!

I would post a new question to make it easier for others to find it who are having the same problem.

fahad lashari
fahad lashari
6,771 Points

Thank you ! much appreciated

You can link to it here if you want and I'll try to help if I can.

Steven Parker
Steven Parker
217,577 Points

:point_right: You need to make sure the player has a chance to move.

If the player's position is at the door, then the player wins. So you make sure that start and door are not the same, since otherwise the game is over before the player gets a turn.

fahad lashari
fahad lashari
6,771 Points

Hi, thanks. That makes things clearer. I have another question in the next video. Do you think you could possibly help me out? Thanks!