Get the next 200 tournaments from pokerstars.
483610
def get_current_tournaments():
    """"""

    schedule_page = requests.get(TOURNAMENTS_XML_URL)
    root = etree.XML(schedule_page.content)

    for tour in root.iter('{*}tournament'):
        yield _Tournament(
            start_date=tour.findtext('{*}start_date'),
            name=tour.findtext('{*}name'),
            game=tour.findtext('{*}game'),
            buyin=tour.findtext('{*}buy_in_fee'),
            players=tour.get('players')
        )
1042486
private function resetBetStacks()
    {
        $this->players()->each(function (PlayerContract $player) {
            $this->betStacks->put($player->name(), Chips::zero());
        });
    }
1200900
def tournament(self,individuals,tourn_size, num_selections=None):
        """"""
        winners = []
        locs = []
        if num_selections is None:
            num_selections = len(individuals)

        for i in np.arange(num_selections):
            # sample pool with replacement
            pool_i = self.random_state.choice(len(individuals),size=tourn_size)
            pool = []
            for i in pool_i:
                pool.append(np.mean(individuals[i].fitness))
            # winner
            locs.append(pool_i[np.argmin(pool)])
            winners.append(copy.deepcopy(individuals[locs[-1]]))

        return winners,locs
565632
def staking_leaderboard(round_num=0, tournament=1):
    """"""
    click.echo(prettify(napi.get_staking_leaderboard(tournament=tournament,
                                                     round_num=round_num)))
22473
public function start()
    {
        if ($this->state != 'pending') {
            throw new AlreadyStartedException('Tournament is already underway.');
        }

        $response = Guzzle::post("tournaments/{$this->id}/start");
        return $this->updateModel($response->tournament);
    }
560910
def get_next_rngruns(self):
        
        available_runs = [result['params']['RngRun'] for result in
                          self.get_results()]
        yield from DatabaseManager.get_next_values(available_runs)
556414
def create(tournament, name, **params):
    """"""
    params.update({"name": name})

    return api.fetch_and_parse(
        "POST",
        "tournaments/%s/participants" % tournament,
        "participant",
        **params)
1261193
def _run(self, strategy, parameters=None):
        '''
        
        '''

        choice = self.run_strategy(strategy, parameters)
        self.choices.append(choice)
        payout = self.bandits.pull(choice)
        if payout is None:
            print('Trials exhausted. No more values for bandit', choice)
            return None
        else:
            self.wins[choice] += payout
        self.pulls[choice] += 1
706954
private Events<Event> getEvents(CanalEventStore eventStore, Position start, int batchSize, Long timeout,
                                    TimeUnit unit) {
        if (timeout == null) {
            return eventStore.tryGet(start, batchSize);
        } else {
            try {
                if (timeout <= 0) {
                    return eventStore.get(start, batchSize);
                } else {
                    return eventStore.get(start, batchSize, timeout, unit);
                }
            } catch (Exception e) {
                throw new CanalServerException(e);
            }
        }
    }
937001
def get_ladder_matches(session, ladder_id, from_timestamp=None, limit=LADDER_MATCH_LIMIT):
    """"""
    if not from_timestamp:
        from_timestamp = datetime.datetime.now() - datetime.timedelta(days=1)
    matches = []
    page_id = 0
    done = False
    i = 0
    while not done and page_id < MAX_LADDER_PAGE_ID:
        url = '{}{}/{}/{}'.format(session.auth.base_url, LADDER_MATCHES_URL, lookup_ladder_id(ladder_id), page_id)
        parsed = make_scrape_request(session, url)
        for row in parsed.find(text='Recent Matches').find_next('table').find_all('tr')[1:]:
            cols = row.find_all('td')
            played_at = dateparser.parse(cols[0].text)
            match_id = int(cols[1].find('a').text[1:])
            has_rec = cols[4].find('a').find('img')
            if not has_rec:
                continue
            if played_at < from_timestamp or i >= limit:
                done = True
                break
            matches.append({
                'timestamp': played_at,
                'match_id': match_id
            })
            i += 1
        page_id += 1
    return matches
