Declaring you must be awake to act

Hi everyone,

This is my first post. My code works fine:

can_act(Person) :- status(Person,awake).
carry(Person,Object) :- can_act(Person),object(Object),not(heavy(Object)).
carry(Person,Object) :- can_act(Person),object(Object),strong(Person).

But, is there a way to omit can_act(Person) in every action by declaring action(carry) and then declaring “for all actions you must be awake” ?

thank you,
d.vyd

can_lift(Person,Object):- not(heavy(Object)) ; strong(Person).

Left up to you to to decide where to put can_lift/2

Hi @logicmoo . I’m not sure I follow you. It looks like you removed the can_act(Person) so there is no check at all if the person is awake. I was hoping for a way to remove this check in carry(Person,Object) by somehow declaring just once that carry is an action and that actions always require a person to be awake. This way I could create many actions and omit can_act(Person) in all of them. If that is what you’ve done, could you walk me through it?

Oh I was only hinting the final program would be able to be slightly simplified like this

can_act(Person) :- status(Person,awake).
carry(Person,Object) :- can_act(Person),object(Object),can_lift(Person,Object).
can_lift(Person,Object):- not(heavy(Object)) ; strong(Person).

Ok, this is a bit easier…

purposefull_action(carry).
purposefull_action(push).
purposefull_action(pull).

action_requires(Act,awake):-  purposefull_action(Act).

can_act(Person,Act):- action_requires(Act,State), status(Person,State).

do_act(Act,Person,Object) :- can_act(Person,Act),object(Object),can_lift(Person,Object).

can_lift(Person,Object):- not(heavy(Object)) ; strong(Person).

So instead of

would become do_act(carry,Person,Object)

Oh, that looks neat. I’ll play with that approach for a bit. Thanks!