Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

fahad lashari
fahad lashari
7,693 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
7,693 Points

Understood. That makes sense

fahad lashari
fahad lashari
7,693 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
7,693 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
231,275 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
7,693 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!