type Cards { rooms <[str]> suspects <[str]> weapons <[str]> } cards = Cards { rooms = ['Library' 'Kitchen' 'Conservatory'] suspects = ['White' 'Green' 'Scarlett'] weapons = ['Rope' 'Lead_Pipe' 'Knife'] } is_ready_to_solve = (cards ) { (length(cards:suspects) == 1) && (length(cards:rooms) == 1) && (length(cards:weapons) == 1) } remove_card = (cards , opponent_card ) { cards:rooms -= opponent_card cards:suspects -= opponent_card cards:weapons -= opponent_card } make_guess = (cards , current_room ) { 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 , opponent_card , current_room ) { 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')