Process the game start data.
489950
private function processGameStart()
    {
        $this->syncChecksumInterval = $this->readBody('l', 4);
        if ($this->version->isMgl) {
            // not sure what difference is vs mgx and up
            $this->position += 28;
            $ver = ord($this->body[$this->position]);
            $this->position += 4;
        } else {
            // These are also stored in the header.
            $isMultiplayer = $this->readBody('l', 4);
            $pov = $this->readBody('l', 4);
            $revealMap = $this->readBody('l', 4);
            $this->containsSequenceNumbers = $this->readBody('l', 4);
            $this->numberOfChapters = $this->readBody('l', 4);
        }
    }
612639
def run_game(load_file, selfplay_dir=None, holdout_dir=None,
             sgf_dir=None, holdout_pct=0.05):
    """"""
    if sgf_dir is not None:
        minimal_sgf_dir = os.path.join(sgf_dir, 'clean')
        full_sgf_dir = os.path.join(sgf_dir, 'full')
        utils.ensure_dir_exists(minimal_sgf_dir)
        utils.ensure_dir_exists(full_sgf_dir)
    if selfplay_dir is not None:
        utils.ensure_dir_exists(selfplay_dir)
        utils.ensure_dir_exists(holdout_dir)

    with utils.logged_timer("Loading weights from %s ... " % load_file):
        network = dual_net.DualNetwork(load_file)

    with utils.logged_timer("Playing game"):
        player = play(network)

    output_name = '{}-{}'.format(int(time.time()), socket.gethostname())
    game_data = player.extract_data()
    if sgf_dir is not None:
        with gfile.GFile(os.path.join(minimal_sgf_dir, '{}.sgf'.format(output_name)), 'w') as f:
            f.write(player.to_sgf(use_comments=False))
        with gfile.GFile(os.path.join(full_sgf_dir, '{}.sgf'.format(output_name)), 'w') as f:
            f.write(player.to_sgf())

    tf_examples = preprocessing.make_dataset_from_selfplay(game_data)

    if selfplay_dir is not None:
        # Hold out 5% of games for validation.
        if random.random() < holdout_pct:
            fname = os.path.join(holdout_dir,
                                 "{}.tfrecord.zz".format(output_name))
        else:
            fname = os.path.join(selfplay_dir,
                                 "{}.tfrecord.zz".format(output_name))

        preprocessing.write_tf_examples(fname, tf_examples)
271896
private function resetProcessData()
    {
        $this->starttime = null;
        $this->callback = null;
        $this->exitcode = null;
        $this->fallbackStatus = [];
        $this->processInformation = null;
        $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
        $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
        $this->process = null;
        $this->latestSignal = null;
        $this->status = self::STATUS_READY;
        $this->incrementalOutputOffset = 0;
        $this->incrementalErrorOutputOffset = 0;
    }
629656
def render(self, obs):
    """"""
    if not self._initialized:
      return
    now = time.time()
    self._game_times.append(
        (now - self._last_time,
         max(1, obs.observation.game_loop - self._obs.observation.game_loop)))
    self._last_time = now
    self._last_game_loop = self._obs.observation.game_loop
    self._obs_queue.put(obs)
    if self._render_sync:
      self._obs_queue.join()
1075953
def run(self, interval):
        """"""
        self._halt = False
        
        # TODO: some error checking to make sure valid paramenters are set
        if self.save_data:
            # initize data set
            self.current_dataset_name = self.set_name
            self.datafile.init_data(self.current_dataset_name, self.aitimes.shape, mode='open')
            self.set_name = increment_title(self.set_name)

        # save the start time and set last tick to expired, so first
        # acquisition loop iteration executes immediately
        self.start_time = time.time()
        self.last_tick = self.start_time - (interval/1000)
        self.interval = interval
        self.acq_thread = threading.Thread(target=self._worker)

        # arm the first read
        self.player.set_aochan(self.aochan)
        self.player.set_aichan(self.aichan)

        # make sure a signal is loaded
        self.reset_stim()
        
        # and go!
        self.acq_thread.start()

        return self.acq_thread
