Count the number of extra actions for player in this turn.
425161
def _count_extra_actions(self, game_image):
        """"""
        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)
515488
def imperative_move
      # if we can win *this turn*, then take it because
      # it rates winning next turn the same as winning in 3 turns
      game.available_moves.each do |move|
        new_game = game.pristine_mark move
        return move if new_game.over? && new_game.winner == player_number
      end
      
      # if we can block the opponent from winning *this turn*, then take it, because
      # it rates losing this turn the same as losing in 3 turns
      if moves_by_rating.all? { |move, rating, game| rating == -1 }
        Game.winning_states do |position1, position2, position3|
          a, b, c = board[position1-1, 1].to_i, board[position2-1, 1].to_i, board[position3-1, 1].to_i
          if a + b + c == opponent_number * 2
            return a.zero? ? position1 : b.zero? ? position2 : position3
          end
        end
      end
    end
1079147
def number_of_interactions(records, direction=None):
    
    if direction is None:
        return len(records)
    else:
        return len([r for r in records if r.direction == direction])
460704
def increment(handler, increment, item_id, counter_name):
    """"""
    data = {'operation': 'increment_counter',
            'id': item_id,
            'counter_name': counter_name,
            'increment': increment}
    handler.invoke(data)
1343931
def perform_action(
            self, action, machines, params, progress_title, success_title):
        """"""
        if len(machines) == 0:
            return 0
        with utils.Spinner() as context:
            return self._async_perform_action(
                context, action, list(machines), params,
                progress_title, success_title)
498352
function (extraPoints) {
		var points = this._getProjectedPoints(),
			len = points ? points.length : 0;
		// Increment length by extraPoints if present
		len += extraPoints || 0;

		return !points || len <= 3;
	}
670738
function (playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options) 
    {
        // If exactComposition isn't set, no override
        if (options.strategyComplexity != "exactComposition")
        {
            return null;
        }

        // Now look at strategies based on game options
        if ((options.numberOfDecks == 2) && (!options.hitSoft17)) 
        {
            return TwoDeckStandSoft17(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options);
        }
    }
648900
def count(self):
        
        actions = self._actionGroup.actions()
        if len(actions) == 1 and actions[0].objectName() == 'place_holder':
            return 0
        
        return len(actions)
1200954
def get_playcount(self):
        """"""

        return _number(
            _extract(
                self._request(self.ws_prefix + ".getInfo", cacheable=True), "playcount"
            )
        )
193583
def update(self, play):
        
        new_tally = { }
        #if any(isinstance(play.event, te) for te in self.trigger_event_types):
        if self._count_play(play):
            # the team who made the play / triggered the event
    
            team = self._get_team(play)

            try:
                self.total[team] += 1
            except:
                self.total[team] = 1
                self.teams.append(team)
                for i in range(len(self.tally)):
                    self.tally[i][team] = 0
      
            try:
                new_tally = { k:v for k,v in self.tally[len(self.tally)-1].items() }
                new_tally['period'] = play.period
                new_tally['time'] = play.time
                new_tally[team] += 1
                new_tally['play'] = play
            except:
                new_tally = {
                    'period': play.period,
                    'time': play.time,
                    team: 1,
                    'play': play
                }
      
            self.tally.append(new_tally)
      
        return new_tally
708307
def count_by_value_impl(sequence):
    
    counter = collections.Counter()
    for e in sequence:
        counter[e] += 1
    return six.viewitems(counter)
594354
def step(self, action):
    """"""
    # Special codes
    if action in self._player_actions():
      envs_step_tuples = self._player_actions()[action]()
    elif self._wait and action == self.name_to_action_num["NOOP"]:
      # Ignore no-op, do not pass to environment.
      envs_step_tuples = self._last_step_tuples
    else:
      # Run action on environment(s).
      if action == self.WAIT_MODE_NOOP_ACTION:
        action = self.name_to_action_num["NOOP"]
      # Perform action on underlying environment(s).
      envs_step_tuples = self._step_envs(action)
      self._update_statistics(envs_step_tuples)

    self._last_step_tuples = envs_step_tuples
    ob, reward, done, info = self._player_step_tuple(envs_step_tuples)
    return ob, reward, done, info
462529
public void tally(RunnerStatistics other) {
        rightCount += other.rightCount();
        wrongCount += other.wrongCount();
        skippedCount += other.skippedCount();
        totalCount += other.totalCount();
    }
19198
function (hands, table, dead) {
		// Preprocesses the input data.
		table = table ? _.map(table, getCode) : [];
		dead = dead ? _.map(dead, getCode) : [];
		hands = _.map(hands, function (hand) {
			return _.map(hand, getCode);
		});
		var res = deckSize + 1;
		for (var c = 0; c < table.length; c++)
			res = evaluator[res + table[c]];
		var deck = _.chain(_.range(1, deckSize + 1)).difference(table)
				.difference(_.flatten(hands)).difference(dead).value();
		var player = _.map(hands, function (hand) {
			return evaluator[evaluator[res + hand[0]] + hand[1]];
		});
		var combinations = function (n, k, res, callback) {
			if (k <= 0) {
				callback(res);
			} else {
				while (n < deck.length) {
					var parcial = evaluator[res + deck[n++]];
					combinations(n, k - 1, parcial, callback);
				}
			}
		};
		
		// Calculates the outcome of each play.
		var remaining = 5 - table.length;
		var plays = deck.length / remaining;
		for (var c = 1; c < remaining; c++)
			plays *= (deck.length - c) / c;
		var values = new Array(hands.length);
		for (var p = 0; p < hands.length; p++) {
			var s = 0;
			values[p] = new Int32Array(plays);
			combinations(0, remaining, player[p], function (res) {
				values[p][s++] = res;
			});
		}
		
		// Determines the results.
		var wins = new Int32Array(hands.length);
		var splits = new Int32Array(hands.length);
		for (var s = 0; s < plays; s++) {
			var winner = [0];
			for (var p = 1; p < hands.length; p++) {
				if (values[p][s] > values[winner[0]][s])
					winner = [p];
				else if (values[p][s] == values[winner[0]][s])
					winner.push(p);
			}
			if (winner.length == 1) {
				wins[winner[0]]++;
			} else {
				for (var p = 0; p < winner.length; p++)
					splits[winner[p]]++;
			}
		}
		
		// Formats odds output.
		var odds = [];
		for (var p = 0; p < hands.length; p++)
			odds[p] = {win: wins[p] / plays, split: splits[p] / plays};
		return odds;
	}
148944
def count_row(engine, table):
    
    return engine.execute(select([func.count()]).select_from(table)).fetchone()[0]
1358857
def GameActionModeEnum(ctx):
    """"""
    return Enum(
        ctx,
        diplomacy=0,
        speed=1,
        instant_build=2,
        quick_build=4,
        allied_victory=5,
        cheat=6,
        unk0=9,
        spy=10,
        unk1=11,
        farm_queue=13,
        farm_unqueue=14,
        default=Pass
    )
843009
function getPlayerPlays(player, game) {
  // Shuffle so that equal-weighted players aren't
  // always prioritized by their turn order
  return Util.shuffle(game.players)
    .reduce((plays, target) => {
      if (player === target) {
        return plays
      }
      return plays.concat(
        player.hand
          .map((card) => {
            return card.validPlays ? card.validPlays(player, target, game) : []
          })
          .reduce((acc, array) => {
            return acc.concat(array)
          }, [])
      )
    }, [])
    .sort((playA, playB) => playB.weight - playA.weight)
}