%%%%%%%%%%%%%%%%% Communication rules for sherlock (1* - 3*) % 20.10.1997 12.10 rule(10):- pr_firing(10), goal(start_comm), then, af(advice('page hercule ~fact(start_comm_hercule)')). rule(11):- pr_firing(11), fact(start_comm_sherlock), then, rg(start_comm), af(communication_established). /* Get number of suspects */ rule(112):- pr_firing(112), not(fact(number(suspects))), then, afw(number(suspects)), afw(number(suspects,0)), fact(room(R)), fact(locate(R,S)), not(S=nothing), not(fact(victim(S))), fact(number(suspects,N)), N1 is N + 1, afw(number(suspects,N1)), rfw(number(suspects,N)), fail. /* Reaction at must_page (only visit_room, for now!) */ %visit_room rule(115):- pr_firing(115), fact(communication_established), then, fact(must_page(fact(visit_room(sherlock,R)))), af(sendf(fact(visit_room(sherlock,R)))), rf(must_page(fact(visit_room(sherlock,R)))), fail. %object(sherlock,M,X,R) rule(1161):- pr_firing(1161), fact(communication_established), then, fact(must_page(fact(object(sherlock,M,X,R)))), not(fact(visit_room(hercule,R))), af(sendf(fact(object(sherlock,M,X,R)))), rf(must_page(fact(object(sherlock,M,X,R)))), fail. rule(1162):- pr_firing(1162), fact(communication_established), then, fact(must_page(fact(object(sherlock,M,X,R)))), fact(visit_room(hercule,R)), rf(must_page(fact(object(sherlock,M,X,R)))), fail. %kill_reason(sherlock,T,P) rule(117):- pr_firing(117), fact(communication_established), then, fact(must_page(fact(kill_reason(sherlock,T,P)))), af(sendf(fact(kill_reason(sherlock,T,P)))), rf(must_page(fact(kill_reason(sherlock,T,P)))), fail. %find_has(sherlock,X,H,T,1) rule(118):- pr_firing(118), fact(communication_established), then, fact(must_page(fact(find_has(sherlock,X,H,T,1)))), af(sendf(fact(find_has(sherlock,X,H,T,1)))), rf(must_page(fact(find_has(sherlock,X,H,T,1)))), fail. %object(sherlock,ask,X) rule(1191):- pr_firing(1191), fact(communication_established), then, fact(must_page(fact(object(sherlock,ask,X)))), not(fact(object(hercule,ask,X))), af(sendf(fact(object(sherlock,ask,X)))), rf(must_page(fact(object(sherlock,ask,X)))), fail. rule(1192):- pr_firing(1192), fact(communication_established), then, fact(must_page(fact(object(sherlock,ask,X)))), fact(object(hercule,ask,X)), rf(must_page(fact(object(sherlock,ask,X)))), fail. /* Answer at interesting objects to ask */ rule(12):- pr_firing(12), fact(object(hercule,ask,X)), then, rf(object(hercule,ask,X)), not(fact(paged(fact(object(sherlock,ask,X))))), af(paged(fact(object(sherlock,ask,X)))), not(fact(object(ask,X))), af(object(ask,X)). /* Answer at interesting objects to look or read */ rule(1311):- pr_firing(1311), fact(object(hercule,M,X,R)), not(fact(visit_room(sherlock,R))), then, rf(object(hercule,M,X,R)), not(fact(object(sherlock,M,X,R))), not(fact(object(M,X,R))), af(object(M,X,R)), not(fact(must_visit(R))), af(must_visit(R)). rule(1312):- pr_firing(1312), fact(object(hercule,M,X,R)), fact(visit_room(sherlock,R)), then, rf(object(hercule,M,X,R)). /* Answer at did_you(hercule,ask,X) */ rule(1321):- pr_firing(1321), fact(did_you(hercule,ask,X)), then, fact(object(ask,X)), afw(number(ask,X,0)), fact(room(R)), fact(locate(R,S)), fact(already_object(ask,S,X)), fact(number(ask,X,N)), N1 is N + 1, afw(number(ask,X,N1)), rfw(number(ask,X,N)). rule(1322):- pr_firing(1322), fact(number(ask,X,N)), then, fact(number(suspects,NS)), af(sendf(fact(number(sherlock,ask,X,N,from,NS)))), rfw(number(ask,X,N)), fact(did_you(hercule,ask,X)), rf(did_you(hercule,ask,X)). /* Answer at what_about(hercule,M,X,R) */ rule(133):- pr_firing(133), fact(what_about(hercule,M,X,R)), fact(answ(M,X,R,A)), not(fact(answ_ag(sherlock,M,X,R,A))), then, rf(what_about(hercule,M,X,R)), af(answ_ag(sherlock,M,X,R,A)), af(sendf(fact(answ_ag(sherlock,M,X,R,A)))). /* Get facts from answ_ag */ rule(134):- pr_firing(134), fact(answ_ag(hercule,M,X,R,A)), then, rf(answ_ag(hercule,M,X,R,A)), af(already_object(M,X)), af(answ(M,X,R,A)), name(A,AS), extrf(AS,AA). /* Answer at number(hercule,ask,X,N,from,NS) */ rule(1351):- pr_firing(1351), fact(number(hercule,ask,X,N,from,NS)), N = 0, then, rf(number(hercule,ask,X,N,from,NS)), af(sendf(fact(object(sherlock,ask,X)))). rule(1352):- pr_firing(1352), fact(number(hercule,ask,X,N,from,NS)), N < NS - N, then, rf(number(hercule,ask,X,N,from,NS)), af(sendf(fact(keep(sherlock,ask,X)))). rule(1353):- pr_firing(1353), fact(number(hercule,ask,X,N,from,NS)), N = NS, then, rf(number(hercule,ask,X,N,from,NS)), af(sendf(fact(good(sherlock,ask,X)))). rule(1354):- pr_firing(1354), fact(number(hercule,ask,X,N,from,NS)), then, rf(number(hercule,ask,X,N,from,NS)). /* Answer at give_facts_nr(monitor) */ rule(1361):- pr_firing(1361), fact(give_facts_nr(monitor)), then, rf(give_facts_nr(monitor)), afw(send_facts_nr), afw(number(facts,0)), fact(X), fact(number(facts,N)), N1 is N + 1, rfw(number(facts,N)), afw(number(facts,N1)), fail. rule(1362):- pr_firing(1362), fact(send_facts_nr), then, fact(number(facts,N)), af(sendm(facts_nr(sherlock,N))), rfw(number(facts,N)). /* Answer at give_goals_nr(monitor) */ rule(1371):- pr_firing(1371), fact(give_goals_nr(monitor)), then, rf(give_goals_nr(monitor)), afw(send_goals_nr), afw(number(goals,0)), goal(X), fact(number(goals,N)), N1 is N + 1, rfw(number(goals,N)), afw(number(goals,N1)), fail. rule(1372):- pr_firing(1372), fact(send_goals_nr), then, fact(number(goals,N)), af(sendm(goals_nr(sherlock,N))), rfw(number(goals,N)).