Python: Why isn't this working? -


i making game , board 2d array, have procedure print maze , each time prints it should show 'x' player standing. problem keeps 'x' player standing:

-1 x -1 -1  -1 2 3 -1  -1 -1 4 5  -1 6 7 -1    9 8 -1    b -1 -1 -1    c d -1 -1  -1 e f -1    1 -1 h g  2 x -1 -1  -1 x 3 -1  -1 -1 4 5  -1 6 7 -1  9 8 -1  b -1 -1 -1  c d -1 -1  -1 e f -1  1 -1 h g  

there 2 'x's when there should 1 don't know why.

def printmaze(maze, x, y):     oldroom = maze[y][x]     u = x - 1     v = y - 1     maze[v][u] = oldroom     maze[y][x] = 'x'     in range(9):         z in range(4):             print str(maze[i][z]).rjust(2),         print '' 

if x , y coordinates of player, first thing set oldroom equal player is. isn't x currently?

instead of shuffling around values in maze array, why not check if current location you're printing player is, , print x instead?

def printmaze(maze, x, y):     in range(9):         z in range(4):             if == x , z == y:                 print 'x',             else:                 print maze[i][z],         print '' 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -