<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>November</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Deep Reinforcement Learning Compared to Human Performance in Playing Video Games</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Jovana Markovska</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Domen Šoberl</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Primorska, Faculty of Mathematics</institution>
          ,
          <addr-line>Natural Sciences and Information Technologies, Glagoljaška 8, SI-6000 Koper</addr-line>
          ,
          <country country="SI">Slovenia</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2022</year>
      </pub-date>
      <volume>29</volume>
      <issue>2022</issue>
      <abstract>
        <p>Through deep reinforcement learning, a computer can learn to play simple video games under the same conditions as human players - by watching the pixels on the screen and issuing the button-press type of actions. In this paper, we investigate how quickly a computer can reach and surpass human performance in a simple two-player video game, given no background knowledge of how to play the game. We implement a Deep Q-Learning (DQN) algorithm using Python and integrate it with the Atari 2600 emulator that runs the Pong game. We train the neural network for up to 3 million training steps and evaluate its performance after every 100.000 steps. As a reference, we measure the performance of 18 human players and take their average rating as the human-level baseline. We propose an evaluation metric that considers the obtained game points and the player's endurance during the game. We find that the Deep Q-Learning algorithm can surpass beginner-level human players in playing the Pong game after about 4 hours of training.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;reinforcement learning</kwd>
        <kwd>deep learning</kwd>
        <kwd>Q-learning</kwd>
        <kwd>deep neural networks</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        With the advances of deep learning [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], it became possible to implement a deep reinforcement
