2023-12-30 02:15:03 +00:00
|
|
|
cards = {
|
2023-11-10 21:24:19 +00:00
|
|
|
rooms = ['Library' 'Kitchen' 'Conservatory']
|
|
|
|
suspects = ['White' 'Green' 'Scarlett']
|
|
|
|
weapons = ['Rope' 'Lead_Pipe' 'Knife']
|
|
|
|
}
|
2023-10-06 12:17:37 +00:00
|
|
|
|
2023-12-30 02:15:03 +00:00
|
|
|
is_ready_to_solve = (cards <map>) <bool> {
|
2023-12-30 02:53:26 +00:00
|
|
|
(length(cards:suspects) == 1)
|
|
|
|
&& (length(cards:rooms) == 1)
|
|
|
|
&& (length(cards:weapons) == 1)
|
2023-11-04 10:02:27 +00:00
|
|
|
}
|
|
|
|
|
2023-12-30 02:15:03 +00:00
|
|
|
remove_card = (cards <map>, opponent_card <str>) <none> {
|
2023-11-27 20:02:08 +00:00
|
|
|
cards:rooms -= opponent_card
|
|
|
|
cards:suspects -= opponent_card
|
|
|
|
cards:weapons -= opponent_card
|
2023-11-03 22:04:45 +00:00
|
|
|
}
|
2023-10-16 20:48:02 +00:00
|
|
|
|
2023-12-30 02:15:03 +00:00
|
|
|
make_guess = (cards <map>, current_room <str>) <none> {
|
|
|
|
if is_ready_to_solve(cards) {
|
|
|
|
output(
|
2023-12-30 02:53:26 +00:00
|
|
|
'I accuse '
|
2023-11-10 21:24:19 +00:00
|
|
|
+ cards:suspects:0
|
2023-11-04 10:02:27 +00:00
|
|
|
+ ' in the '
|
2023-11-10 21:24:19 +00:00
|
|
|
+ cards:rooms:0
|
2023-11-04 10:02:27 +00:00
|
|
|
+ ' with the '
|
2023-11-10 21:24:19 +00:00
|
|
|
+ cards:weapons:0
|
2023-12-30 02:15:03 +00:00
|
|
|
+ '!'
|
|
|
|
)
|
2023-11-03 22:04:45 +00:00
|
|
|
} else {
|
2023-12-30 02:15:03 +00:00
|
|
|
output(
|
2023-12-30 02:53:26 +00:00
|
|
|
'I question '
|
2024-01-01 12:46:47 +00:00
|
|
|
+ random:from(cards:suspects)
|
2023-10-24 00:45:47 +00:00
|
|
|
+ ' in the '
|
2023-11-10 21:24:19 +00:00
|
|
|
+ current_room
|
2023-10-24 00:45:47 +00:00
|
|
|
+ ' with the '
|
2024-01-01 12:46:47 +00:00
|
|
|
+ random:from(cards:weapons)
|
2023-12-30 02:15:03 +00:00
|
|
|
+ '.'
|
|
|
|
)
|
2023-11-03 22:04:45 +00:00
|
|
|
}
|
|
|
|
}
|
2023-10-31 05:09:29 +00:00
|
|
|
|
2023-12-30 02:15:03 +00:00
|
|
|
take_turn = (cards <map>, opponent_card <str>, current_room <str>) <none> {
|
|
|
|
remove_card(cards opponent_card)
|
|
|
|
make_guess(cards current_room)
|
2023-12-26 22:52:44 +00:00
|
|
|
}
|
|
|
|
|
2023-12-30 02:15:03 +00:00
|
|
|
take_turn(cards 'Rope' 'Kitchen')
|
|
|
|
take_turn(cards 'Library' 'Kitchen')
|
|
|
|
take_turn(cards 'Conservatory' 'Kitchen')
|
|
|
|
take_turn(cards 'White' 'Kitchen')
|
|
|
|
take_turn(cards 'Green' 'Kitchen')
|
|
|
|
take_turn(cards 'Knife' 'Kitchen')
|