:- dynamic request/2, need/1, manager/1, common_project/2, using/1, abroad/1.
:-compile('C:/GorgiasB/gorgias-src-0.6d/lib/gorgias.pl').
:-compile('C:/GorgiasB/gorgias-src-0.6d/ext/lpwnf.pl').
rule(r1(Agent, Resource), challenge(Agent, Resource), []):-request(Agent, Resource).
rule(r2(Agent, Resource), refuse(Agent, Resource), []):-need(Resource), request(Agent, Resource).
rule(r3(Agent, Resource), give(Agent, Resource), []):-request(Agent, Resource), manager(Agent).
rule(p1(Agent, Resource), prefer(r2(Agent, Resource), r1(Agent, Resource)), []).
rule(p2(Agent, Resource), prefer(r1(Agent, Resource), r2(Agent, Resource)), []):-common_project(Agent, Resource).
rule(p3(Agent, Resource), prefer(r3(Agent, Resource), r1(Agent, Resource)), []).
rule(p4(Agent, Resource), prefer(r1(Agent, Resource), r3(Agent, Resource)), []):-using(Resource).
rule(p5(Agent, Resource), prefer(r1(Agent, Resource), r3(Agent, Resource)), []):-abroad(Agent).
rule(c1(Agent, Resource), prefer(p2(Agent, Resource), p1(Agent, Resource)), []).
rule(c2(Agent, Resource), prefer(p4(Agent, Resource), p3(Agent, Resource)), []).
rule(c3(Agent, Resource), prefer(p5(Agent, Resource), p3(Agent, Resource)), []).
complement(give(Agent, Resource), challenge(Agent, Resource)).
complement(challenge(Agent, Resource), give(Agent, Resource)).
complement(refuse(Agent, Resource), challenge(Agent, Resource)).
complement(challenge(Agent, Resource), refuse(Agent, Resource)).
complement(refuse(Agent, Resource), give(Agent, Resource)).
complement(give(Agent, Resource), refuse(Agent, Resource)).