Returns a list of successors (both in the grid and free spaces)
(self, parent: Node)
| 130 | return [self.start.pos] |
| 131 | |
| 132 | def get_successors(self, parent: Node) -> list[Node]: |
| 133 | """ |
| 134 | Returns a list of successors (both in the grid and free spaces) |
| 135 | """ |
| 136 | successors = [] |
| 137 | for action in delta: |
| 138 | pos_x = parent.pos_x + action[1] |
| 139 | pos_y = parent.pos_y + action[0] |
| 140 | if not (0 <= pos_x <= len(grid[0]) - 1 and 0 <= pos_y <= len(grid) - 1): |
| 141 | continue |
| 142 | |
| 143 | if grid[pos_y][pos_x] != 0: |
| 144 | continue |
| 145 | |
| 146 | successors.append( |
| 147 | Node( |
| 148 | pos_x, |
| 149 | pos_y, |
| 150 | self.target.pos_y, |
| 151 | self.target.pos_x, |
| 152 | parent.g_cost + 1, |
| 153 | parent, |
| 154 | ) |
| 155 | ) |
| 156 | return successors |
| 157 | |
| 158 | def retrace_path(self, node: Node | None) -> list[TPosition]: |
| 159 | """ |