heli_link_dis(h1,b1,800).
heli_link_dis(h1,b3,1400).
heli_link_dis(h1,b2,600).
heli_link_dis(h1,b8,1200). 开发者_StackOverflow社区
heli_link_dis(h2,b4,400).
heli_link_dis(h2,b3,2000).
heli_link_dis(h2,b5,500).
heli_link_dis(h3,b5,1000).
heli_link_dis(h3,b6,400).
heli_link_dis = helicopter linked distance
h1 mean the name of a helicopter
b1 means the name of a base station
800 is the distance between helicopter and the base station
I need the prolog code to trace the closest helicopter to a given base station
An extremely inefficient, yet minimalist, solution is:
nearest_heli(H, B, D) :-
heli_link_dis(H, B, D),
\+ (heli_link_dis(_, _, D1), D1 < D).
加载中,请稍侯......
精彩评论