proc(approachDot(Ball), pi(t, ?(now(t)) : pi(pval, pi(nval, pi(tval, pi(vis, pi(xcoord, pi(ycoord, pi(area, pi(dist, limit( queryHeadJoints(pval, nval, tval, t) : queryBall(Ball, vis, xcoord, ycoord, area, t): queryNearDistance(dist, t) ): if( lookingStraight & ballWithinSight(Ball) & dist < 125, %then noOp(t), %else pi(found, pi(pval1, pi(nval1, pi(tval1, pi(dist1, pi(pval1abs, pi(pval1less, pi(p, pi(n, limit( searchBall(Ball, found, t) : queryHeadJoints(pval1, nval1, tval1, t) : queryNearDistance(dist1, t) ): limit( if(found = 0, %then turn(90, t), %else ?(abs(pval1, pval1abs)) : ?(pval1less is pval1 * 2 / 3) : if( pval1abs > 10, %then turn(pval1less, t), %else if( dist1 > 200, %then walk(150, t), %else if( dist1 > 55, %then walk(50, t), %else noOp(t) ) ) ) : ?(p is 0 - pval1) : ?(n is 15 - nval1) : pan(p, t) : nod(n, t) % : wait(1, t) ) ): approachDot(Ball) ))))))))) ) )))))))) ) ). macroAction(north(T), limit(approachDot(pink)) : playSound("barkhigh.wav", T) : wait(6, T) : walk(500, T) ). macroAction(east(T), limit(approachDot(blue)) : playSound("barkhigh.wav", T) : wait(6, T) : walk(500, T) ). macroAction(south(T), limit(approachDot(yellow)) : playSound("barkhigh.wav", T) : wait(6, T) : walk(500, T) ). macroAction(west(T), limit(approachDot(green)) : playSound("barkhigh.wav", T) : wait(6, T) : walk(500, T) ). proc(pathPlanning(N), pi(t, pi(n1, ?(now(t)) : if( N < 1, %then noOp(t), %else ( north(t) # east(t) # south(t) # west(t) ) : ?(n1 is N - 1) : pathPlanning(n1) ) )) ). proc(traverseMaze, pi(t, ?(now(t)) : wait(2, t) : getReady(t) : limit(pathPlanning(4)) ) ). reward(0, s0). reward(R, do(A, S)):- not A = north(T), not A = east(T), not A = west(T), not A = south(T), R is 0. reward(R, do(A, S)):- (A = north(T); A = east(T); A = west(T); A = south(T)), roboLoc(X, Y, do(A, S)), ( goalRoom(X, Y), R is 100 ; not goalRoom(X, Y), R is -1).