Beispiel #1
0
                                               0)

        # Always end after this time
        if self._frame > 300:
            self._done = True

        # Stop early once a faceoff has been won and someone has the puck
        if self.short_circuit and self._puck_bonus > 0 and faceoffs_won > 0:
            self._done = True

        score = (faceoffs_won -
                 faceoffs_lost) * 100 + -self._min_puck_y + self._puck_bonus

        # Calculate action for the next frame
        self._frame += 1
        features = [self._frame]
        self._next_action = self.net.activate(features)

        self._stats = {
            "score": score,
            "frame": self._frame,
            "puck_y": puck_y,
            "faceoff_winner": self._faceoff_winner
        }

        return score


if __name__ == "__main__":
    runner.main(sys.argv[1:], FaceoffTrainer)
            self._pressed['B'] += 1
        if 'C' in buttons_pressed:
            self._pressed['C'] += 1

        # Save the score vector
        self._score_vector = score_vector

        self._done = any(self._done_reasons.values())

        # Stats to track
        self._stats = {
            'time_w_puck':
            ", ".join([
                "{} {:.1f}s".format(team, time)
                for team, time in self._accumulator.time_puck.items()
            ]),
            'pass cmp/att':
            "{}/{} ({:.0f}%) shots={}".format(
                self._accumulator.pass_completions['home'],
                self._accumulator.pass_attempts['home'], cmp_pct * 100,
                info['home-shots']),
            'buttons':
            self._pressed,
        }

        return score


if __name__ == "__main__":
    runner.main(sys.argv[1:], GameScoring1Trainer)
        if 'B' in buttons_pressed:
            self._b_pressed += 1

        # Stats to track
        self._stats = {
            'score':
            score,
            'time_w_puck':
            self._accumulator.time_puck['home'],
            'time_no_puck':
            self._accumulator.time_puck[None],
            'time_opp_puck':
            self._accumulator.time_puck['away'],
            'successful_passes':
            self._accumulator.pass_completions,
            'consecutive_passes':
            self._accumulator.consecutive_passes['consecutive']['home'],
            'cmp_pct':
            cmp_pct,
            'unique_passes':
            self._accumulator.consecutive_passes['unique']['home'],
            'b_pressed':
            self._b_pressed,
        }

        return score


if __name__ == "__main__":
    runner.main(sys.argv[1:], PassingDrillTrainer)
Beispiel #4
0
    def stats(self) -> dict:
        return self._stats

    @property
    def done(self) -> bool:
        return self._done

    def tick(self, ob, rew, done, info, env) -> float:
        home_checks = info['home-checks']
        away_checks = info['away-checks']

        # Play for a minute
        if info['time'] < 600 - 60:
            self._done = True

        # Pure score on checks
        score = (home_checks * 100) - (away_checks * 50)

        # Calculate action for the next frame
        self._frame += 1
        features = [self._frame]
        self._next_action = self.net.activate(features)

        self._stats = {"score": score}

        return score


if __name__ == "__main__":
    runner.main(sys.argv[1:], AggroTrainer)
Beispiel #5
0
        # 60 fps
        possession_score = self._possession_frames[
            'home'] - self._possession_frames['away']

        # 10x for attack score vs possession
        attack_score = 600 * (info['home-attack-time'] -
                              info['away-attack-time'])

        if info['time'] == 0:
            self._done = True

        score = possession_score + attack_score

        features = players_and_puck_feature(info)
        self._next_action = self.net.activate(features)

        self._stats = {
            "score": score,
            "pos_home": self._possession_frames['home'],
            "pos_none": self._possession_frames[None],
            "pos_away": self._possession_frames['away'],
            "atk_home": info['home-attack-time'],
            "atk_away": info['away-attack-time']
        }

        return score


if __name__ == "__main__":
    runner.main(sys.argv[1:], BallHogTrainer)
Beispiel #6
0
        self._score_acc += juke_reward

        score = self._score_acc

        score += max(self._max_puck_y, self.GOAL_Y)
        score += max(self._max_shooter_y, self.GOAL_Y)

        if info['home-goals']:
            score += 100000
            # Try to solve as quickly as possible
            score += info['time-shootout'] * 1000

        # Stop early once stoppage occurs
        if info['shootout-stoppage']:
            if self.short_circuit:
                self._done = True
            self._pending_stoppage = True
        elif self._pending_stoppage:
            self._done = True

        features = [shooter_x, shooter_y, goalie_x, goalie_y, puck_x, puck_y]
        self._next_action = self.net.activate(features)

        self._stats = {"score": score}

        return score


if __name__ == "__main__":
    runner.main(sys.argv[1:], ShootoutTrainer)