2023-11-28 15:29:42 +00:00
|
|
|
all_cards <map> = {
|
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-11-27 20:02:08 +00:00
|
|
|
is_ready_to_solve = |cards <map>| <bool> {
|
2023-11-10 21:24:19 +00:00
|
|
|
((length cards:suspects) == 1)
|
|
|
|
&& ((length cards:rooms) == 1)
|
|
|
|
&& ((length cards:weapons) == 1)
|
2023-11-04 10:02:27 +00:00
|
|
|
}
|
|
|
|
|
2023-11-27 20:02:08 +00:00
|
|
|
take_turn = |opponent_card <str>, current_room <str>, cards <map>| <map> {
|
2023-11-10 21:24:19 +00:00
|
|
|
(remove_card opponent_card cards)
|
|
|
|
(make_guess current_room cards)
|
|
|
|
cards
|
2023-11-27 20:02:08 +00:00
|
|
|
}
|
2023-10-19 01:50:45 +00:00
|
|
|
|
2023-11-27 20:02:08 +00:00
|
|
|
remove_card = |opponent_card <str>, cards <map>| {
|
|
|
|
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-11-27 20:02:08 +00:00
|
|
|
make_guess = |current_room <str>, cards <map>| {
|
2023-11-10 21:24:19 +00:00
|
|
|
if (is_ready_to_solve cards) {
|
2023-10-07 01:59:01 +00:00
|
|
|
(output 'It was '
|
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-10-25 18:41:23 +00:00
|
|
|
+ '!')
|
2023-11-03 22:04:45 +00:00
|
|
|
} else {
|
2023-10-07 01:59:01 +00:00
|
|
|
(output 'I accuse '
|
2023-11-10 21:24:19 +00:00
|
|
|
+ (random 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 '
|
2023-11-10 21:24:19 +00:00
|
|
|
+ (random cards:weapons)
|
2023-10-24 00:45:47 +00:00
|
|
|
+ '!')
|
2023-11-03 22:04:45 +00:00
|
|
|
}
|
|
|
|
}
|
2023-10-31 05:09:29 +00:00
|
|
|
|
2023-11-10 21:24:19 +00:00
|
|
|
(take_turn 'Rope' 'Kitchen'
|
|
|
|
(take_turn 'Library' 'Kitchen'
|
|
|
|
(take_turn 'Conservatory' 'Kitchen'
|
|
|
|
(take_turn 'White' 'Kitchen'
|
|
|
|
(take_turn 'Green' 'Kitchen'
|
|
|
|
(take_turn 'Knife' 'Kitchen' all_cards))))))
|
2023-11-04 10:02:27 +00:00
|
|
|
|