Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:00:46+00:00 2026-06-13T08:00:46+00:00

I need my C program to be able to travel around a board. The

  • 0

I need my C program to be able to travel around a board. The board is represented by a 2D int array (where 0 and 7 are empty squares and everything else is an obstacle). The cost to move from one square to another is always the same but it should not move diagonally.

I’ve been looking up A* but it’s confusing and every single example I could find is with C++ or Java so I’m starting to wonder if it’s even possible on C.

That and if it’s the best algorithm to use for it.

Edit: The board is either 24×25 or 25×24 I can’t remember which

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:00:47+00:00Added an answer on June 13, 2026 at 8:00 am

    As your board is small, you can use a breadth-first search (BFS) doing a complete search for the best path. I think that the performance will be comparable if not better than A* algorithm.

    The algorithm is simpler than A* and there are many implementations in C over the internet. Here is an example of a BFS transversal on a grid:

    An illustration of a BFS transversal on a grid. If all squares are reachable, the distances from center are those indicated.

    To get the path you can save a matrix (for example a 2d-array of char — lets name it parent) where parent[x][y] is for example (0 – if you reach that square from left, 1 – right, 2 – up, 3 – down). For example, if you’re visiting the square with coords (4,6) and will put the (5,6) on the queue, you do parent[5][6] = 2 because (5,6) came from the row above (4,6). So to retrieve the full path you can pick the destination node and save the parents coordinates until you reach the source square.

    Now it is up to you think about and figure how you can implement it 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to make a program that looks through a mailbox
I have a program that I need to be able to search a file
I am writing a program where users need to be able to use self
I have colors like FF7B2900 from a program. I need to be able to
I don't really understand windows UAC... I need for my program to be able
I need to be able to install a program in a shared folder on
i need to be able to SFTP though VBA. I have an Access program
I need my C program to be able to read in an identifier using
Basically, I need to make my program able to create multiple (unlimited) variables for
I need a program that checks if the difference between all pairs of elements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.