In Prolog this should be particularly easy. Just define a predicate that’s true if two fields are a distance n from each other, by using induction (they are a distance 1 if adjacent, and distance n if adjacent to a field of distance n-1). Then you should be easily able to write the expression that finds all fields of distance n from your starting point.

Hi!

I read about pathfinding. But in most algorithm solutions the start and target coordinates are known.

I’m making a board game. To offer the user all possible moves I need an algorithm the other way round.

Given is start coordinates and the number on the dice. Now I want my program to give me all possible moves for all my figures.

Best would be if the moves could be stored in a list.

I so far have the coordinates of the board fields and the function to find out if two fields are next to each (neighbours).

I would like to code the algorithm in prolog.

Thanks for your help. (and sorry for my bad English)

Moltar