def chance(chances, max_chances):
        """
        Calculates "chance" out of "max chances".
        Example: 1 chance out of 3 chances (or 33.3%)

        :param chances: a chance proportional to maxChances.

        :param max_chances: a maximum number of chances

        :return: random boolean "chance"
        """
        chances = chances if chances >= 0 else 0
        max_chances = max_chances if max_chances >= 0 else 0
        if chances == 0 and max_chances == 0:
            return False
        
        max_chances = max(max_chances, chances)
        start = (max_chances - chances) / 2
        end = start + chances
        hit = random.random() * max_chances
        return hit >= start and hit <= end