265813
private function ensureProcessIsStarted(): void
    {
        if (is_resource($this->process) === false) {
            $this->startProcess();

            $this->handleStartupErrors();
        }
    }
910884
def start_output (self):
        """"""
        super(GMLLogger, self).start_output()
        if self.has_part("intro"):
            self.write_intro()
            self.writeln()
        self.writeln(u"graph [")
        self.writeln(u"  directed 1")
        self.flush()
829381
def processData(self, times, response, test_num, trace_num, rep_num):
        """"""
        # invert polarity affects spike counting
        response = response * self._polarity

        if rep_num == 0:
            # reset
            self.spike_counts = []
            self.spike_latencies = []
            self.spike_rates = []

        fs = 1./(times[1] - times[0])

        # process response; calculate spike times
        spike_times = spikestats.spike_times(response, self._threshold, fs)
        self.spike_counts.append(len(spike_times))
        if len(spike_times) > 0:
            self.spike_latencies.append(spike_times[0])
        else:
            self.spike_latencies.append(np.nan)
        self.spike_rates.append(spikestats.firing_rate(spike_times, times))

        binsz = self._bins[1] - self._bins[0]
        response_bins = spikestats.bin_spikes(spike_times, binsz)
        # self.putnotify('spikes_found', (response_bins, rep_num))
        self.appendData(response_bins, rep_num)
88177
def start(self):
        """"""

        if self._started is True:
            raise ArgumentError("EmulationLoop.start() called multiple times")

        self._thread = threading.Thread(target=self._loop_thread_main)
        self._thread.start()
        self._started = True
681717
protected function process()
    {

        // add the SKU => entity ID/store view code mapping
        $this->addSkuEntityIdMapping($sku = $this->getValue(ColumnKeys::SKU));
        $this->addSkuStoreViewCodeMapping($sku, $this->getSubject()->getStoreViewCode(StoreViewCodes::ADMIN));

        // clean-up the repositories etc. to free memory
        $this->getProductBunchProcessor()->cleanUp();

        // temporary persist the SKU
        $this->setLastSku($sku);
    }
638871
private function start()
    {
        if (Arr::is_assoc($this->data)) {
            $this->data = [$this->data];
        }

        foreach ($this->data as $data) {
            $relationshipsToProcess = $this->resolveResource($data);
            $this->resolveRelationships($relationshipsToProcess);
        }
    }
