Hi, I was wondering how to add the counter bit of the instructions described below into my program. Thanks.
Create the maze
Get a pointer to the start.
Make another pointer for a Cell
Make a stack
Push the start on the stack
Draw the maze
Start the two counters (total steps, steps in path)
While the stack is not empty
Get a pointer to the cell on top of the stack (current cell)
If it’s the end, were done
Update counters
Update symbol to X
Break out of loop
Update the current cell’s symbol to O
Draw the maze
Get a pointer to a neighbouring cell
If the neighbour exists
Update counters
Update current cell’s symbol to o
Push the new cell on the stack
If there are no valid neighbours, we backtrack
Update counters
Set symbol to .
Pop the cell off the stack
Make the program sleep a so it prints nicely (I did 250ms)
Print out the counters
Draw the maze one final tie
Delete things
I am not sure what you are counting, but if its number of calls to a function, this will help. If its just in a loop or something else, just count it directly.