2023-11-28 11:01:38 -05:00
|
|
|
all_cards = {
|
2023-11-10 16:24:19 -05:00
|
|
|
rooms = ['Library' 'Kitchen' 'Conservatory']
|
|
|
|
suspects = ['White' 'Green' 'Scarlett']
|
|
|
|
weapons = ['Rope' 'Lead_Pipe' 'Knife']
|
|
|
|
}
|
2023-10-06 08:17:37 -04:00
|
|
|
|
2023-12-01 23:20:33 -05:00
|
|
|
is_ready_to_solve = <fn map -> bool> |cards| {
|
2023-12-01 22:16:50 -05:00
|
|
|
((length cards:suspects) == 1)
|
|
|
|
&& ((length cards:rooms) == 1)
|
|
|
|
&& ((length cards:weapons) == 1)
|
2023-11-04 06:02:27 -04:00
|
|
|
}
|
|
|
|
|
2023-12-01 23:20:33 -05:00
|
|
|
take_turn = <fn str str map -> map> |opponent_card current_room cards| {
|
2023-11-10 16:24:19 -05:00
|
|
|
(remove_card opponent_card cards)
|
|
|
|
(make_guess current_room cards)
|
|
|
|
cards
|
2023-11-27 15:02:08 -05:00
|
|
|
}
|
2023-10-18 21:50:45 -04:00
|
|
|
|
2023-12-01 23:20:33 -05:00
|
|
|
remove_card = <fn str map> |opponent_card cards| {
|
2023-12-01 22:16:50 -05:00
|
|
|
(output opponent_card cards)
|
2023-11-27 15:02:08 -05:00
|
|
|
cards:rooms -= opponent_card
|
|
|
|
cards:suspects -= opponent_card
|
|
|
|
cards:weapons -= opponent_card
|
2023-11-03 18:04:45 -04:00
|
|
|
}
|
2023-10-16 16:48:02 -04:00
|
|
|
|
2023-12-01 23:20:33 -05:00
|
|
|
make_guess = <fn str map> |current_room cards| {
|
2023-11-10 16:24:19 -05:00
|
|
|
if (is_ready_to_solve cards) {
|
2023-10-06 21:59:01 -04:00
|
|
|
(output 'It was '
|
2023-11-10 16:24:19 -05:00
|
|
|
+ cards:suspects:0
|
2023-11-04 06:02:27 -04:00
|
|
|
+ ' in the '
|
2023-11-10 16:24:19 -05:00
|
|
|
+ cards:rooms:0
|
2023-11-04 06:02:27 -04:00
|
|
|
+ ' with the '
|
2023-11-10 16:24:19 -05:00
|
|
|
+ cards:weapons:0
|
2023-10-25 14:41:23 -04:00
|
|
|
+ '!')
|
2023-11-03 18:04:45 -04:00
|
|
|
} else {
|
2023-10-06 21:59:01 -04:00
|
|
|
(output 'I accuse '
|
2023-11-10 16:24:19 -05:00
|
|
|
+ (random cards:suspects)
|
2023-10-23 20:45:47 -04:00
|
|
|
+ ' in the '
|
2023-11-10 16:24:19 -05:00
|
|
|
+ current_room
|
2023-10-23 20:45:47 -04:00
|
|
|
+ ' with the '
|
2023-11-10 16:24:19 -05:00
|
|
|
+ (random cards:weapons)
|
2023-11-28 11:01:38 -05:00
|
|
|
+ '.')
|
2023-11-03 18:04:45 -04:00
|
|
|
}
|
|
|
|
}
|
2023-10-31 01:09:29 -04:00
|
|
|
|
2023-11-10 16:24:19 -05: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 06:02:27 -04:00
|
|
|
|