I want to apply a list of effects in a current state in other words, have a list of effects generated by an action if the current state has a condition that corresponds to the denial of a effect that condition will be removed.
If i have the current state:
[clear(b),on(b,a),on(a,mesa),clear(d),on(d,c),on(c,desk)]
And the list of effects :
[-clear(d), -on(d.c), on(c,d)]
The result would be :
[clear(b),on(b,a),on(a,mesa), on(c,d), on(c,desk)]
This is what i got right now, any help would be appreciated!
applyEffects(currentState,Effects,result)
insert(Element, List,result)
remove(Element,List, result)
applyEffects([],L,L).
applyEffects(L,[],L).
applyEffects([X|XTail], [-X|YTail], A) :-
insert(X, A, B),
applyEffects([X|XTail],YTail, B).
insert(E, L1, [E|L1]).
remove(X, [X|L1], L1).
remove(X, [Y|L1], A):- remove(X,L1,[L1|Y]).