dust/examples/clue_solver.ds

45 lines
821 B
Plaintext
Raw Normal View History

2023-10-25 18:41:23 +00:00
rooms = ['Library' 'Kitchen']
suspects = ['White' 'Green']
weapons = ['Rope' 'Lead_Pipe']
2023-10-19 01:50:45 +00:00
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-25 18:41:23 +00:00
removed = remove card in 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> {
2023-10-25 18:41:23 +00:00
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-25 18:41:23 +00:00
+ '!')
2023-10-16 20:48:02 +00:00
} else {
2023-10-07 01:59:01 +00:00
(output 'I accuse '
2023-10-24 00:45:47 +00:00
+ (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
}