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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -