1
0
dust/examples/clue_solver.ds
2023-11-03 18:04:45 -04:00

45 lines
820 B
Plaintext

rooms = ['Library' 'Kitchen']
suspects = ['White' 'Green']
weapons = ['Rope' 'Lead_Pipe']
cards = [rooms suspects weapons]
take_turn = |current_room opponent_card| => {
(remove_card opponent_card)
(make_guess current_room)
}
remove_card = |opponent_card| => {
for card_list in cards {
removed = remove card from card_list
card == opponent_card
}
if (type removed) == 'empty'
output 'Card not found.'
}
make_guess = |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)
+ '!')
}
}
(make_guess 'Library')