def _count_extra_actions(self, game_image):
        """Count the number of extra actions for player in this turn."""
        proportional = self._bonus_tools['extra_action_region']
        # Use ProportionalRegion to isolate the extra actions area
        t, l, b, r = proportional.region_in(game_image)
        token_region = game_image[t:b, l:r]
        # Use TemplateFinder (multiple) to check for extra actions
        game_h, game_w = game_image.shape[0:2]
        token_h = int(round(game_h * 27.0 / 960))
        token_w = int(round(game_w * 22.0 / 1280))
        sizes = (token_h, token_w),
        # sizes change every time so just remake it.
        # thresholds are tight since need to count conservatively
        finder = v.TemplateFinder(pq_data.extra_action_template,
                                  sizes=sizes,
                                  acceptable_threshold=0.1,
                                  immediate_threshold=0.1)
        found_tokens = finder.locate_multiple_in(token_region)
        return len(found_tokens)
def _count_extra_actions ( self , game_image ) : proportional = self . _bonus_tools [ 'extra_action_region' ] t , l , b , r = proportional . region_in ( game_image ) token_region = game_image [ t : b , l : r ] game_h , game_w = game_image . shape [ 0 : 2 ] token_h = int ( round ( game_h * 27.0 / 960 ) ) token_w = int ( round ( game_w * 22.0 / 1280 ) ) sizes = ( token_h , token_w ) , finder = v . TemplateFinder ( pq_data . extra_action_template , sizes = sizes , acceptable_threshold = 0.1 , immediate_threshold = 0.1 ) found_tokens = finder . locate_multiple_in ( token_region ) return len ( found_tokens )
Count the number of extra actions for player in this turn.