I know the question is not very precise, and that is because I have no idea what is going on either. I have narrowed down the problem to a couple of lines, but to me the execution seems rather weird.
def loadmaze(backup):
test = createmaze(10,10) #This creates a new 10x10 matrix
maze = placewalls(test, "x") #The X is a string with wall positions
if maze != test:
#when placewalls executed correctly, and returned a maze different from the original
showmaze(maze) #simply printing maze to console
else:
return backup #so nothing changes, looks as if function never happened
return maze,10,10
# this returns the new maze, with walls, and the dimensions of the new maze
def placewalls(amaze,positions):
#placing walls, definitely correct
return amaze-with-walls
Obviously I changed the variable names so it's clear what I'm doing.
The problem is, when I call the function loadmaze(maze), it never returns a maze with walls. Somehow the test and maze values are always identical. I do not understand how this can be as the maze with walls is assigned to maze after test, which at that point does not have walls.
According to the debug, test also contains the walls after the third line has been executed.
Please help, I'm terribly confused.
placewallscode. Clearly "somethinggoeswrong" is true so that it returns its first argument.mazeandtestmight be the same object, but now just with walls. See for example in the Python FAQ.# placing wallssubroutine modifies the object which the first parameter refers to. Please share the full code of theplacewallsfunction.testbe the same asmazewhenmazegets another value (with walls) aftertesthas been assigned an empty maze?