I am studying C++ programing and i have a assignment which create a maze, which is a two dimensional array of size entered by user and the density also entered by user density is percentage of obstacle in the array.

one mouse enter from the bottom of the array from center and it should come out from the top center.

i don't know how to work on it.

our proffesor give us some built in functions like gotoxy(), clrscr(), delay(unsigned int millisec),

If any one could help me out that would be great for me.

if any one know then i can send you the whole program pdf files.

thank you for your time
Edit/Delete Message

Dani AI

Generated

This thread started with a maze assignment from ; as asked, share code when available, and as asked, clarify whether you must generate the maze, solve it, or both. Below is a compact, practical plan that covers generation, solvability, and solving so it can be applied whichever part you need.

Start by separating responsibilities: input/validation, maze generation, pathfinding, and display. For generation, compute the obstacle count from the user density and place obstacles randomly while keeping the entrance and exit cells free. After placement, always check reachability from entrance to exit (run a flood fill/BFS). If unreachable, either regenerate or carve a connecting corridor (remove obstacles along a path found by reverse BFS) instead of looping forever. For solving, use BFS for the shortest path on an unweighted grid; use A* with Manhattan distance if you want faster/search-directed results.

Example workflow (pseudocode):

generateGrid(rows, cols)
placeRandomObstacles(count, avoid = {start, goal})
if not isReachable(start, goal):
    carvePath(start, goal)  // or regenerate up to a limit
path = findPath(start, goal) // BFS or A*
display(grid, path) // animate if needed

Practical tips: use a 2D container (vector<vector<char>>), seed the RNG once, validate density (0-100), handle even-sized grids where “center” is ambiguous, and limit regeneration attempts to avoid hangs. Keep generation and solver code modular so you can test each piece independently.

Recommended Answers

All 2 Replies

Member Avatar for Member #46692

If you can, you should post your pdf.

Are you asking how to create a maze or how to solve a maze?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.