Thursday, November 26, 2015

[Prolog] Fun Murder Mystery

Instructions: You will use Prolog to solve a murder mystery.

There are 5 victims:
1) Mr. Boddy, the host of the party.  Killed with a candlestick in the hall.
2) The cook.  Killed with a knife in the kitchen.
3) A motorist who stopped by the house.  Killed with a wrench in the lounge.
4) A police officer who was searching for the motorist.  Killed with a lead pipe in the library.
5) Yvette, the house maid.  Strangled by a rope in the billiards room.
6) A singing telegram.  Shot with the revolver in the hall.

The suspects are:
1) Professor Plum
2) Mrs. Peacock
3) Mrs. White
4) Miss Scarlet, a Madam operating a brothel in Washington DC.
5) Colonel Mustard
6) Mr. Green
7) Wadsworth, the butler

You are given the following clues regarding motive:
*Everyone except Wadsworth had a motive to kill Mr. Boddy.
*The cook had worked for Mrs. Peacock, and had stolen money from her.
*The motorist was blackmailing Colonel Mustard.
*Yvette had worked for Miss Scarlet's brothel before, and left on bad terms.
*Yvette and Colonel Mustard had formerly had an affair, and she was threatening to tell his wife.
*Mrs. White knew that Yvette was also having an affair with her husband.
*Miss Scarlet had been bribing the police officer to keep him from arresting her.
*Professor Plum had lost his license as a psychiatrist after having an affair with his patient, who turns out to be the singing telegram.
*Wadsworth has an unnatural hatred for singing telegrams.

There are some additional clues that may help you solve the case:
*Colonel Mustard is bad with knots, and so could not have used the rope.
*Professor Plum hates guns.
*Mrs. Peacock would never risk damaging a fine candlestick by using it as a weapon.
*Miss Scarlet was never in the billiards room.
*Professor Plum was never in the kitchen.
*Colonel Mustard never visited the room where Mr. Boddy was murdered.
*Mrs. White has an alibi for the murder of Mr. Boddy.
*Mr. Green has an alibi for every murder.
*Miss Scarlet has an alibi for every murder committed in the same room where the revolver was used.

Notes: This is not correct so the murderer got away.

victim(mr_boddy).
victim(cook).
victim(motorist).
victim(police_officer).
victim(yvette).
victim(singing_telegram).

suspect(professor_plum).
suspect(mrs_peacock).
suspect(mrs_white).
suspect(miss_scarlet).
suspect(colonel_mustard).
suspect(mr_green).
suspect(wadsworth).

weapon(wrench).
weapon(candlestick).
weapon(lead_pipe).
weapon(knife).
weapon(revolver).
weapon(rope).

room(hall).
room(kitchen).
room(lounge).
room(library).
room(billiard_room).

murder(mr_boddy,candlestick,hall).
murder(cook,knife,kitchen).
murder(motorist,wrench,lounge).
murder(police_officer,lead_pipe,library).
murder(singing_telegram,revolver,hall).
murder(yvette,rope,billiard_room).

motive(professor_plum,mr_boddy).
motive(mrs_peacock,mr_boddy).
motive(mrs_white,mr_boddy).
motive(miss_scarlet,mr_boddy).
motive(colonel_mustard,mr_boddy).
motive(mr_green,mr_boddy).
motive(mrs_peacock,cook).
motive(colonel_mustard,motorist).
motive(molonel_mustard,yvette).
motive(mrs_white,yvette).
motive(miss_scarlet,police_officer).
motive(professor_plum,singing_telegram).
motive(wadsworth,singing_telegram).

alibis(colonel_mustard, mr_boddy, candlestick).
alibis(mrs_white, mr_boddy, candlestick).

alibir(colonel_mustard, billiard_room, rope).
alibir(professor_plum, hall, revolver).
alibir(mrs_peacock, hall, candlestick).
alibir(miss_scarlet, hall, revolver).

alibiv(mr_green, X).

% Update accuse to solve the murders.
% Add more facts and rules as needed.
accuse(V,S) :- murder(V,W,R), suspect(S), motive(S, V), not(alibis(S, V, W)), not(alibir(S, R, W)), not(alibiv(S, V)).

No comments:

Post a Comment