Returns a list of successors (both in the grid and free spaces)
(self, parent: Node)
| 145 | return None |
| 146 | |
| 147 | def get_successors(self, parent: Node) -> list[Node]: |
| 148 | """ |
| 149 | Returns a list of successors (both in the grid and free spaces) |
| 150 | """ |
| 151 | return [ |
| 152 | Node( |
| 153 | pos_x, |
| 154 | pos_y, |
| 155 | self.target.pos_x, |
| 156 | self.target.pos_y, |
| 157 | parent.g_cost + 1, |
| 158 | parent, |
| 159 | ) |
| 160 | for action in delta |
| 161 | if ( |
| 162 | 0 <= (pos_x := parent.pos_x + action[1]) < len(self.grid[0]) |
| 163 | and 0 <= (pos_y := parent.pos_y + action[0]) < len(self.grid) |
| 164 | and self.grid[pos_y][pos_x] == 0 |
| 165 | ) |
| 166 | ] |
| 167 | |
| 168 | def retrace_path(self, node: Node | None) -> Path: |
| 169 | """ |