learning algorithm (Deep Q-Network, DQN) that can learn how to play video games under the
same sensory conditions as human players [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. Traditionally, reinforcement learning was used
with high-level game states, e.g., board positions with the tic-tac-toe game [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. On the other
hand, humans observe a screen image composed of raw pixels, and it is up to them to make an
abstract meaning out of it. For example, suppose a human player is given no instructions on
how a game is played, the mechanics of it, who the agent is, and what the goal of the game is,
except for positive or negative feedback when the score has been changed. The player would,
by trial and error, first make sense of the individual objects seen on the screen, determine the
mechanics of the game by trying out various actions with the game controller, and find out what
the goal is supposed to be by observing under what circumstances the scores change. Deep
learning has enabled computers to perform under similar conditions. Instead of feeding the
algorithm with an abstract representation of the game’s state, the convolutional layers within a
DQN learn how to extract high-level features from raw pixels [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], while the fully connected
layers learn a game’s strategy.
      </p>
      <p>In this paper, we aim to answer the research question of how quickly DQN can reach and
surpass human performance in a simple two-player video game. We present the results of
a video game tournament that we organized to evaluate the human progress in playing the
classic Pong game on the Atari 2600 platform. We propose an evaluation metric that encodes
the player’s endurance and the achieved score, which we compare with the values achieved by
the computer at diferent stages of training.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Methodology</title>
      <p>
        We implemented the DQN reinforcement learning algorithm [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] in Python 3.10. We used
Tensorflow 2.10 [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] to construct the deep neural network, OpenAI Gym [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] in combination with
the ALE (Arcade Learning Environment) [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] to simulate the Atari 2600 gaming platform, and
Petting Zoo [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] to adapt the ALE for multi-agent playing. The input to the learning algorithm
was the screen image of size 160 × 210 pixels. The output was an integer representing the
action to be executed. ALE supports 18 distinct actions of the original Atari 2600 controller. We
reduced the number of actions to the four required for playing the Pong game: 0 (no action), 1
(fire), 2 (up) in 3 (down). The same four actions were available to human players by pressing
keys on the keyboard. The agent was competing against the built-in computer opponent. The
agent received the positive reward +1 when hitting the opponent’s goal and the negative reward
-1 when receiving the goal from the opponent. The same rules applied to human players. The
game ended when either side reached 21 points.
      </p>
      <p>We trained the DQN for 3 million steps, which accounted for 797 played games. The game
runs natively at 20 steps per second, which takes 41.67 hours of real-time gameplay to reach 3
million steps. In our case, the training process lasted about 49 hours on a desktop computer
without GPU support. The training started with a high exploration factor to obtain diverse
playing experiences, which means that most actions were chosen randomly. The ratio of actions
chosen randomly vs. through the learned policy was linearly reduced with the number of
training steps until it reached the ratio of 1:10 at 1 million steps and remained constant from
that point on. We saved the weights and biases of the trained Q-network every 100,000 steps,
thus obtaining 30 diferent AI players, each later one supposedly performing better than the
preceding ones. All 30 AI players were then given to play 100 full games against the computer
opponent to evaluate their average rating.</p>
      <p>To evaluate the performance of human players, we organized a tournament in playing the
Pong game, which was attended by 18 students of the University of Primorska. None of the
participants were proficient in playing this game before; all could be considered complete
beginners. Each participant played three full games against the computer opponent in an Atari
2600 emulator on a laptop computer. Players used a standard computer keyboard and played
the game on the same system. They were not allowed to practice the game beforehand. A single
game typically lasted about 15 minutes. Compared to today’s standard of computer gaming,
Pong is not a particularly engaging game. We observed that the participants started feeling
bored and demotivated after finishing three games, which is why we limited the experiment to
playing only three games. Our experiment, therefore, measures the performance of beginner
players.</p>
      <p>We argue that the final game score alone is not a good indicator of the player’s performance.
For example, suppose that two players both lose the game without hitting a single goal, but one
player manages to play the game for a longer time than the other. Although they both received
the same final score, the player with more extended gameplay demonstrates more proficiency.
We, therefore, define the player’s rating measured in one gameplay as:
rating = 103 ·
∑︀=1  · − 1</p>
      <p>,

(1)
where  is the number of episodes (either side scores a goal, and a reward is collected),  = ± 1
is the award received by the agent, and  is the duration of the episode in steps. The constant
103 is chosen to scale the rating into an easily readable interval. This rating is used the same
for AI players and humans.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Results</title>
      <p>The ratings (1) achieved by human players in all 54 played games are shown in Table 1. A
negative rating indicates that the human player performs worse than the built-in computer
opponent, and a positive value indicates that the human player performs better. As seen from
the table, participants lost all the games but were improving in performance with each game.
The average rating over all 54 games was − 8.03, with a standard deviation of 2.84. Therefore,
we conclude that human player rating at the beginner’s level is typically between − 10.87 and
− 5.19. This interval is depicted on the plot in Figure 1 by a green strip.</p>
      <p>We evaluated the 30 trained AI players separately from the organized tournament, but the
ratings are comparable because we used the same evaluation metric. The red plot in Figure 1
shows the average rating over 100 played games for each level of AI training, with the yellow
strip representing the standard deviation. The rating converges relatively quickly towards zero,
which means that the trained AI player reaches the performance of the computer opponent but
does not surpass it. By observing the hard-coded strategy of the computer opponent, it becomes
clear that it follows a near-optimal defense strategy by always keeping the paddle aligned with
the vertical position of the ball. This makes the opponent hard to defeat but not dificult to
g
n
i
t
a
r
r
e
y
a
l
P
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30</p>
      <p>Number of training steps × 105
match by inventing a similar defensive strategy. The training is also not stable, which we can
see on the plot as occasional drops in performance along the training timeline. However, these
instabilities are quickly compensated with further training. Human performance was surpassed
in about 300,000 training steps, which is roughly 4 hours of real-time gameplay.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Discussion</title>
      <p>We researched the performance of deep learning against humans in playing a simple video game.
Our research question was how quickly computers could reach and outperform human players in
action gaming when playing under the same sensory conditions as humans. We chose to conduct
our experiment on the classical Atari 2600 Pong game and measured the performance of 18
people who played 54 games altogether. The number of games was determined after a discussion
with the participants, who declared that after the third game, they were demotivated to carry
out the experiment longer. We argued that the final score alone is an insuficient measurement
of performance and proposed a rating that also incorporates the player’s endurance. The
comparison between the measured human ratings and the ratings achieved through deep
reinforcement learning showed that the beginner’s human level of performance in playing
Pong could be surpassed by AI if trained for about 4 hours or longer. However, this may not be
the case with more proficient players. Neither the AI player nor any of our participants ever
managed to surpass the performance of the built-in computer opponent, but an experienced
human Pong player might.</p>
      <p>The participants were not versed in playing this game, so if they were allowed to play
more games or to practice before attending the experiment, the measured human rating would
probably be higher. We observed that the average ratings improved with every game played.
The biggest advancement was made between the first and the second gameplay, mainly because
the participants were getting used to controlling the paddle during the first game, and only
in the later games focused more on the strategy of playing. A significant drawback was also
the use of a keyboard instead of the original analog controller for which the Pong game was
originally made.</p>
      <p>In this research, we only considered playing against the computer opponent. The idea of a
human playing against a trained AI player is an interesting one, but it is not easy to come up with
a feasible approach. Expecting the participants to play for hours with a reinforcement learning
algorithm is not practical. It is also likely that the training would take a long time because
humans tend to experiment with more complex playing strategies and can be inconsistent in
their decisions. If trained in advance against the computer opponent, the AI player overfits to
the hard-coded strategy and fails to play against humans. Another possibility is to implement
adversarial training of two AI players that play against each other. However, the strategy
space the two agents would have to explore is vast, and there is no guarantee that the training
would be stable. Moreover, the learned adversarial strategies may not work well against human
players.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Y.</given-names>
            <surname>LeCun</surname>
          </string-name>
          , Y. Bengio, G. Hinton,
          <article-title>Deep learning</article-title>
          ,
          <source>Nature</source>
          <volume>521</volume>
          (
          <year>2015</year>
          )
          <fpage>436</fpage>
          -
          <lpage>44</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>V.</given-names>
            <surname>Mnih</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Kavukcuoglu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Silver</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. A.</given-names>
            <surname>Rusu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Veness</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. G.</given-names>
            <surname>Bellemare</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Graves</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. A.</given-names>
            <surname>Riedmiller</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Fidjeland</surname>
          </string-name>
          , G. Ostrovski,
          <string-name>
            <given-names>S.</given-names>
            <surname>Petersen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Beattie</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Sadik</surname>
          </string-name>
          , I. Antonoglou,
          <string-name>
            <given-names>H.</given-names>
            <surname>King</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Kumaran</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Wierstra</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Legg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Hassabis</surname>
          </string-name>
          ,
          <article-title>Human-level control through deep reinforcement learning</article-title>
          ,
          <source>Nature</source>
          <volume>518</volume>
          (
          <year>2015</year>
          )
          <fpage>529</fpage>
          -
          <lpage>533</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>R. S.</given-names>
            <surname>Sutton</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. G.</given-names>
            <surname>Barto</surname>
          </string-name>
          , Reinforcement Learning: An Introduction, second ed., The MIT Press,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>A.</given-names>
            <surname>Krizhevsky</surname>
          </string-name>
          , I. Sutskever,
          <string-name>
            <given-names>G. E.</given-names>
            <surname>Hinton</surname>
          </string-name>
          ,
          <article-title>Imagenet classification with deep convolutional neural networks</article-title>
          ,
          <source>Commun. ACM</source>
          <volume>60</volume>
          (
          <year>2017</year>
          )
          <fpage>84</fpage>
          --
          <lpage>90</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>M.</given-names>
            <surname>Abadi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Agarwal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Barham</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Brevdo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Citro</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. S.</given-names>
            <surname>Corrado</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Davis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Dean</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Devin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Ghemawat</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Goodfellow</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Harp</surname>
          </string-name>
          , G. Irving,
          <string-name>
            <given-names>M.</given-names>
            <surname>Isard</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Jia</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Jozefowicz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Kaiser</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kudlur</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Levenberg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Mané</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Monga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Moore</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Murray</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Olah</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Schuster</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Shlens</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Steiner</surname>
          </string-name>
          , I. Sutskever,
          <string-name>
            <given-names>K.</given-names>
            <surname>Talwar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Tucker</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Vanhoucke</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Vasudevan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Viégas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Vinyals</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Warden</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wattenberg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wicke</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Yu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Zheng</surname>
          </string-name>
          ,
          <source>TensorFlow: Large-scale machine learning on heterogeneous systems</source>
          ,
          <year>2015</year>
          . URL: https://www.tensorflow.org/, software available from tensorflow.
          <source>org.</source>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>G.</given-names>
            <surname>Brockman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Cheung</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Pettersson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Schneider</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Schulman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Tang</surname>
          </string-name>
          , W. Zaremba, OpenAI Gym, arXiv:
          <fpage>1606</fpage>
          .01540,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Bellemare</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Naddaf</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Veness</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Bowling</surname>
          </string-name>
          ,
          <article-title>The arcade learning environment: An evaluation platform for general agents</article-title>
          ,
          <source>Journal of Artificial Intelligence Research</source>
          <volume>47</volume>
          (
          <year>2012</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>J. K.</given-names>
            <surname>Terry</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Black</surname>
          </string-name>
          , L. Santos,
          <article-title>Multiplayer support for the arcade learning environment</article-title>
          ,
          <volume>10</volume>
          .48550/arXiv.
          <year>2009</year>
          .
          <volume>09341</volume>
          ,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>