程序代写 % Accomplish a given Task and return the Cost

% Accomplish a given Task and return the Cost
solve_task(Task,Cost) :-
my_agent(A), get_agent_position(A,P),
solve_task_dfs(Task,[P],[P|Path]), !,

Copyright By PowCoder代写 加微信 powcoder

agent_do_moves(A,Path), length(Path,Cost).

% Calculate the path required to achieve a Task
solve_task_dfs(Task,[P|Ps],Path) :-
achieved(Task,P), reverse([P|Ps],Path)
map_adjacent(P,Q,empty), \+ member(Q,Ps),
solve_task_dfs(Task,[Q,P|Ps],Path).

% True if the Task is achieved with the agent at Pos
achieved(Task,Pos) :-
Task=find(Obj), map_adjacent(Pos,_,Obj)
Task=go(Pos).

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com