(
s,
j,
visited,
g_function,
close_list_anchor,
close_list_inad,
open_list,
back_pointer,
)
| 127 | |
| 128 | |
| 129 | def expand_state( |
| 130 | s, |
| 131 | j, |
| 132 | visited, |
| 133 | g_function, |
| 134 | close_list_anchor, |
| 135 | close_list_inad, |
| 136 | open_list, |
| 137 | back_pointer, |
| 138 | ): |
| 139 | for itera in range(n_heuristic): |
| 140 | open_list[itera].remove_element(s) |
| 141 | # print("s", s) |
| 142 | # print("j", j) |
| 143 | (x, y) = s |
| 144 | left = (x - 1, y) |
| 145 | right = (x + 1, y) |
| 146 | up = (x, y + 1) |
| 147 | down = (x, y - 1) |
| 148 | |
| 149 | for neighbours in [left, right, up, down]: |
| 150 | if neighbours not in blocks: |
| 151 | if valid(neighbours) and neighbours not in visited: |
| 152 | # print("neighbour", neighbours) |
| 153 | visited.add(neighbours) |
| 154 | back_pointer[neighbours] = -1 |
| 155 | g_function[neighbours] = float("inf") |
| 156 | |
| 157 | if valid(neighbours) and g_function[neighbours] > g_function[s] + 1: |
| 158 | g_function[neighbours] = g_function[s] + 1 |
| 159 | back_pointer[neighbours] = s |
| 160 | if neighbours not in close_list_anchor: |
| 161 | open_list[0].put(neighbours, key(neighbours, 0, goal, g_function)) |
| 162 | if neighbours not in close_list_inad: |
| 163 | for var in range(1, n_heuristic): |
| 164 | if key(neighbours, var, goal, g_function) <= W2 * key( |
| 165 | neighbours, 0, goal, g_function |
| 166 | ): |
| 167 | open_list[j].put( |
| 168 | neighbours, key(neighbours, var, goal, g_function) |
| 169 | ) |
| 170 | |
| 171 | |
| 172 | def make_common_ground(): |
no test coverage detected