I’m trying to create a randomized maze in C++, but I can’t start because I don’t know how to create grids or cells. How could I create it? And I also want to create it using ASCII characters. how can i store it in array? (can any one give a sample code and some explanation so i can understand it better)
Another question: What data stuctures should I need to learn and use? I’m planning to use Eller’s algorithm or Kruskal’s algorithm.
Thank you guys for helping me! im a begginer programmer, and i want to learn about this, because this is a part of my project, thank you vary much!
You probably want to store your maze in a 2-dimension char array. You can declare an array with or without initializing it in C++.
You could change the initial values to
'|'and'-'for walls in your maze, and use a space character,' ', for the passageways. Either initialization method works, but you always use the elements the same way. Here’s how you clear the board in the initialized array above.If you want to read the value of an element (useful when you’re trying to navigate a maze), you use the same subscript notation as when you’re setting its value.