MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / expand_state

Function expand_state

graphs/multi_heuristic_astar.py:129–169  ·  view source on GitHub ↗
(
    s,
    j,
    visited,
    g_function,
    close_list_anchor,
    close_list_inad,
    open_list,
    back_pointer,
)

Source from the content-addressed store, hash-verified

127
128
129def 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
172def make_common_ground():

Callers 1

multi_a_starFunction · 0.85

Calls 5

validFunction · 0.85
keyFunction · 0.85
remove_elementMethod · 0.80
addMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected