Trainer only command.
Recovers the players stamina, recovery, effort and hear capacity to the values at the beginning of the game.
427851
public void addRecoverCommand() {
        StringBuilder buf = new StringBuilder();
        buf.append("(recover)");
        fifo.add(fifo.size(), buf.toString());
    }
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
169844
protected function run()
    {
        $pack = $this->rec->getResourcePack();
        $this->version = $this->get(VersionAnalyzer::class);
        $version = $this->version;

        $players = $this->get(PlayerMetaAnalyzer::class);

        // The player number is used for chat messages.
        $playersByNumber = [];
        // The player index is used for game actions.
        $playersByIndex = [];
        foreach ($players as $player) {
            $playersByNumber[$player->number] = $player;
            $playersByIndex[$player->index] = $player;
        }

        $this->playersByNumber = $playersByNumber;

        $size = strlen($this->body);

        $this->position = 0;
        if ($version->isMgl) {
            $this->processGameStart();
        }

        while ($this->position < $size - 3) {
            $operationType = $this->readBody('l', 4);

            if ($operationType === self::OP_CHAT) {
                // AoC and up store the game start message with the same ID
                // as a CHAT message, but chat messages are prefixed with 0xFFFF_FFFF
                $syncChecksumInterval = $this->readBody('l', 4);
                if ($syncChecksumInterval === -1) {
                    $this->processChatMessage();
                } else {
                    $this->position -= 4;
                    $this->processGameStart();
                }
            } else if ($operationType === self::OP_SYNC) {
                $this->syncIndex++;
                // There are a lot of sync packets, so we get a significant
                // speedup just from doing this inline (and not in a separate
                // method), and by using `unpack` and manual position increments
                // instead of `readBody`.
                $data = unpack('l2', substr($this->body, $this->position, 8));
                $this->currentTime += $data[1]; // $this->readBody('l', 4);
                if ($this->syncIndex === $this->syncChecksumInterval) {
                    // no need to parse checksums
                    $this->position += 28;
                }
            } else if ($operationType === self::OP_VIEWLOCK) {
                // just skip for now
                $this->position += 12;
            } else if ($operationType === self::OP_COMMAND) {
                $length = $this->readBody('l', 4);
                $next = $this->position + $length;
                $command = ord($this->body[$this->position]);
                $this->position++;

                switch ($command) {
                    // player resign
                    case self::COMMAND_RESIGN:
                        $playerIndex = ord($this->body[$this->position]);
                        $playerNumber = ord($this->body[$this->position + 1]);
                        $disconnected = ord($this->body[$this->position + 2]);
                        $this->position += 3;
                        $player = $playersByIndex[$playerIndex];
                        if ($player && $player->resignTime === 0) {
                            $player->resignTime = $this->currentTime;
                            $message = sprintf('%s resigned', $player->name);
                            $this->chatMessages[] = new ChatMessage($this->currentTime, null, $message);
                        }
                        break;
                    // researches
                    case self::COMMAND_RESEARCH:
                        $this->position += 3;
                        $buildingId = $this->readBody('l', 4);
                        $playerId = $this->readBody('v', 2);
                        $researchId = $this->readBody('v', 2);
                        $player = $playersByIndex[$playerId];
                        if (!$player) {
                            break;
                        }

                        switch ($researchId) {
                            case self::RESEARCH_FEUDAL:
                                $researchDuration = 130000;
                                $player->feudalTime = $this->currentTime + $researchDuration;
                                break;
                            case self::RESEARCH_CASTLE:
                                // persians have faster research time
                                $researchDuration = 160000;
                                if ($player->civId === Civilization::PERSIANS) {
                                    $researchDuration /= 1.10;
                                }
                                $player->castleTime = $this->currentTime + round($researchDuration);
                                break;
                            case self::RESEARCH_IMPERIAL:
                                $researchDuration = 190000;
                                if ($player->civId === Civilization::PERSIANS) {
                                    $researchDuration /= 1.15;
                                }
                                $player->imperialTime = $this->currentTime + round($researchDuration);
                                break;
                        }
                        $player->addResearch($researchId, $this->currentTime);
                        break;
                    // training unit
                    case self::COMMAND_TRAIN:
                        $this->position += 3;
                        $buildingId = $this->readBody('l', 4);
                        $unitType = $this->readBody('v', 2);
                        $amount = $this->readBody('v', 2);

                        if (!isset($this->units[$unitType])) {
                            $this->units[$unitType] = $amount;
                        } else {
                            $this->units[$unitType] += $amount;
                        }
                        break;
                    // AI trains unit
                    case self::COMMAND_TRAIN_SINGLE:
                        $this->position += 9;
                        $unitType = $this->readBody('v', 2);
                        if (!isset($this->units[$unitType])) {
                            $this->units[$unitType] = 1;
                        } else {
                            $this->units[$unitType] += 1;
                        }
                        break;
                    // building
                    case self::COMMAND_BUILD:
                        $this->position += 1;
                        $playerId = $this->readBody('v', 2);
                        $this->position += 8;
                        $buildingType = $this->readBody('v', 2);

                        $buildingType = $pack->normalizeUnit($buildingType);

                        if (!isset($this->buildings[$playerId][$buildingType])) {
                            $this->buildings[$playerId][$buildingType] = 1;
                        } else {
                            $this->buildings[$playerId][$buildingType]++;
                        }
                        break;
                    // tributing
                    case self::COMMAND_TRIBUTE:
                        $playerIdFrom = ord($this->body[$this->position++]);
                        $playerIdTo = ord($this->body[$this->position++]);
                        $resourceId = ord($this->body[$this->position++]);

                        $playerFrom = $playersByIndex[$playerIdFrom];
                        $playerTo = $playersByIndex[$playerIdTo];

                        if ($playerFrom && $playerTo) {
                            $amount = $this->readBody('f', 4);
                            $marketFee = $this->readBody('f', 4);

                            $tribute = new Tribute();
                            $tribute->time = $this->currentTime;
                            $tribute->playerFrom = $playerFrom;
                            $tribute->playerTo = $playerTo;
                            $tribute->resourceId = $resourceId;
                            $tribute->amount = floor($amount);
                            $tribute->fee = $marketFee;
                            $this->tributes[] = $tribute;
                        } else {
                            $this->position += 8;
                        }
                        break;
                    // multiplayer postgame data in UP1.4 RC2+
                    case self::COMMAND_POSTGAME:
                        $this->postGameData = $this->read(PostgameDataAnalyzer::class);
                        break;
                    default:
                        break;
                }

                $this->position = $next;
            }
        }

        if (!empty($this->chatMessages)) {
            usort($this->chatMessages, function ($a, $b) {
                return $a->time - $b->time;
            });
        }

        if (!empty($this->buildings)) {
            ksort($this->buildings);
        }

        $analysis = new \StdClass;
        $analysis->duration = $this->currentTime;
        $analysis->tributes = $this->tributes;
        $analysis->chatMessages = $this->chatMessages;
        $analysis->units = $this->units;
        $analysis->buildings = $this->buildings;
        $analysis->postGameData = $this->postGameData;

        return $analysis;
    }
72937
def player
      PLAYERS.each do |player|
        player_load(player) || next

        instance = player_class(player).new
        player_on_platform?(instance) || next

        return instance if player_launched?(instance)
      end
      nil
    end
532738
def cmd(send, _, args):
    
    if args['target'] == 'private':
        send("You're all alone!")
        return
    with args['handler'].data_lock:
        channel = args['handler'].channels[args['target']]
        voiced = len([x for x in args['handler'].voiced[args['target']].values() if x])
        total = len(channel.users())
    send("%d active users, %d total users, %g%% active" % (voiced, total, voiced / total * 100))
736366
def last_round
      last_round = 0
      @player.values.each do |p|
        p.results.each do |r|
          last_round = r.round if r.round > last_round
        end
      end
      last_round
    end
315302
private function determineOutcome()
    {
        $outcome = [];
        
        $players = $this->getPlayers();
        $opponents = $players;

        if ($players === false) {
            return false;
        }

        foreach ($players as $player) {
        
            foreach ($opponents as $opponent) {
    
                // dont play the player against themself
                if ($player->getId() === $opponent->getId())
                {
                    continue;
                }

                // move collection
                $player_move = $player->getLastMoveIndex();
                $opponent_move = $opponent->getLastMoveIndex();

                // verify moves have been set
                if (!is_array($player_move)) {
                    throw new RockPaperScissorsSpockLizardException($player->getName() . ' has not set a move!');
                }

                if (!is_array($opponent_move)) {
                    throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' has not set a move!');
                }

                // move labels
                $player_move_label = ucfirst(key($player_move));
                $opponent_move_label = ucfirst(key($opponent_move));

                // map moves to an index
                $player_move_index = $this->getMoveIndex($player_move);
                $opponent_move_index = $this->getMoveIndex($opponent_move);

                // Exceptions
                if (!is_numeric($player_move_index)) {
                    throw new RockPaperScissorsSpockLizardException($player->getName() . ' made an illegal move!');
                }

                if (!is_numeric($opponent_move_index)) {
                    throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' made an illegal move!');
                }

                if (current($player_move) === true) {
                    throw new RockPaperScissorsSpockLizardException($player->getName() . ' has already made this move!');
                }

                if (current($opponent_move) === true) {
                    throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' has already made this move!');
                }

                // compare player with opponent
                if (isset($this->move_outcomes[$player_move_index][$opponent_move_index])) {
                    $outcome['winners'][] = [
                        'player' => $player,
                        'opponent' => $opponent,
                        'description' => $player_move_label . ' ' . $this->move_outcomes[$player_move_index][$opponent_move_index] . ' ' . $opponent_move_label
                    ];
                    $outcome['losers'][] = [
                        'player' => $opponent,
                        'opponent' => $player,
                        'description' => $player_move_label . ' ' . $this->move_outcomes[$player_move_index][$opponent_move_index] . ' ' . $opponent_move_label
                    ];
                } else if (isset($this->move_outcomes[$opponent_move_index][$player_move_index])) {
                    // dont do anything -- we just need to check this in order to determine whether a tie needs to be calculated
                } else {
                    // we just add the tie for the player since the opponent will be added to the ties on later iteration
                    $outcome['ties'][] = [
                        'player' => $player,
                        'opponent' => $opponent,
                        'description' => 'Both played ' . $player_move_label
                    ];
                }
            }
        }

        // mark last moves as played
        foreach ($players as $player) {
            $player->lastMoveIsPlayed();
        }
        
        $this->setOutcome($outcome);
        
        return $this->getRoundOutcome();
    }
1348974
function restartGame(players) {
    // Replace the current instance with a new instance
    let newGame = new RockPaperScissors(game, players, winCounter, id);
    proxy.swap(newGame);

    q.delay(RESULTS_DELAY)
      .done(function() {
        deferred.resolve(newGame.handleIt(callbacks));
      });
  }
117104
def reset(self):
        
        info = self._env.reset()[self.brain_name]
        n_agents = len(info.agents)
        self._check_agents(n_agents)
        self.game_over = False

        if not self._multiagent:
            obs, reward, done, info = self._single_step(info)
        else:
            obs, reward, done, info = self._multi_step(info)
        return obs
364347
def _set_trainer(self, trainer):
        
        # trainer cannot be replaced for sparse params
        if self._stype != 'default' and self._trainer and trainer and self._trainer is not trainer:
            raise RuntimeError(
                "Failed to set the trainer for Parameter '%s' because it was already set. " \
                "More than one trainers for a %s Parameter is not supported." \
                %(self.name, self._stype))
        self._trainer = trainer
360178
def reset_game(self):
        """"""
        self.ms_game.reset_game()
        self.update_grid()
        self.time = 0
        self.timer.start(1000)
74754
private void deliverFaderStartCommand(Set<Integer> playersToStart, Set<Integer> playersToStop) {
        for (final FaderStartListener listener : getFaderStartListeners()) {
            try {
                listener.fadersChanged(playersToStart, playersToStop);
            } catch (Throwable t) {
                logger.warn("Problem delivering fader start command to listener", t);
            }
        }
    }
