Skip to content

Commit 85af0fc

Browse files
committed
Remove stupid idea
1 parent 3904da0 commit 85af0fc

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

lib/move_your_cedric/models/player.ex

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ defmodule MoveYourCedric.Models.Player do
9090
%{state.path | final_path: build_final_path(
9191
closed_list,
9292
state.position,
93-
state.target,
9493
closed_list |> List.last(),
9594
[])}
9695

@@ -143,7 +142,6 @@ defmodule MoveYourCedric.Models.Player do
143142
%{state.path | final_path: build_final_path(
144143
closed_list,
145144
state.position,
146-
state.target,
147145
closed_list |> List.last(),
148146
[])}
149147

@@ -258,29 +256,19 @@ defmodule MoveYourCedric.Models.Player do
258256
%{state.path | open_list: open_list ++ to_add}
259257
end
260258

261-
defp build_final_path(_closed_list, [ox, oy], _target, %{parent: [ox, oy]} = _current, final_path) do
259+
defp build_final_path(_closed_list, [ox, oy], %{parent: [ox, oy]} = _current, final_path) do
262260
Logger.debug("[PLAYER] Finished!")
263261
final_path
264262
end
265263

266-
defp build_final_path(closed_list, origin, target, current, path) do
264+
defp build_final_path(closed_list, origin, current, path) do
267265
Logger.debug("[PLAYER] Building: #{inspect current}")
268266

269-
# Dummy node target, to have a full path.
270-
node_target =
271-
%Astar.Node{
272-
position: target,
273-
f: nil,
274-
g: Astar.cost_to_enter(current.position, target),
275-
h: 0,
276-
parent: nil
277-
}
278-
279267
parent =
280268
closed_list
281269
|> Enum.filter(fn node -> node.position == current.parent end)
282270
|> List.first()
283271

284-
[parent] ++ build_final_path(closed_list, origin, target, parent, path ++ [current, node_target])
272+
[parent] ++ build_final_path(closed_list, origin, parent, path ++ [current])
285273
end
286274
end

0 commit comments

Comments
 (0)