I have a non-language-specific problem which I'm having trouble finding a workable answer for.
I have a 10x10 grid containing integer values from 1-10. Each value represents the cost of travelling across that square, moving north, east, south or west (cost is incurred while stepping off a square rather than onto it).
I need to find a method to navigate the cheapest path from a starting square to an end point.
I was using a recursive javascript function whereby each square could ask an adjacent square what the cost was if the journey went that way; the square asked would then ask its neighbours etc. until the cheapest route was found. However, as might be expected this takes far too long, even if each square was marked as busy so it couldn't be asked again (in order to prevent circular routes which might never end).
I'm sure this must have been done before. Does anyone have a method they feel would work?
Thanks for your help :)