function P = drawBugOnBar(N,H,P,w)
% Draws a bar with N positions and a bug at position (P)
% Displays the time in hops (H) and position (P) of the bug and 
% pauses w seconds.
% Returns the current position of the bug
lo = min([1,P])-0.2;
hi = max([N,P])+0.2;
positions = 1:N;
plot( [0.8 N+0.2 N+0.2 0.8 0.8], [-0.2 -0.2 0.2 0.2 -0.2], 'k', ...
       positions,0,'ko', ...  % all positions
       P, 0, 'b*'        ...  % where the bug is currently
    )
axis( [lo hi -1 3] )
text( 1.5,2.0,['    Hops = ' num2str(H)]);
text( 1.5,1.5,['Position = ' num2str(P)]);
pause(w);