1
0
dust/examples/clue_solver.ds

45 lines
821 B
Plaintext
Raw Normal View History

2023-10-25 14:41:23 -04:00
rooms = ['Library' 'Kitchen']
suspects = ['White' 'Green']
weapons = ['Rope' 'Lead_Pipe']
2023-10-18 21:50:45 -04:00
cards = [rooms suspects weapons]
2023-10-06 08:17:37 -04:00
2023-10-18 21:50:45 -04: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 14:41:23 -04:00
removed = remove card in card_list {
2023-10-18 21:50:45 -04:00
card == opponent_card
}
}
2023-10-22 14:48:34 -04:00
if (type removed) == 'empty' {
2023-10-18 21:50:45 -04:00
(output 'Card not found.')
}
2023-10-16 16:48:02 -04:00
}
2023-10-06 21:59:01 -04:00
make_guess = function <current_room> {
2023-10-25 14:41:23 -04:00
if ((length suspects) == 1)
&& ((length rooms) == 1)
&& ((length weapons) == 1)
2023-10-16 16:48:02 -04:00
{
2023-10-06 21:59:01 -04:00
(output 'It was '
+ suspects.0
+ ' in the '
+ rooms.0
+ ' with the '
+ weapons.0
2023-10-25 14:41:23 -04:00
+ '!')
2023-10-16 16:48:02 -04:00
} else {
2023-10-06 21:59:01 -04:00
(output 'I accuse '
2023-10-23 20:45:47 -04:00
+ (random suspects)
+ ' in the '
+ current_room
+ ' with the '
+ (random weapons)
+ '!')
2023-10-16 16:48:02 -04:00
}
2023-10-06 21:59:01 -04:00
}