996816
function () {
            return function () {
                return casper.wait(200)
                    .waitFor(function () {
                        var remainingAjaxRequests = this.evaluate(function () {
                            var amount = 0;

                            try {
                                amount = CMS.$.active;
                            } catch (e) {}

                            return amount;
                        });

                        return remainingAjaxRequests === 0;
                    }).wait(200);
            };
        }
1215560
def get_status():
    """"""

    res = requests.get(STATUS_URL)
    status = res.json()['tournaments']['summary']

    # move all sites under sites attribute, including play money
    sites = status.pop('site')
    play_money = status.pop('play_money')
    play_money['id'] = 'Play Money'
    sites.append(play_money)
    sites = tuple(_SiteStatus(**site) for site in sites)

    return _Status(sites=sites, updated=status.pop('updated'), **status)
620774
function TwoDeckStandSoft17(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options)
{
    var result;
    const overrides = [
            {hand:[4,6,6], dealer: 10, action: "hit"},
            {hand:[3,6,7], dealer: 10, action: "hit"},
            {hand:[2,6,8], dealer: 10, action: "hit"},
            {hand:[1,6,9], dealer: 10, action: "hit"},
            {hand:[3,3,10], dealer: 10, action: "hit"},
            {hand:[2,2,6,6], dealer: 10, action: "hit"},
            {hand:[1,3,6,6], dealer: 10, action: "hit"},
            {hand:[1,2,6,7], dealer: 10, action: "hit"},
            {hand:[1,1,6,8], dealer: 10, action: "hit"},
            {hand:[2,2,2,10], dealer: 10, action: "hit"},
            {hand:[1,2,3,10], dealer: 10, action: "hit"},
            {hand:[4,4,4,4], dealer: 9, action: "stand"},
            {hand:[3,4,4,5], dealer: 9, action: "stand"},
            {hand:[3,3,5,5], dealer: 9, action: "stand"},
            {hand:[2,4,5,5], dealer: 9, action: "stand"},
            {hand:[1,5,5,5], dealer: 9, action: "stand"},
            {hand:[2,2,3,3,6], dealer: 10, action: "hit"},
            {hand:[1,1,1,6,7], dealer: 10, action: "hit"},
            {hand:[1,1,2,2,10], dealer: 10, action: "hit"},
            {hand:[1,1,2,6,6], dealer: 10, action: "hit"},
            {hand:[1,3,4,4,4], dealer: 9, action: "stand"},
            {hand:[2,2,4,4,4], dealer: 9, action: "stand"},
            {hand:[2,3,3,4,4], dealer: 9, action: "stand"},
            {hand:[3,3,3,3,4], dealer: 9, action: "stand"},
            {hand:[1,2,3,5,5], dealer: 9, action: "stand"},
            {hand:[1,2,4,4,5], dealer: 9, action: "stand"},
            {hand:[1,3,3,4,5], dealer: 9, action: "stand"},
            {hand:[2,2,2,5,5], dealer: 9, action: "stand"}, 
            {hand:[2,2,3,4,5], dealer: 9, action: "stand"},
            {hand:[2,3,3,3,5], dealer: 9, action: "stand"},
            {hand:[1,1,1,1,4,4], dealer: 3, action: "stand"},
            {hand:[1,1,2,4,4,4], dealer: 7, action: "stand"},
            {hand:[1,1,3,3,4,4], dealer: 7, action: "stand"},
            {hand:[1,2,2,3,4,4], dealer: 7, action: "stand"},
            {hand:[1,2,3,3,3,4], dealer: 7, action: "stand"},
            {hand:[1,3,3,3,3,3], dealer: 7, action: "stand"},
            {hand:[2,2,2,3,3,4], dealer: 7, action: "stand"},
            {hand:[2,2,3,3,3,3], dealer: 7, action: "stand"},
            {hand:[1,3,3,3,3,3], dealer: 8, action: "stand"},
            {hand:[2,2,3,3,3,3], dealer: 8, action: "stand"},
            {hand:[1,3,3,3,3,3], dealer: 9, action: "stand"},
            {hand:[2,2,3,3,3,3], dealer: 9, action: "stand"},
            {hand:[1,1,2,4,4,4], dealer: 9, action: "stand"},
            {hand:[1,1,3,3,4,4], dealer: 9, action: "stand"},
            {hand:[1,2,2,3,4,4], dealer: 9, action: "stand"},
            {hand:[1,2,3,3,3,4], dealer: 9, action: "stand"},
            {hand:[2,2,2,2,4,4], dealer: 9, action: "stand"},
            {hand:[2,2,2,3,3,4], dealer: 9, action: "stand"},
            {hand:[1,1,1,3,5,5], dealer: 9, action: "stand"},
            {hand:[1,1,1,4,4,5], dealer: 9, action: "stand"},
            {hand:[1,1,2,2,5,5], dealer: 9, action: "stand"},
            {hand:[1,1,2,3,4,5], dealer: 9, action: "stand"},
            {hand:[1,1,3,3,3,5], dealer: 9, action: "stand"},
            {hand:[1,2,2,2,4,5], dealer: 9, action: "stand"},
            {hand:[1,2,2,3,3,5], dealer: 9, action: "stand"},
            {hand:[2,2,2,2,3,5], dealer: 9, action: "stand"},
            {hand:[1,1,1,1,6,6], dealer: 10, action: "hit"},
            {hand:[1,2,2,2,3,6], dealer: 10, action: "hit"},
            {hand:[2,2,2,2,2,6], dealer: 10, action: "hit"},
        ];

    // Special case if there are two cards
    if (playerCards.length == 2)
    {
        if ((handValue.total == 11) && (dealerCard == 1) &&
            ((playerCards[0] == 2) || (playerCards[0] == 3) || (playerCards[0] == 8) || (playerCards[0] == 9)))
        {
            return "double";            
        }
        else if ((handValue.total == 12) && (dealerCard == 4) &&
                    ((playerCards[0] == 2) || (playerCards[0] == 10)))
        {
            return "hit";
        }
    }
    else // 3 or more cards
    {
        // Ace, Ace, 6 hits against dealer Ace
        if ((playerCards.length == 3) && (handValue.total == 18) && handValue.soft && (dealerCard == 1) &&
                    ((playerCards[0] == 6) || (playerCards[1] == 6) || (playerCards[2] == 6)))
        {
            return "hit";
        }
        else if ((playerCards.length == 6) || (handValue.total == 16))
        {
            result = FindExceptionInList(playerCards, dealerCard, overrides);
            if (result)
            {
                return result;
            }
        }
    
        // Three or more cards, 16 vs 10 stands and soft 18 vs Ace stands (except as noted in table which was already checked)
        if ((handValue.total == 16) && (dealerCard == 10))
        {
            return "stand";
        }
        if ((handValue.total == 18) && (handValue.soft) && (dealerCard == 1))
        {
            return "stand";
        }
    }

    return null;
 }
