-
Notifications
You must be signed in to change notification settings - Fork 1
/
rps.pl
23 lines (19 loc) · 779 Bytes
/
rps.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# sCASP encoding of rps
# Reference: Jason's article at https://medium.com/computational-law-diary/how-rules-as-code-makes-laws-better-115ab62ab6c4
#pred player(X) :: '@(X) is a player'.
#pred player_in_game(Player,Game) :: '@(Player) participated in @(Game)'.
#pred winner_of_game(Player,Game) :: '@(Player) is the winner of @(Game)'.
#pred player_threw_sign(Player,Sign) :: '@(Player) threw @(Sign)'.
#pred sign_beats_sign(Sign,OtherSign) :: '@(Sign) beats @(OtherSign)'.
#beats(rock,scissors).
#beats(scissors,paper).
#beats(paper,rock).
winner(Game,Player) :-
player(Player),
player(OtherPlayer),
participate_in(Game,Player),
throw(Player,Sign),
participate_in(Game,OtherPlayer),
throw(OtherPlayer,OtherSign),
beat(Sign,OtherSign),
Player \= OtherPlayer.