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
Diego Salas Polar
21,431 PointsI need help printing the 'X' in my dungeon game. Here is the link to fixing my code: https://w.trhou.se/8skmpqqfbf.
I would like to know what I am doing wrong.
MODERATOR EDIT added Workspace snapshot to question body, so it will be a clickable link
1 Answer
Chris Freeman
Treehouse Moderator 68,468 PointsRunning your code produces an "X", but there is a bug in get_moves. I was surprised by the output:
You're currently in room (2, 1)
_ _ _
|_|_|_|
|_|_|_|
|_|X|_|
You can move ['LEFT', 'RIGHT', 'UP', 'DOWN']
I clearly can not move DOWN from here. Also, when the player is in the TOP row (0), "DOWN" is removed. See corrected code below:
def get_moves(player):
moves = ['LEFT', 'RIGHT', 'UP', 'DOWN']
#player = (x, y)
if player[1]==0:
moves.remove('LEFT')
if player[1] == 2:
moves.remove('RIGHT')
if player[0] ==0:
moves.remove('UP')
if player[0] == 2: # <-- changed criteria to "2"
moves.remove('DOWN')
Also, as coded, the coordinates relate more to "(row, column)" than to "(x, y)".