:-object wasp3 : [bcilib]. var url = './soccer/soccer1b.wrl'. var timelimit = 300. main :- text_area(Browser), set_output(Browser), format('Load the game ...~n'), loadURL(url), format('the game will start in 5 seconds,~n'), format('note that the total playing time period is ~w seconds,~n', [timelimit]), delay(5000), format('the game startup,~n'), play_ball(me, ball). play_ball(Agent, Ball) :- -- timelimit, timelimit > 0, !, format('time left: ~w seconds~n', [timelimit]), delay(800), near_ball_then_kick(Agent, Ball), play_ball(Agent, Ball). play_ball(_, _). near_ball_then_kick(Agent, Ball):- getViewpointPositionEx(Agent,X,_Y,Z), getPosition(Ball,X1,Y1,Z1), Xdif is X1-X, Zdif is Z1-Z, Dist is sqrt(Xdif*Xdif + Zdif*Zdif), Dist < 5, !, X2 is Xdif*3, Z2 is Zdif*3, X3 is X2 + X1, Z3 is Z2 + Z1, setPosition(Ball,X3,Y1,Z3). near_ball_then_kick(_, _). getViewpointPositionEx(_,X,Y,Z) :- getSFVec3f(proxSensor,position,X,Y,Z). getViewpointOrientationEx(_,X,Y,Z,R):- getSFRotation(proxSensor,orientation,X,Y,Z,R). :-end_object wasp3.