How to use the drama.LoveTriangle function in drama

To help you get started, we’ve selected a few drama examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github james-owen-ryan / talktown / drama.py View on Github external
def _excavate_love_triangles(self):
        """Recognize character love triangles that have emerged in a simulation instance."""
        love_triangles = []
        for first_person in self.simulation.town.residents:
            first_person_love_interests = set(first_person.is_captivated_by)
            for second_person in first_person_love_interests:
                second_person_love_interests = set(second_person.is_captivated_by)
                if first_person not in second_person_love_interests:
                    for third_person in second_person_love_interests:
                        third_person_love_interests = set(third_person.is_captivated_by)
                        if second_person not in third_person_love_interests:
                            if first_person in third_person_love_interests:
                                subjects = (first_person, second_person, third_person)
                                if not any(lt for lt in love_triangles if set(lt.subjects) == set(subjects)):
                                    love_triangles.append(LoveTriangle(subjects=subjects))
        return love_triangles

drama

Delft Radar Modelling and perfornance Analysis (DRaMA)

GPL-3.0
Latest version published 11 months ago

Package Health Score

50 / 100
Full package analysis

Similar packages