73847
def staking_cutoff(round_num, tournament):
    """"""
    click.echo(prettify(napi.get_staking_cutoff(round_num, tournament)))
885868
function(widget, data) {
            var str;
            str = 'There are more players in this waiting room ' +
                'than playslots in the game. ';
            if (widget.poolSize === 1) {
                str += 'Each player will play individually.';
            }
            else {
                str += 'Only ' + data.nGames + ' players will be selected ' +
                    'to play the game.';
            }
            return str;
        }
1343514
def get_recent_matches(session, init_url, from_timestamp, limit):
    """"""
    if not from_timestamp:
        from_timestamp = datetime.datetime.now() - datetime.timedelta(days=1)
    matches = []
    page_id = 0
    done = False
    while not done and page_id < MAX_MATCH_PAGE_ID:
        url = '{}/{}'.format(init_url, page_id)
        parsed = make_scrape_request(session, url)
        for row in parsed.find('table').find_all('tr')[1:]:
            cols = row.find_all('td')
            played_at = dateparser.parse(cols[2].text)
            match_id = int(cols[5].find('a').text[1:])
            has_rec = cols[6].find('a').find('img')
            if played_at < from_timestamp or (limit and len(matches) == limit):
                done = True
                break
            if not has_rec:
                continue
            matches.append({
                'timestamp': played_at,
                'match_id': match_id
            })
        if not matches:
            break
        page_id += 1
    return matches
975700
public function finalize()
    {
        if ($this->state != 'awaiting_review') {
            throw new StillRunningException('Tournament is still running.');
        }

        $response = Guzzle::post("tournaments/{$this->id}/finalize");
        return $this->updateModel($response->tournament);
    }