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 trialSergei Miroshnikov
3,313 PointsWhy we are skipping the case when player is located at corner e.g (0,0), in that case we have only 2 directions to move
CELLS = [(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)]
so if player is at(0,0) he can move only 'DOWN' and 'RIGHT' . Why Kenneth omitted that in his lecture ?
2 Answers
Nathan Tallack
22,160 PointsThe get_moves function is using separate if statements for each direction. Consider the function code below:
def get_moves(player):
moves = ['(L)eft', '(R)ight', '(U)p', '(D)own']
if player[1] == 0:
moves.remove('(L)eft')
if player[1] == 2:
moves.remove('(R)ight')
if player[0] == 0:
moves.remove('(U)p')
if player[0] == 2:
moves.remove('(D)own')
return moves
If the player is at 0,0 then the first and the third condition would be true removing left and up from the moves variable.
So this would satisfy the condition that you are mentioning in your question.
Does that make sense?
Sergei Miroshnikov
3,313 Pointsyeah , thanks