/* Prolog Trolley Ethical Intuition Simulator *//* for Psych 205 by Luke Swartz *//* (c) 2000 *//* effects */bad(killing(_AnyNumberOfPeople)).bad(hitting(_AnyNumberOfPeople)).worse(killing(A), killing(B)) :-	A > B.worse(hitting(A), hitting(B)) :-	A > B.worse(killing(_AnyNumber), hitting(_AnyOtherNumber)) :- !.equally_bad(killing(A), killing(B)) :-	A == B.equally_bad(hitting(A), hitting(B)) :-	A == B./* causation and i(ntentional)-causation */causes(FirstEvent, SecondEvent) :-	FirstEvent == SecondEvent, !.causes(FirstEvent, SecondEvent) :-	directly_causes(FirstEvent, SecondEvent), !.causes(FirstEvent, SecondEvent) :-	directly_causes(X, SecondEvent),	causes(FirstEvent, X).causes(FirstEvent, prevention_of(SecondEvent)) :-	prevents(FirstEvent, SecondEvent).causes(prevention_of(FirstEvent), prevention_of(SecondEvent)) :-	causes(FirstEvent, SecondEvent).i_causes(FirstEvent, SecondEvent) :-	causes(FirstEvent, SecondEvent),	is_goal(SecondEvent).i_causes(FirstEvent, SecondEvent) :-	is_goal(X),	causes(FirstEvent, SecondEvent),	causes(SecondEvent, X)./* prevention */prevents(FirstEvent, SecondEvent) :-	directly_prevents(FirstEvent, SecondEvent), !.prevents(FirstEvent, SecondEvent) :-	directly_prevents(X,Y),	causes(FirstEvent, X),	causes(Y, SecondEvent)./* permissibility *//* intentional battery/murder is prohibited (assumes DDE??) */not_p(Action) :-	bad(SomeEffect),	i_causes(Action, SomeEffect), !./* utilitarian consequences */not_p(Action) :-	is_goal(prevention_of(BadResult)),	bad(WorseEffect),	causes(Action, WorseEffect),	worse(WorseEffect, BadResult)./* preference for inaction, all things being equal */not_p(Action) :-	is_goal(prevention_of(BadResult)),	bad(EqualEffect),	causes(Action, EqualEffect),	equally_bad(EqualEffect, BadResult).obligatory(Action) :-	bad(Effect),	\+ causes(Action, Effect), /* no bad effect */	bad(OtherEffect),	prevents(Action, OtherEffect). /* prevents a bad effect *//* a macro: */can(Action) :-	\+ not_p(Action).