Thread: solve a maze

  1. #1
    Registered User
    Join Date
    Mar 2016
    Posts
    3

    solve a maze

    Hello people!

    How can a solve a maze in C using dfs and stack, I have a .txt file with

    Code:
    5 10
    ##########
    # i m    #
    #####  ###
    #m m # m #
    #s########
    I already read the matrix and store it.
    The instructions are: 'i' is the start point
    'm' are coins that I need count
    '#' are closed way(wall)
    '.' are free path
    and 's' exit.

    I need find a route of 'i' to 's' if I take a wrong way I need return and search a new path when I find 's' I need to print the cordinates route and the coins in the right way.


    Anyone can help me make this task using dfs with stack, I already store the labyrinth, i would like to know how to call dfs function, and how to make it.

    ps. If You don't understand my english, ask me.

    I am Brazilian.
    Thank you.
    Last edited by Salem; 05-22-2016 at 03:46 AM. Reason: Put ascii art in code tags

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,625
    > I need find a route of 'i' to 's' if I take a wrong way I need return and search a new path
    So you need to store something when you reach a point in the maze where there is more than one choice of where to go next.


    Remember, we're here to guide you, not give you answers on a plate.
    If you've already read the maze, then at least show that code.

    Next, try writing some code which moves 'i' at least one space in a valid direction.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2016
    Posts
    3

    it's my code to read and store maze

    Here It's my main.c e file.h
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    Mar 2016
    Posts
    3
    I've attached my c program.

    I am little bite confuse to use dfs in my situation, thank you for you support.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 01-08-2011, 01:10 PM
  2. Solve a maze recursive
    By BENCHMARKMAN in forum C++ Programming
    Replies: 4
    Last Post: 09-19-2006, 11:33 PM
  3. 3D maze
    By MethodMan in forum Game Programming
    Replies: 25
    Last Post: 11-24-2004, 01:29 AM
  4. maze ****
    By datainjector in forum C Programming
    Replies: 2
    Last Post: 10-30-2002, 09:44 PM
  5. Maze game, complete with maze editor and an example maze!
    By Brian in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-20-2002, 03:27 AM

Tags for this Thread