/// Method recursive that execute the A* algorithm
Tile? _getTileWinner(Tile current, Tile end) {
if (end == current) return current;
_waitList.remove(current);
for (final element in current.neighbors) {
if (element.parent == null) {
_analiseDistance(element, end, parent: current);
}
}
_doneList.add(current);
for (var n in current.neighbors) {
if (!_doneList.contains(n)) {
_waitList.add(n);
}
}
_waitList.sort((a, b) => a.f.compareTo(b.f));
for (final element in _waitList) {
if (!_doneList.contains(element)) {
final result = _getTileWinner(element, end);
if (result != null) {
return result;
}
}
}
return null;
}
this search check _doneList but it is growing
if search large (check all done tiles have heavy cost)
this search check _doneList but it is growing if search large (check all done tiles have heavy cost)