996742
def run(self):
        
        self.logger.debug('initializing agent')
        self.game_interface.load_interface()

        self.prepare_for_run()

        # Create Ratelimiter
        rate_limit = rate_limiter.RateLimiter(GAME_TICK_PACKET_POLLS_PER_SECOND)
        last_tick_game_time = None  # What the tick time of the last observed tick was
        last_call_real_time = datetime.now()  # When we last called the Agent

        # Get bot module
        agent, agent_class_file = self.load_agent()

        last_module_modification_time = os.stat(agent_class_file).st_mtime

        # Run until main process tells to stop, or we detect Ctrl+C
        try:
            while not self.terminate_request_event.is_set():
                self.pull_data_from_game()
                # game_tick_packet = self.game_interface.get
                # Read from game data shared memory

                # Run the Agent only if the game_info has updated.
                tick_game_time = self.get_game_time()
                should_call_while_paused = datetime.now() - last_call_real_time >= MAX_AGENT_CALL_PERIOD
                if tick_game_time != last_tick_game_time or should_call_while_paused:
                    last_tick_game_time = tick_game_time
                    last_call_real_time = datetime.now()

                    # Reload the Agent if it has been modified or if reload is requested from outside.
                    try:
                        new_module_modification_time = os.stat(agent_class_file).st_mtime
                        if new_module_modification_time != last_module_modification_time or self.reload_request_event.is_set():
                            self.reload_request_event.clear()
                            last_module_modification_time = new_module_modification_time
                            # Clear the render queue on reload.
                            if hasattr(agent, 'renderer') and isinstance(agent.renderer, RenderingManager):
                                agent.renderer.clear_all_touched_render_groups()
                            agent, agent_class_file = self.reload_agent(agent, agent_class_file)
                    except FileNotFoundError:
                        self.logger.error(f"Agent file {agent_class_file} was not found. Will try again.")
                        time.sleep(0.5)
                    except Exception:
                        self.logger.error("Reloading the agent failed:\n" + traceback.format_exc())
                        time.sleep(0.5)  # Avoid burning CPU / logs if this starts happening constantly

                    # Call agent
                    try:
                        self.call_agent(agent, self.agent_class_wrapper.get_loaded_class())
                    except Exception as e:
                        self.logger.error("Call to agent failed:\n" + traceback.format_exc())

                # Ratelimit here
                rate_limit.acquire()
        except KeyboardInterrupt:
            self.terminate_request_event.set()

        # Shut down the bot by calling cleanup functions.
        if hasattr(agent, 'retire'):
            try:
                agent.retire()
            except Exception as e:
                self.logger.error("Retiring the agent failed:\n" + traceback.format_exc())
        if hasattr(agent, 'renderer') and isinstance(agent.renderer, RenderingManager):
            agent.renderer.clear_all_touched_render_groups()
        # Zero out the inputs, so it's more obvious that the bot has stopped.
        self.game_interface.update_player_input(PlayerInput(), self.index)
        self.quick_chat_quit_event.set()  # Shut down quick chat.

        # If terminated, send callback
        self.termination_complete_event.set()
256579
def main_loop(self):
        """"""
        while True:
            for e in pygame.event.get():
                self.handle_event(e)

            self.step()
            pygame.time.wait(5)
945024
def start(self, version=None, want_rgb=True, **kwargs):
    """"""
    del want_rgb  # Unused
    if not os.path.isdir(self.data_dir):
      raise sc_process.SC2LaunchError(
          "Expected to find StarCraft II installed at '%s'. If it's not "
          "installed, do that and run it once so auto-detection works. If "
          "auto-detection failed repeatedly, then set the SC2PATH environment "
          "variable with the correct location." % self.data_dir)

    version = version or FLAGS.sc2_version
    if isinstance(version, lib.Version) and not version.data_version:
      # This is for old replays that don't have the embedded data_version.
      version = self._get_version(version.game_version)
    elif isinstance(version, six.string_types):
      version = self._get_version(version)
    elif not version:
      version = self._get_version("latest")
    if version.build_version < lib.VERSIONS["3.16.1"].build_version:
      raise sc_process.SC2LaunchError(
          "SC2 Binaries older than 3.16.1 don't support the api.")
    if FLAGS.sc2_dev_build:
      version = version._replace(build_version=0)
    exec_path = os.path.join(
        self.data_dir, "Versions/Base%05d" % version.build_version,
        self._exec_name)

    if not os.path.exists(exec_path):
      raise sc_process.SC2LaunchError("No SC2 binary found at: %s" % exec_path)

    return sc_process.StarcraftProcess(
        self, exec_path=exec_path, version=version, **kwargs)
661535
public function process()
    {
        $this->initializeStorageNode($this->storageNodeNodePath, $this->storageNodeTitle);
        $this->initializeNodeTemplates();

        $nodeTemplate = new NodeTemplate();
        $this->processBatch($nodeTemplate);
    }
965767
function() {
        // Compute the amount of play left to go
        t.playLeft = t.playEnd - Date.now();

        // Done playing
        if (t.playLeft <= 0) {
          clearInterval(t.timer);
          t.next();
        }

        // Set the progress bar width
        t.setProgress();
      }
1185320
def start_game(debug=False):
    
    args = parse_cli_args()

    if args['version']:
        print_version_and_exit()

    if args['rules']:
        print_rules_and_exit()

    game = Game(**args)
    if args['resume']:
        game.restore()

    if debug:
        return game

    return game.loop()