Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. a code for shorten a path in a grid

a code for shorten a path in a grid

Scheduled Pinned Locked Moved C#
questioncsslamp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Siren9
    wrote on last edited by
    #1

    I have an 8x8 grid...On the grid i have a robot standing in the origin point (0,0) Also,i have a little lamp placed at any tile RANDOMLY at the start of puzzle. The robot can only move square by square either horizontally or vertically (no diagonals allowed!) The robot wants to get to the lamp as quickly as possible (means in the least number of moves possible) So how can i shorten the path?

    L B 2 Replies Last reply
    0
    • S Siren9

      I have an 8x8 grid...On the grid i have a robot standing in the origin point (0,0) Also,i have a little lamp placed at any tile RANDOMLY at the start of puzzle. The robot can only move square by square either horizontally or vertically (no diagonals allowed!) The robot wants to get to the lamp as quickly as possible (means in the least number of moves possible) So how can i shorten the path?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try the appropriate[^] forum.

      speaking as ...

      1 Reply Last reply
      0
      • S Siren9

        I have an 8x8 grid...On the grid i have a robot standing in the origin point (0,0) Also,i have a little lamp placed at any tile RANDOMLY at the start of puzzle. The robot can only move square by square either horizontally or vertically (no diagonals allowed!) The robot wants to get to the lamp as quickly as possible (means in the least number of moves possible) So how can i shorten the path?

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        The general answer to any pathfinding question is "have you checked out A*[^]?". So, have you? In the case of a uniform grid with no obstacles you can just go straight for the target, but I'm guessing this is a preliminary to pathfinding with obstacles, and in that case A* is exactly what you'll want.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups