Path hilighting algorithm.
Closed this issue · 1 comments
JohnMarsh commented
For when a player wants to move a piece we need to find all the available hexagons that that piece may move to.
For this to work well I think every hex tile object should have a pointer to all their neighbors. Then we can try to move through them recursively while decrementing the move counter. The function may look something like this.
findPaths(Tile currentTile, int moves){
if(!canTraverse())
return;
if(moves == 0){
this.hilightTile();
} else{
(for Tile t : this.neighbours)
(findPaths(t, moves--);
}
}
JohnMarsh commented
I forgot to check if a tile is already hilighted. That's important so that it doesn't infinitely recurse.