%% Fiddle the dog walks the shortest distance left or right (if walking left and right cover the same distance, she should walk left) around a square to retrieve her bone. A is the distance from the front left corner of the square at the front that Fiddle starts at. B is the distance from the back left point at the back that the bone is at.
%%direction(0,0,Direction).
%% Direction=left
direction(A, B, Direction) :-
Sum is A + B, Average is Sum / 2, direction(Average, Direction).
direction(Average, left) :-
Average < 0.5.
direction(0.5, left).
direction(Average, right) :-
Average > 0.5.