dust/examples/clue_solver.ds
2023-10-25 15:12:57 -04:00

45 lines
821 B
Plaintext

rooms = ['Library' 'Kitchen']
suspects = ['White' 'Green']
weapons = ['Rope' 'Lead_Pipe']
cards = [rooms suspects weapons]
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 {
removed = remove card in card_list {
card == opponent_card
}
}
if (type removed) == 'empty' {
(output 'Card not found.')
}
}
make_guess = function <current_room> {
if ((length suspects) == 1)
&& ((length rooms) == 1)
&& ((length weapons) == 1)
{
(output 'It was '
+ suspects.0
+ ' in the '
+ rooms.0
+ ' with the '
+ weapons.0
+ '!')
} else {
(output 'I accuse '
+ (random suspects)
+ ' in the '
+ current_room
+ ' with the '
+ (random weapons)
+ '!')
}
}