Skip to content

Instantly share code, notes, and snippets.

@rickcnagy
Last active September 3, 2018 16:37
Show Gist options
  • Save rickcnagy/cc94534ab56a2ee9f43e5f171e9228da to your computer and use it in GitHub Desktop.
Save rickcnagy/cc94534ab56a2ee9f43e5f171e9228da to your computer and use it in GitHub Desktop.
An overkill Prolog solution to the Jindosh riddle in Dishonored 2
exists(A, list(A, _, _, _, _)).
exists(A, list(_, A, _, _, _)).
exists(A, list(_, _, A, _, _)).
exists(A, list(_, _, _, A, _)).
exists(A, list(_, _, _, _, A)).
rightOf(R, L, list(L, R, _, _, _)).
rightOf(R, L, list(_, L, R, _, _)).
rightOf(R, L, list(_, _, L, R, _)).
rightOf(R, L, list(_, _, _, L, R)).
leftOf(L, R, list(L, R, _, _, _)).
leftOf(L, R, list(_, L, R, _, _)).
leftOf(L, R, list(_, _, L, R, _)).
leftOf(L, R, list(_, _, _, L, R)).
middle(A, list(_, _, A, _, _)).
first(A, list(A, _, _, _, _)).
nextTo(A, B, list(B, A, _, _, _)).
nextTo(A, B, list(_, B, A, _, _)).
nextTo(A, B, list(_, _, B, A, _)).
nextTo(A, B, list(_, _, _, B, A)).
nextTo(A, B, list(A, B, _, _, _)).
nextTo(A, B, list(_, A, B, _, _)).
nextTo(A, B, list(_, _, A, B, _)).
nextTo(A, B, list(_, _, _, A, B)).
%% name, color, city, drink, heirloom
jindosh(Guests) :-
exists(guest(finch, blue, _, _, _), Guests),
first(guest(winslow, _, _, _, _), Guests),
nextTo(guest(winslow, _, _, _, _), guest(_, green, _, _, _), Guests),
leftOf(guest(_, red, _, _, _), guest(_, white, _, _, _), Guests),
exists(guest(_, red, _, wine, _), Guests),
exists(guest(_, purple, dabokva, _, _), Guests),
nextTo(guest(_, _, _, _, ring), guest(_, _, dabokva, _, _), Guests),
exists(guest(contee, _, _, _, war_medal), Guests),
exists(guest(_, _, karnaca, _, bird_pendant), Guests),
nextTo(guest(_, _, _, _, diamond), guest(_, _, dunwall, _, _), Guests),
nextTo(guest(_, _, dunwall, _, _), guest(_, _, _, rum, _), Guests),
exists(guest(marcolla, _, _, whiskey, _), Guests),
exists(guest(_, _, baleton, absinthe, _), Guests),
middle(guest(_, _, _, beer, _), Guests),
exists(guest(natsiou, _, fraeport, _, _), Guests),
exists(guest(_, _, _, _, snuff_tin), Guests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment