Jump to content

Featured Replies

Posted

Objective

Implement a pathfinding algorithm (e.g., Dijkstra’s or A*) to find the shortest path between two points on a grid.


Requirements

  1. Grid Representation:

    • Create a 2D grid where each cell represents walkable terrain or an obstacle.
  2. Algorithm:

    • Implement a pathfinding algorithm like Dijkstra’s or A*.
    • The algorithm should find the shortest path between a start and an end point, avoiding obstacles.
  3. Visualization:

    • Print the grid showing the path taken. For example:
      • S for start
      • E for end
      • X for obstacles
      • * for the shortest path
  4. Input:

    • Allow the user to define the grid size, starting and ending points, and obstacle placement.
  5. Error Handling:

    • Validate inputs (e.g., ensure the start and end points are not obstacles).
  6. Stretch Goals:

    • Add support for weighted cells (e.g., some cells take more "time" to cross).
    • Create a graphical visualization if you're using a framework like Pygame or JavaScript with Canvas.

Example

Input:

Grid Size: 5x5
Start Point: (0, 0)
End Point: (4, 4)
Obstacles: (2, 2), (3, 2)

Output:

S * * * *
  X X * *
  X X * E

Submission Instructions

  • Share your code and an example of how it works.
  • For graphical solutions, provide a screenshot or link.

CodeName: Jessica

💻 Linux Enthusiast | 🌍 Adventurer | 🦄 Unicorn 
🌐 My Site | 📢 Join the Forum

spacer.png

 

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

Important Information

Terms of Use Privacy Policy Guidelines We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.