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 trialfahad lashari
7,693 PointsQuestion 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
Jason Anello
Courses Plus Student 94,610 PointsHi 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.
Steven Parker
231,275 PointsYou 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
7,693 PointsHi, thanks. That makes things clearer. I have another question in the next video. Do you think you could possibly help me out? Thanks!
fahad lashari
7,693 Pointsfahad lashari
7,693 PointsUnderstood. That makes sense
fahad lashari
7,693 Pointsfahad lashari
7,693 PointsThat makes things clearer. I have another question in the next video. Do you think you could possibly help me out? Thanks!
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsI would post a new question to make it easier for others to find it who are having the same problem.
fahad lashari
7,693 Pointsfahad lashari
7,693 PointsThank you ! much appreciated
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsYou can link to it here if you want and I'll try to help if I can.
fahad lashari
7,693 Pointsfahad lashari
7,693 Pointshttps://teamtreehouse.com/community/what-makes-the-map-print-the-way-that-it-does