614861
def _set_player(self):
        
        players = []
        for name, p in self._mpris_players.items():
            # we set the priority here as we need to establish the player name
            # which might not be immediately available.
            if "_priority" not in p:
                if self.player_priority:
                    try:
                        priority = self.player_priority.index(p["name"])
                    except ValueError:
                        try:
                            priority = self.player_priority.index("*")
                        except ValueError:
                            priority = None
                else:
                    priority = 0
                if priority is not None:
                    p["_priority"] = priority
            if p.get("_priority") is not None:
                players.append((p["_state_priority"], p["_priority"], p["index"], name))
        if players:
            top_player = self._mpris_players.get(sorted(players)[0][3])
        else:
            top_player = {}

        self._player = top_player.get("_dbus_player")
        self._player_details = top_player

        self.py3.update()
312046
def add_result(round, player, opponent, score)
      n1 = player.is_a?(ICU::RatedPlayer) ? player.num : player.to_i
      n2 = opponent.is_a?(ICU::RatedPlayer) ? opponent.num : opponent.to_i
      p1 = @player[n1] || raise("no such player number (#{n1})")
      p2 = @player[n2] || raise("no such player number (#{n2})")
      r1 = ICU::RatedResult.new(round, p2, score)
      r2 = ICU::RatedResult.new(round, p1, r1.opponents_score)
      p1.add_result(r1)
      p2.add_result(r2)
      nil
    end
311949
def empty(cls: Type[BoardT], *, chess960: bool = False) -> BoardT:
        """"""
        return cls(None, chess960=chess960)
349286
def train(*tf_records: "Records to train on"):
    """"""
    tf.logging.set_verbosity(tf.logging.INFO)
    estimator = dual_net.get_estimator()

    effective_batch_size = FLAGS.train_batch_size
    if FLAGS.use_tpu:
        effective_batch_size *= FLAGS.num_tpu_cores

    if FLAGS.use_tpu:
        if FLAGS.use_bt:
            def _input_fn(params):
                games = bigtable_input.GameQueue(
                    FLAGS.cbt_project, FLAGS.cbt_instance, FLAGS.cbt_table)
                games_nr = bigtable_input.GameQueue(
                    FLAGS.cbt_project, FLAGS.cbt_instance, FLAGS.cbt_table + '-nr')
                return preprocessing.get_tpu_bt_input_tensors(
                    games,
                    games_nr,
                    params['batch_size'],
                    number_of_games=FLAGS.window_size,
                    random_rotation=True)
        else:
            def _input_fn(params):
                return preprocessing.get_tpu_input_tensors(
                    params['batch_size'],
                    tf_records,
                    random_rotation=True)
        # Hooks are broken with TPUestimator at the moment.
        hooks = []
    else:
        def _input_fn():
            return preprocessing.get_input_tensors(
                FLAGS.train_batch_size,
                tf_records,
                filter_amount=FLAGS.filter_amount,
                shuffle_buffer_size=FLAGS.shuffle_buffer_size,
                random_rotation=True)

        hooks = [UpdateRatioSessionHook(FLAGS.work_dir),
                 EchoStepCounterHook(output_dir=FLAGS.work_dir)]

    steps = FLAGS.steps_to_train
    logging.info("Training, steps = %s, batch = %s -> %s examples",
                 steps or '?', effective_batch_size,
                 (steps * effective_batch_size) if steps else '?')

    if FLAGS.use_bt:
        games = bigtable_input.GameQueue(
            FLAGS.cbt_project, FLAGS.cbt_instance, FLAGS.cbt_table)
        if not games.read_wait_cell():
            games.require_fresh_games(20000)
        latest_game = games.latest_game_number
        index_from = max(latest_game, games.read_wait_cell())
        print("== Last game before training:", latest_game, flush=True)
        print("== Wait cell:", games.read_wait_cell(), flush=True)

    try:
        estimator.train(_input_fn, steps=steps, hooks=hooks)
        if FLAGS.use_bt:
            bigtable_input.set_fresh_watermark(games, index_from,
                                               FLAGS.window_size)
    except:
        if FLAGS.use_bt:
            games.require_fresh_games(0)
        raise
770486
function getGameAfterMoves(game, moves) {
    return moves.reduce(function (lastGame, move) {
        return getGameAfterMove(lastGame, move);
    }, game);
}