dust-lang 0.4.2

General purpose programming language
cards = {
	rooms = ['Library' 'Kitchen' 'Conservatory']
	suspects = ['White' 'Green' 'Scarlett']
	weapons = ['Rope' 'Lead_Pipe' 'Knife']
}

is_ready_to_solve = (cards <map>) <bool> {
	(length(cards:suspects) == 1)
	&& (length(cards:rooms) == 1)
	&& (length(cards:weapons) == 1)
}

remove_card = (cards <map>, opponent_card <str>) <none> {
	cards:rooms -= opponent_card
	cards:suspects -= opponent_card
	cards:weapons -= opponent_card
}

make_guess = (cards <map>, current_room <str>) <none> {
	if is_ready_to_solve(cards) {
		output(
			'I accuse '
			+ cards:suspects:0
			+ ' in the ' 
			+ cards:rooms:0  
			+ ' with the ' 
			+ cards:weapons:0 
			+ '!'
		)
	} else {
		output(
			'I question '
			+ random:from(cards:suspects)
			+ ' in the '
			+ current_room
			+ ' with the '
			+ random:from(cards:weapons)
			+ '.'
		)
	}
}

take_turn = (cards <map>, opponent_card <str>, current_room <str>) <none> {
	remove_card(cards opponent_card)
	make_guess(cards current_room)
}

take_turn(cards 'Rope' 'Kitchen')
take_turn(cards 'Library' 'Kitchen')
take_turn(cards 'Conservatory' 'Kitchen')
take_turn(cards 'White' 'Kitchen')
take_turn(cards 'Green' 'Kitchen')
take_turn(cards 'Knife' 'Kitchen')