170 likes | 288 Views
Using FLUX to model The RollerSlam game. Fluent Calculus x FLUX. First Step: Defining the Fluents and the actions. RollerSlam (Fluents). RollerSlam (Fluents). RollerSlam (Fluents). RollerSlam (Actions). RollerSlam (Actions).
E N D
Second Step: Defining the precondition and state update axioms
Programming in FLUX • Precondition Axiom: • Poss(A(x), z) πA(x,z) or • NotPoss(A(x), z) ¬πA(x,z) • State Update Axiom • StateUpdate(z1, A(x), z2) Δ(x, z1), Update(z1, v+, v-, z2) • Do(s, z0, z) • do ([], Z, Z) • do([A|S},Z0, Z) :-poss(A, Z0),sateUpdate (Z0, A, Z1), do (S, Z1, Z2)
Initial State • Init(z0) Consistent(z0), DuplicateFree(z0)
Defining the ‘poss’ axioms • poss(throwA(Agent,Strength),Z1) :- holds(hasBall(Agent), Z1), not_holds(inGround(Agent),Z1). • poss(release(Agent),Z1) :- holds(hasBall(Agent),Z1). • poss(dash(Agent),Z1):- not_holds(inGround(Agent),Z1). • poss(kick(Agent,Strength),Z1) :- holds(hasBall(Agent), Z1), not_holds(inGround(Agent),Z1). • poss(tackle(Agent,AgentB,vector(Xmax, Ymax), MaxDistance),Z1) :- not_holds(inGround(Agent),Z1), holds(hasBall(AgentB), Z1), not_holds(counterTackle(AgentB),Z1), closer(Sxa, Sya, Sxb, Syb, MaxDistance). • poss(counterTackle(Agent),Z1) :- not_holds(inGround(Agent),Z1). • poss(hit(Agent,Strength, MaxDistance),Z1) :- not_holds(inGround(Agent), Z1), closer(Sxa, Sya, Sxb, Syb, MaxDistance). • poss(catchA(Agent, MaxDistance),Z1) :- not_holds(inGround(Agent),Z1), not_holds(hasBall(Agent), Z1), closer(Sxa, Sya, Sxb, Syb, MaxDistance). • poss(standUp(Agent),Z1) :- holds(inGround(Agent),Z1).
Pre-Conditions For Ramification • poss(ramifySit2, Z1):- holds(isMoving(Ball, Attrition), Z1). • poss(ramifySit3, Z1):- holds(outBoundary(Object), Z1).
‘State_update’ axioms • state_update(Z1,dash(Agent, vector(X,Y)),Z2,[]) :- holds(acceleration(Agent, vector(X0,Y0)),Z1), update(Z1,[acceleration(Agent,vector(X,Y))],[acceleration(Agent, vector(X0,Y0))],Z2). • state_update(Z1,throwA(Agent,Strength),Z2,[]) :- (poss(throwA(Agent,Strength),Z1), holds(position(Ball, vector(X0, Y0)),Z1), X #= X0 * Strength, Y #= Y0 * Strength, update(Z1,[position(Ball, vector(X,Y))],[hasBall(Agent),position(Ball, vector(X0, Y0))],Z2)) ; (not poss(throwA(Agent,Strength),Z1), Z2=Z1 ). • state_update(Z1,release(Agent),Z2,[]) :- (poss(release(Agent),Z1), update(Z1,[],[hasBall(Agent)],Z2)) ; (not poss(release(Agent),Z1), Z2=Z1).
‘State_update’ axioms • state_update(Z1,kick(Agent,Strength),Z2,[]) :- (poss(kick(Agent,Strength),Z1), holds(position(Ball, vector(X0, Y0)),Z1), X #= X0 * Strength, Y #= Y0 * Strength, update(Z1,[position(Ball, vector(X,Y))],[hasBall(Agent),position(Ball, vector(X0, Y0))],Z2)) ; (not poss(kick(Agent,Strength),Z1), Z2=Z1). • state_update(Z1,tackle(Agent,AgentB,vector(Xmax, Ymax), MaxDistance),Z2,[]) :- (poss(tackle(Agent,AgentB,vector(Xmax, Ymax), MaxDistance),Z1), holds(position(Agent, vector(Sxa,Sya)),Z1), holds(position(AgentB, vector(Sxb,Syb)),Z1), update(Z1,[inGround(AgentB)],[hasBall(AgentB)],Z2)) ; (not poss(tackle(Agent,AgentB,vector(Xmax, Ymax), MaxDistance),Z1), Z2=Z1).
‘State_update’ axioms • state_update(Z1,counterTackle(Agent),Z2,[]) :- (poss(counterTackle(Agent),Z1), update(Z1,[counterTackle(Agent)],[],Z2)) ; (not poss(counterTackle(Agent),Z1), Z2=Z1). • state_update(Z1,hit(Agent,Strength, MaxDistance),Z2,[]) :- (poss(hit(Agent,Strength, MaxDistance),Z1), holds(position(Agent, vector(Sxa,Sya)),Z1), holds(position(Ball, vector(Sxb,Syb)),Z1), X #= Sxb * Strength, Y #= Syb * Strength, update(Z1,[position(Ball, vector(X,Y))],[position(Ball, vector(Sxb,Syb))],Z2)) ; (not poss(hit(Agent,Strength, MaxDistance),Z1), Z2=Z1).
‘State_update’ axioms • state_update(Z1,catchA(Agent, MaxDistance),Z2,[]) :- (poss(catchA(Agent, MaxDistance),Z1), holds(position(Agent, vector(Sxa,Sya)),Z1), holds(position(Ball, vector(Sxb,Syb)),Z1), update(Z1,[hasBall(Agent)],[],Z2)) ; (not poss(catchA(Agent, MaxDistance),Z1), Z2=Z1). • state_update(Z1,standUp(Agent),Z2,[]) :- (poss(standUp(Agent),Z1), update(Z1,[],[inGround(Agent)],Z2)) ; (not poss(standUp(Agent),Z1), Z2=Z1 ).