Hi guys, I'm currently working on the prim algorithm and got a problem. Heres my code: http://pastebin.com/a7AJkjEr So atm I'm filling a list of walls and instantiate some testobject and if my wall has it's boolean wallInMaze = false; the method should instantiate just a ground object. But currently when I call the function createMaze() all booleans are true even though I change one of them with pickRandomWall() to false. I dont know why it does this. Can somebody help me pls? greetings
Posting the code here is generally better. One cheap way to debug this stuff is to turn your bool into a property and add in some Debug.Log statements so you can see every time it changes.
i didnt look at everything, but I see this Code (CSharp): public void setIsNoWallInMaze() //Makes the wall invisible in the maze { wallInMaze = !wallInMaze; } doing !wallInMaze does not mean that wallInMaze = false. Instead what it does is it takes what ever wallInMaze is, lets say it is false, and it makes it the opposite, which is true. And then the next time you call it, since its now true, !true is false... and then !false is true, etc... Try doing wallInMaze = false; and see if it gets rid of your bug. I am also not sure as to how you are debugging to see all the walls bool state, but I see here Code (CSharp): if(wallList[tmpCounter].isWallInMaze()) // Does stuff when the wall is visible in the Maze; { wallList[tmpCounter].showState(); ............... So if that is how you are debugging, then of course you will see all is true, because any that is false will not reach the debug code.