players.py
def next_direction(self) -> Set[str]:
        """ Update the direction to move the next time self.move is called. This
        direction should be determined by the relative number of visible targets
        and enemies.
        This function considers the number of targets this player is moving
        towards and the number of enemies this player is moving away from and
        determines the direction to move towards most targets and away from most
        enemies.

        Return a set of all equally good directions to move towards.
        This method should call the names_in_range Tree method exactly twice.
        This method should set self._direction to a subset of:
        ('N', 'S', 'E', 'W')

        >>> player = Player('p0', 3, 1, 'Game (a valid game class)',\
        'purple', (50, 100))
        # Assume there are 2 targets and 3 enemies in the NE direction;
        # Assume there is 1 target and 2 enemies in the SE direction.
        # Assume <player> randomly chose to look in <'NE'> and <'SE'>
        >>> player.next_direction()
        {'W'}
        >>> player.__getattribute__('_direction')
        'W'
        """
        nw = []
        ne = []
        sw = []
        se = []
        directions = random.sample(['NE', 'SE', 'NE', 'SW'], 2)
        if 'NW' in directions:
            nw.extend(self._game.field.names_in_range(self._location, 'NW',
                                                      self._vision))
        if 'NE' in directions:
            ne.extend(self._game.field.names_in_range(self._location, 'NE',
                                                      self._vision))
        if 'SW' in directions:
            sw.extend(self._game.field.names_in_range(self._location, 'SW',
                                                      self._vision))
        if 'SE' in directions:
            se.extend(self._game.field.names_in_range(self._location, 'SE',
                                                      self._vision))
        n, w, s, e = self._help_next(nw, ne, sw, se)
        result = []
        if n == max(n, w, s, e):
            result.append('N')
        if w == max(n, w, s, e):
            result.append('W')
        if s == max(n, w, s, e):
            result.append('S')
        if e == max(n, w, s, e):
            result.append('E')
        self._direction = random.choice(result)
        return set(result)
 Update the direction to move the next time self.move is called. This
        direction should be determined by the relative number of visible targets
        and enemies.
        This function considers the number of targets this player is moving
        towards and the number of enemies this player is moving away from and
        determines the direction to move towards most targets and away from most
        enemies.

        Return a set of all equally good directions to move towards.
        This method should call the names_in_range Tree method exactly twice.
        This method should set self._direction to a subset of:
        ('N', 'S', 'E', 'W')

        >>> player = Player('p0', 3, 1, 'Game (a valid game class)',\
        'purple', (50, 100))
        # Assume there are 2 targets and 3 enemies in the NE direction;
        # Assume there is 1 target and 2 enemies in the SE direction.
        # Assume <player> randomly chose to look in <'NE'> and <'SE'>
        >>> player.next_direction()
        {'W'}
        >>> player.__getattribute__('_direction')
        'W'
        
Update the direction to move the next time self.move is called. This
direction should be determined by the relative number of visible targets
and enemies.
This function considers the number of targets this player is moving
towards and the number of enemies this player is moving away from and
determines the direction to move towards most targets and away from most
enemies.

Return a set of all equally good directions to move towards.
This method should call the names_in_range Tree method exactly twice.


Update the direction to move the next time self . move is called . This direction should be determined by the relative number of visible targets and enemies . This function considers the number of targets this player is moving towards and the number of enemies this player is moving away from and determines the direction to move towards most targets and away from most enemies . Return a set of all equally good directions to move towards . This method should call the names_in_range Tree method exactly twice .
def next_direction(self) -> Set[str]:
        nw = []
        ne = []
        sw = []
        se = []
        directions = random.sample(['NE', 'SE', 'NE', 'SW'], 2)
        if 'NW' in directions:
            nw.extend(self._game.field.names_in_range(self._location, 'NW',
                                                      self._vision))
        if 'NE' in directions:
            ne.extend(self._game.field.names_in_range(self._location, 'NE',
                                                      self._vision))
        if 'SW' in directions:
            sw.extend(self._game.field.names_in_range(self._location, 'SW',
                                                      self._vision))
        if 'SE' in directions:
            se.extend(self._game.field.names_in_range(self._location, 'SE',
                                                      self._vision))
        n, w, s, e = self._help_next(nw, ne, sw, se)
        result = []
        if n == max(n, w, s, e):
            result.append('N')
        if w == max(n, w, s, e):
            result.append('W')
        if s == max(n, w, s, e):
            result.append('S')
        if e == max(n, w, s, e):
            result.append('E')
        self._direction = random.choice(result)
        return set(result)
def next_direction ( self ) -> Set [ str ] : nw = [ ] ne = [ ] sw = [ ] se = [ ] directions = random . sample ( [ 'NE' , 'SE' , 'NE' , 'SW' ] , 2 ) if 'NW' in directions : nw . extend ( self . _game . field . names_in_range ( self . _location , 'NW' , self . _vision ) ) if 'NE' in directions : ne . extend ( self . _game . field . names_in_range ( self . _location , 'NE' , self . _vision ) ) if 'SW' in directions : sw . extend ( self . _game . field . names_in_range ( self . _location , 'SW' , self . _vision ) ) if 'SE' in directions : se . extend ( self . _game . field . names_in_range ( self . _location , 'SE' , self . _vision ) ) n , w , s , e = self . _help_next ( nw , ne , sw , se ) result = [ ] if n == max ( n , w , s , e ) : result . append ( 'N' ) if w == max ( n , w , s , e ) : result . append ( 'W' ) if s == max ( n , w , s , e ) : result . append ( 'S' ) if e == max ( n , w , s , e ) : result . append ( 'E' ) self . _direction = random . choice ( result ) return set ( result )
Update the direction to move the next time self.move is called.
Update the direction to move the next time self . move is called .
""" Update the direction to move the next time self.move is called. This
        direction should be determined by the relative number of visible targets
        and enemies.
        This function considers the number of targets this player is moving
        towards and the number of enemies this player is moving away from and
        determines the direction to move towards most targets and away from most
        enemies.

        Return a set of all equally good directions to move towards.
        This method should call the names_in_range Tree method exactly twice.
        This method should set self._direction to a subset of:
        ('N', 'S', 'E', 'W')

        >>> player = Player('p0', 3, 1, 'Game (a valid game class)',\
        'purple', (50, 100))
        # Assume there are 2 targets and 3 enemies in the NE direction;
        # Assume there is 1 target and 2 enemies in the SE direction.
        # Assume <player> randomly chose to look in <'NE'> and <'SE'>
        >>> player.next_direction()
        {'W'}
        >>> player.__getattribute__('_direction')
        'W'
        """
self