mirror of
https://github.com/dancojocaru2000/ai-project-idastar.git
synced 2025-04-20 23:03:54 +03:00
Forgot minor things about IDA*
Minor things like avoiding obstacles...
This commit is contained in:
parent
f23c53fc82
commit
6e0bb36132
1 changed files with 13 additions and 0 deletions
13
IDAstar.cs
13
IDAstar.cs
|
@ -179,13 +179,26 @@ namespace IdaStar
|
|||
if (!neighbour.IsInsideBox(_board.Count, _board[0].Count)) {
|
||||
continue;
|
||||
}
|
||||
if (_board[neighbour.Row][neighbour.Column] == CellState.OBSTACLE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_board[neighbour.Row][neighbour.Column] == CellState.EMPTY) {
|
||||
_board[neighbour.Row][neighbour.Column] = CellState.PATH;
|
||||
}
|
||||
AlgorithmStep?.Invoke(this);
|
||||
var neighbourF = search(neighbour, cost + increment, threshold);
|
||||
|
||||
if (neighbourF < min) {
|
||||
min = neighbourF;
|
||||
}
|
||||
if (min == zero) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (_board[neighbour.Row][neighbour.Column] == CellState.PATH) {
|
||||
_board[neighbour.Row][neighbour.Column] = CellState.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
return min;
|
||||
|
|
Loading…
Add table
Reference in a new issue