Generate Moves For Bots
@return $this
494669
private function generateMovesForBots()
    {
        foreach ($this->getPlayers() as &$player) {

            $last_move = $player->getLastMoveIndex();

            // generate move for bots
            if ($player->isBot() && empty($last_move)) {
                $move = $this->generateMove();
                $player->move($move);
            }
        }
        
        return $this;
    }
428428
public function timerEndAction()
    {
        $this->timerAction('end');
        // And we are done. Feedback to the user.
        $miniBench = $this->miniBenchTo(static::$timekeeping);
        $this->pool->createClass('Brainworxx\\Krexx\\Controller\\DumpController')
            ->dumpAction($miniBench, 'kreXX timer');
        // Reset the timer vars.
        static::$timekeeping = array();
        static::$counterCache = array();

        return $this;
    }
200310
public function shuffle()
    {
        $keys = array_keys($this->items);
        shuffle($keys);

        $new = [];
        foreach ($keys as $key) {
            $new[$key] = $this->items[$key];
        }

        $this->items = $new;

        return $this;
    }
577665
public function batchActions()
    {
        $actions = static::registeredActions();
        $recordClass = $this->recordClass;
        $actions = array_filter($actions, function ($action) use ($recordClass) {
            return $action['recordClass'] === $recordClass;
        });
        return $actions;
    }
711575
public function addActions(array $actions)
    {
        collect($actions)->each(function ($action) {
            $this->addAction($action);
        });

        return $this;
    }
1024948
protected function createExampleSteps()
    {
        $steps = array();
        foreach ($this->outlineSteps as $outlineStep) {
            $keyword = $outlineStep->getKeyword();
            $keywordType = $outlineStep->getKeywordType();
            $text = $this->replaceTextTokens($outlineStep->getText());
            $args = $this->replaceArgumentsTokens($outlineStep->getArguments());
            $line = $outlineStep->getLine();

            $steps[] = new StepNode($keyword, $text, $args, $line, $keywordType);
        }

        return $steps;
    }
178895
protected function makeRanking () : void
    {       
        $result = [];

        // Calculate ranking
        $done = array ();
        $rank = 1;

        while (count($done) < $this->_selfElection->countCandidates()) :
            $to_done = [];

            foreach ( $this->_StrongestPaths as $candidate_key => $challengers_key ) :
                if ( in_array($candidate_key, $done, true) ) :
                    continue;
                endif;

                $winner = true;

                foreach ($challengers_key as $beaten_key => $beaten_value) :
                    if ( in_array($beaten_key, $done, true) ) :
                        continue;
                    endif;

                    if ( $beaten_value < $this->_StrongestPaths[$beaten_key][$candidate_key] ) :
                        $winner = false;
                    endif;
                endforeach;

                if ($winner) :
                    $result[$rank][] = $candidate_key;

                    $to_done[] = $candidate_key;
                endif;
            endforeach;

            $done = array_merge($done, $to_done);

            $rank++;
        endwhile;

        $this->_Result = $this->createResult($result);
    }
572632
public function setMoves($moves)
  {
    $moves = trim($moves);

    $this->moves = $moves;
    $this->movesCount = count(explode(' ', $moves));
  }
889066
public function copyAction()
    {
        $trackId    = $this->_getIdParam();
        $engine     = $this->getTrackEngine();
        $newTrackId = $engine->copyTrack($trackId);

        $this->_reroute(array('action' => 'edit', \MUtil_Model::REQUEST_ID => $newTrackId));
    }
1277277
public function batchActions()
    {
        $actions = [RemoveSelected::class];

        if ($this->module->model() instanceof Rankable) {
            array_push($actions, SaveOrder::class);
        }

        return $actions;
    }
128284
public function getBotMessages()
    {
        return Collection::make($this->getDriver()->getMessages())->filter(function (IncomingMessage $message) {
            return $message->isFromBot();
        })->toArray();
    }
1234854
public function withoutDuplicates(): self
    {
        if (count($this->pairs) === count(array_count_values(array_column($this->pairs, 0)))) {
            return $this;
        }

        $pairs = array_reduce($this->pairs, [$this, 'removeDuplicates'], []);
        if ($pairs === $this->pairs) {
            return $this;
        }

        $clone = clone $this;
        $clone->pairs = $pairs;

        return $clone;
    }
1011981
public function setUpperLimitMst()
    {
        $alg = new AlgorithmTspMst($this->graph);
        $this->upperLimit = $alg->getWeight();

        return $this;
    }
633804
protected function defineStrategyHandlers() {
		if(!$this->_strategiesDefined) {
			foreach($this->getStrategies() as $strategyClass) {
				$strategyMethod = 'handleStrategy' . $strategyClass;
				$this->addWrapperMethod($strategyMethod, 'handleStrategy');
			}
			$this->_strategiesDefined = true;
		}
	}
859836
public function copy(): self
    {
        $arguments = [];

        foreach ($this->arguments as $argument) {
            $arguments[] = $argument;
        }

        return new self($arguments);
    }
627634
public function applyRulesets()
    {
        // List of fields which actually need validation at this time.
        $fields = $this->getActualFields();

        foreach ($fields as $field) {
            $rulesets = $this->getRules($field);
            $this->active_field = $field;
            $this->prefix = '';
            $this->caption = '';
            foreach ($rulesets as $rules) {
                $this->applyRules($field, $rules);
            }
        }

        return $this;
    }
468859
def bota_gorda(game):
    '''
    
    '''
    game.valid_moves = tuple(sorted(game.valid_moves, key=lambda m: -(m[0].first + m[0].second)))