Beispiel #1
0
def generate_goals(num_goals: int) -> List[Goal]:
    """Return a randomly generated list of goals with length num_goals.

    All elements of the list must be the same type of goal, but each goal
    must have a different randomly generated colour from COLOUR_LIST. No two
    goals can have the same colour.

    Precondition:
        - num_goals <= len(COLOUR_LIST)
    """
    x = COLOUR_LIST
    n = random.randint(0, 1)
    temp = []
    colour = []
    if n == 1:
        while len(temp) < num_goals:
            color = COLOUR_LIST[random.randint(0, len(x) - 1)]
            if not colour.__contains__(color):
                colour.append(colour_name(color))
                temp.append(PerimeterGoal(color))

        while len(temp) < num_goals:
            color = COLOUR_LIST[random.randint(0, len(x) - 1)]

            if not colour.__contains__(colour_name(color)):
                colour.append(colour_name(color))
                temp.append(BlobGoal(color))
    return temp
Beispiel #2
0
 def description(self) -> str:
     """Return a description of this goal.
     """
     description = "The player must aim to put the most possible units " + \
                   "of " + colour_name(self.colour) + " on the outer" +\
                   " perimeter."
     return description
Beispiel #3
0
 def description(self) -> str:
     """
     returns the description of the goal
     """
     color = colour_name(self.colour)
     return 'Player must aim to put the most possible units {} on the outer'\
            'perimeter'.format(color)
Beispiel #4
0
 def description(self) -> str:
     """Return a precise string description of the perimeter goal and the
     target colour
     """
     target = colour_name(self.colour)
     description = f'Perimeter Goal:Put the most possible units of ' \
                   f'{target} cells on outer perimeter'
     return 'DESCRIPTION: ' + description
Beispiel #5
0
    def description(self) -> str:
        """Return a precise string description of blob goal and the
        target colour
        """

        target = colour_name(self.colour)
        description = f'Blob Goal: Aim for the largest group of connected ' \
                      f'{target} blocks'
        return 'DESCRIPTION: ' + description
Beispiel #6
0
def _print_colours(x: int, y: int, text_height: int,
                   font: pygame.font.Font, image: pygame.Surface)\
        -> int:
    _print_to_image('Colours', x, y, font, image)

    # Indent the next item
    x += 10
    y += text_height + Y_FONT_PADDING

    for c in COLOUR_LIST:
        _print_to_image(colour_name(c), x, y, font, image, c)
        y += text_height + Y_FONT_PADDING

    return y
Beispiel #7
0
    def __str__(self) -> str:
        """Return this Block in a string format.
        """
        if len(self.children) == 0:
            indents = '\t' * self.level
            colour = colour_name(self.colour)
            return f'{indents}Leaf: colour={colour}, pos={self.position}, ' \
                   f'size={self.size}, level={self.level}\n'
        else:
            indents = '\t' * self.level
            result = f'{indents}Parent: pos={self.position},' \
                     f'size={self.size}, level={self.level}\n'

            for child in self.children:
                result += str(child)

            return result
Beispiel #8
0
    def __str__(self) -> str:
        """Return this Block in a string format.

        >>> block = Block((0, 0), 750, (0, 0, 0), 0, 1)
        >>> str(block)
        'Leaf: colour=Black, pos=(0, 0), size=750, level=0\\n'
        """
        if len(self.children) == 0:
            indents = '\t' * self.level
            colour = colour_name(self.colour)
            return f'{indents}Leaf: colour={colour}, pos={self.position}, ' \
                   f'size={self.size}, level={self.level}\n'
        else:
            indents = '\t' * self.level
            result = f'{indents}Parent: pos={self.position},' \
                     f'size={self.size}, level={self.level}\n'

            for child in self.children:
                result += str(child)

            return result
Beispiel #9
0
 def description(self) -> str:
     """ Returns the goal of the player on the bottom right section of
     the game screen. This goal is for BlobGoal.
     """
     colour = colour_name(self.colour)
     return 'Goal: Create the largest blob with {0}.'.format(colour)
Beispiel #10
0
 def description(self) -> str:
     return 'Create a largest “blob” of ' + colour_name(self.colour)
Beispiel #11
0
 def description(self) -> str:
     """ Returns the goal of the player on the bottom right section of
     the game screen. This goal is for PerimeterGoal.
     """
     colour = colour_name(self.colour)
     return 'Goal: Fill the perimeter with {0}.'.format(colour)
Beispiel #12
0
 def description(self) -> str:
     return 'Make the largest \'blob\' (area) of' + colour_name(self.colour)
Beispiel #13
0
 def description(self) -> str:
     return 'Most unit cells of ' + \
         colour_name(self.colour) + ' on the perimeter'
Beispiel #14
0
 def description(self) -> str:
     return 'Blob Goal: Create the largest “blob” of ' \
            + colour_name(self.colour) + '.'
Beispiel #15
0
 def description(self) -> str:
     # Reviewed 17/03/2020
     colour = colour_name(self.colour)
     return 'Connect as many {0} units together!'.format(colour)
Beispiel #16
0
 def description(self) -> str:
     """Return a description of the goal, including the target colour."""
     return 'Create the largest connected blob of {}.'.format(
         colour_name(self.colour))
Beispiel #17
0
 def description(self) -> str:
     return 'Make the largest ' + colour_name(self.colour) + \
            ' border around the board'
Beispiel #18
0
 def description(self) -> str:
     """this tells the user what there goal is
     """
     return 'Get ' + colour_name(self.colour) + 'blocks on' \
         ' the sides of the board. Corners are worth double'
Beispiel #19
0
 def description(self) -> str:
     """this tells the user what there goal is
     """
     return 'Connect as many blocks of ' + colour_name(self.colour) + \
            ' as possible'
Beispiel #20
0
 def description(self) -> str:
     statement = 'Biggest group of blobs of' + colour_name(self.colour)
     return statement
Beispiel #21
0
 def description(self) -> str:
     statement = 'Achieve squares of' + colour_name(self.colour) + \
                 'to touch the perimeter of the board.'
     return statement
Beispiel #22
0
 def description(self) -> str:
     description = "The player must aim for the largest group of " +\
                   "connected blocks of " + colour_name(self.colour) + "."
     return description
Beispiel #23
0
 def description(self) -> str:
     colour = colour_name(self.colour)
     return f'PerimeterGoal: Surround the perimeter of the board with {colour}.'
Beispiel #24
0
 def description(self) -> str:
     colour = colour_name(self.colour)
     return f'BlobGoal: Make the biggest {colour} blob.'
Beispiel #25
0
 def description(self) -> str:
     return 'Perimeter Goal: Put most unit cell ' \
            'of ' + colour_name(self.colour) + \
            ' on the outer perimeter.'
Beispiel #26
0
 def description(self) -> str:
     # TODO: Implement me
     return 'Most unit cells of ' + colour_name(self.colour) + \
            ' on the perimeter'
Beispiel #27
0
 def description(self) -> str:
     # Reviewed 17/03/2020
     colour = colour_name(self.colour)
     return 'Place as many {0} units on the perimeter!'.format(colour)
Beispiel #28
0
 def description(self) -> str:
     # TODO: Implement me
     return 'Largest group of connected blocks of ' + \
            colour_name(self.colour)
Beispiel #29
0
 def description(self) -> str:
     """Return a description of the goal, including the target colour."""
     return 'Create the most {} on the perimeter.'.format(
         colour_name(self.colour))
Beispiel #30
0
 def description(self) -> str:
     """
     returns the description of the goal
     """
     color = colour_name(self.colour)
     return 'Player must aim for the largest "blob" of {}'.format(color)