2023-10-19 01:50:45 +00:00
|
|
|
rooms = ['Library', 'Kitchen']
|
|
|
|
suspects = ['White', 'Green']
|
|
|
|
weapons = ['Rope', 'Lead_Pipe']
|
|
|
|
cards = [rooms suspects weapons]
|
2023-10-06 12:17:37 +00:00
|
|
|
|
2023-10-19 01:50:45 +00:00
|
|
|
take_turn = function <current_room opponent_card> {
|
|
|
|
(remove_card opponent_card)
|
|
|
|
(make_guess current_room)
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_card = function <opponent_card> {
|
|
|
|
for card_list in cards {
|
2023-10-22 18:27:18 +00:00
|
|
|
removed = remove card from card_list {
|
2023-10-19 01:50:45 +00:00
|
|
|
card == opponent_card
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-22 18:48:34 +00:00
|
|
|
if (type removed) == 'empty' {
|
2023-10-19 01:50:45 +00:00
|
|
|
(output 'Card not found.')
|
|
|
|
}
|
2023-10-16 20:48:02 +00:00
|
|
|
}
|
|
|
|
|
2023-10-07 01:59:01 +00:00
|
|
|
make_guess = function <current_room> {
|
|
|
|
if (length suspects) == 1
|
|
|
|
&& (length rooms) == 1
|
|
|
|
&& (length weapons) == 1
|
2023-10-16 20:48:02 +00:00
|
|
|
{
|
2023-10-07 01:59:01 +00:00
|
|
|
(output 'It was '
|
|
|
|
+ suspects.0
|
|
|
|
+ ' in the '
|
|
|
|
+ rooms.0
|
|
|
|
+ ' with the '
|
|
|
|
+ weapons.0
|
|
|
|
+ '!'
|
2023-10-16 20:48:02 +00:00
|
|
|
)
|
|
|
|
} else {
|
2023-10-07 01:59:01 +00:00
|
|
|
(output 'I accuse '
|
|
|
|
+ (random suspects)
|
|
|
|
+ ' in the '
|
|
|
|
+ current_room
|
|
|
|
+ ' with the '
|
|
|
|
+ (random weapons)
|
|
|
|
+ '!')
|
2023-10-16 20:48:02 +00:00
|
|
|
}
|
2023-10-07 01:59:01 +00:00
|
|
|
}
|