<!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>Bacallado, M.);</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>A Procedural Content Generation Algorithm for First Person Shooter and Tower Defense Games</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Manuel Bacallado</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jesús Miguel Torres</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Rafael Arnay.</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Universidad de La Laguna, Escuela Superior de Ingeniería y Tecnología</institution>
          ,
          <addr-line>San Cristóbal de La Laguna</addr-line>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2023</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0003</lpage>
      <abstract>
        <p>The purpose of this work is to present the implementation of a rule-based procedural generation algorithm used for the creation of a game that mixes two genres: First Person Shooter and Tower Defense. The algorithm creates 3D levels, where there will be added enemy towers to destroy, base tower to defend, generation of enemies that will have different mechanics, being one of them, the destruction or conversion of the base tower and more elements. Each time the player starts a new game, a new map is generated with the elements located in different positions adding roguelikes features.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Procedural Content Generation</kwd>
        <kwd>Games</kwd>
        <kwd>First Person Shooter</kwd>
        <kwd>Tower Defense</kwd>
        <kwd>Roguelike 1</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>In this work, we make a PCG system for the creation of FPS and TD game with roguelike
features. The rest of the document is structured as follows: Section 2 discusses how the PCG
system is built and the components it integrates. In Section 3, we describe how the gameplay is
implemented and tools used. In Section 4, we make some conclusions and discuss future work.</p>
    </sec>
    <sec id="sec-2">
      <title>2. PCG DESIGN AND IMPLEMENTATION</title>
      <p>In this section, we present our PCG architecture, and we describe our use case of the algorithm
implementation in a roguelike FPS - TD prototype.</p>
      <sec id="sec-2-1">
        <title>2.1 The PGC system</title>
        <p>The architecture of the PCG system is composed for three modules that share data with each
other: Map Generation, Tower Spawn Position Generation and The Enemy Generation. The game
contains only one level generation, which occurs procedurally each game. With this system, and
through the internal modules, it is possible to create new level shapes for the game. Although the
enemies and objects are the same, the presentation of the set makes the player always feel that
he is in a different game.</p>
      </sec>
      <sec id="sec-2-2">
        <title>2.1.1 Map Generation</title>
        <p>
          The map generator system is a procedurally generated algorithm based on the Random Walk
algorithm [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], where starting from an initial position (x=0, y=0, z=0), new paths are created using
the next cardinal positions (north, south, east, west) shown in Figure 1, adding the new position
randomly generated with the previous one and storing the generated route. The algorithm is
normally built on 2 dimensions and for this project it has been adapted to 3 dimensions,
modifying the attributes so that the coordinates are now x and z, instead of x and y, and changing
the 2D sprites for 3D models.
        </p>
        <p>The algorithm has two parts: the first one to generate the path where the floor tiles are
positioned, and the next one to create the walls tiles and give the level the appearance of a
dungeon. In this case, the tiles are 3D models to represent the art of the game. The rules on which
the algorithm is executed are as follows: the number of iterations, length of walk in each iteration,
and whether each iteration starts at a random position as shown in Figure 2. The attributes are
stored in a user-modifiable structure.</p>
        <p>Once the floor path has been created, a method based on binary values is used to know the
location of the wall tile to be inserted, since the walls have different representations depending
on the position in which they are located. This method is used twice: once for cardinal walls, and
once for diagonal walls. In both cases, we iterate over the list of floor coordinates obtained earlier
and depending on the wall type, we add the position of the floor to a cardinal or diagonal
coordinate. To create the binary number, we check if the resulting coordinate exists in the list of
floor coordinates. If so, then a 1 is added to a string variable. Otherwise, 0 is added. Once we have
the string representing the number, it is converted to integer and compared with the list of
specified values of each address to obtain the corresponding model.</p>
        <p>Once we have both the directions of the floor and the walls, we use a visualization system to
place the corresponding model in each coordinate, and finally have the generate map. Figure 3
shows the complete result.</p>
      </sec>
      <sec id="sec-2-3">
        <title>2.1.2 Tower Spawn Position Generation</title>
        <p>After the map has been generated, enemy towers and the tower we must defend are positioned.
In this case, for the player’s tower, it is always positioned at the coordinate (0,0,0), although the
visual representation is different, since the map always is different. Enemy towers are placed
randomly at the extremes of the map. These extreme positions are positions where both x and z
coordinates have minimum and maximum values. In our prototype there are only three enemy
towers, so once instantiated on the map as shown in Figure 3, the remaining extreme position is
used to place the player.</p>
      </sec>
      <sec id="sec-2-4">
        <title>2.1.3 The Enemy Generation</title>
        <p>The enemy generation gets a random position on the map in which there is no key element such
as walls or towers to generate an enemy in that position. There is a generator integrated in each
enemy tower, and each generator have a different group of enemies and the interval in seconds
of generation. When a tower is destroyed, the generator is destroyed with it. In our prototype, we
have five types of enemies as shown in Figure 4. Of these enemies, two attack the tower directly
(EnemyConverter and EnemyFollowTower), while the rest goes after the player (EnemyGun and
EnemyFollowPlayer) or remains blocking the map (EnemyRadar).</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Game Implementation</title>
      <p>The proposed PCG system was developed for the game with the code name: Project Survivor. In
the game, the player’s mission is destroy the enemy towers before the enemies convert or destroy
the player’s tower or kill the player. If the tower is converted, all enemies target the player and
increase their speed to reach and destroy it, greatly increasing the difficulty of the game. In case
of destroying it, the game is simply over and a new one would have to be started from scratch. In
this pre-alpha version of the prototype, the enemies have a basic artificial intelligence performing
the behaviors described in section 2.1.3 and the player has only one weapon available.</p>
      <p>
        The game was developed with the Unity game engine [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. For the art, and being a prototype,
basic engine models have been used to represent the map, towers, enemies, weapons and bullets.
Figure 5 shows one gameplay screen with all the elements in the scene.
      </p>
      <p>After testing the game when this pre-alpha version has been completed, it has been found that
it is necessary to adjust the generation times of enemies and add obstacles to slow down the
player’s progress, and on several occasions, it has been possible to reach the enemy towers with
easily. Apart from adding new weapons for the player and objects of healing and destruction.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion</title>
      <p>In this paper, we propose an algorithm capable of generating the game and level structure for a
game that mixes the FPS and TD genres. During the development of the game, enemies have been
designed to challenge the player, such as enemies that directly target to the base tower. In future
works, new skills, items, enemies, obstacles, and different challenges for the player will be
implemented. Also, add extra complexity to the map by making it smaller every so often,
generating the redesign procedurally but respecting the current state of the elements on the map.
In addition, playtesting sessions with external users will be carried out to collect as much data
and feedback as possible and make the appropriate changes.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>J.</given-names>
            <surname>Togelius</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Whitehead</surname>
          </string-name>
          , and
          <string-name>
            <given-names>R.</given-names>
            <surname>Bidarra</surname>
          </string-name>
          . “
          <article-title>Procedural Content Generation in Games (Guest Editorial),”</article-title>
          .
          <source>IEEE Transactions on Computational Intelligence and AI</source>
          in Games,
          <volume>3</volume>
          (
          <issue>3</issue>
          ) pp.
          <fpage>169</fpage>
          -
          <lpage>171</lpage>
          , Sep.
          <year>2011</year>
          . doi:
          <volume>10</volume>
          .1109/TCIAIG.
          <year>2011</year>
          .
          <volume>2166554</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2] “Sanctum”,
          <year>2011</year>
          . https://coffestainstudios.com/games/sanctum/ (accessed Oct.
          <volume>15</volume>
          ,
          <year>2023</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>“</surname>
            <given-names>GROSS</given-names>
          </string-name>
          ”,
          <year>2023</year>
          . https://hangryowl.games/gross-press-kit (accessed Oct.
          <volume>15</volume>
          ,
          <year>2023</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>D. T.</given-names>
            <surname>Mattheus</surname>
          </string-name>
          , Rogue - Video
          <string-name>
            <surname>Game</surname>
          </string-name>
          , Ventana Press., Inc.,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>V.</given-names>
            <surname>Cerny</surname>
          </string-name>
          and
          <string-name>
            <given-names>F.</given-names>
            <surname>Dechterenko</surname>
          </string-name>
          ,
          <article-title>Rogue-Like Games as a PlayGround for Artificial Intelligence - Evolutionary Approach</article-title>
          , in
          <source>: Proceedings of the Internacional Conference on Entertainment Computing, Sep</source>
          .
          <year>2015</year>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>319</fpage>
          -24589-8_
          <fpage>20</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>G.</given-names>
            <surname>Smith</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Gan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Othenin-Girard</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>J.</given-names>
            <surname>Whitehead</surname>
          </string-name>
          , “
          <article-title>PCG-based game design: enabling new play experiences through procedural content generation</article-title>
          ,”
          <source>in Proceedings of the 2nd International Workshop on Procedural Content Generation in Games</source>
          , New York, NY, USA, Jun.
          <year>2011</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>4</lpage>
          . doi:
          <volume>10</volume>
          .1145/2000919.2000926.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>F.</given-names>
            <surname>Xia</surname>
          </string-name>
          , J. Liu,
          <string-name>
            <given-names>H.</given-names>
            <surname>Nie</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Fu</surname>
          </string-name>
          , Liangtian and
          <string-name>
            <given-names>X.</given-names>
            <surname>Kong</surname>
          </string-name>
          . “
          <article-title>Random Walks: A Review of Algorithms and Applications”</article-title>
          .
          <source>IEEE Transactions On Emerging Topics in Computational Intelligence</source>
          ,
          <volume>4</volume>
          (
          <issue>2</issue>
          ):
          <fpage>95</fpage>
          -
          <lpage>107</lpage>
          , April.
          <year>2020</year>
          . doi:
          <volume>10</volume>
          .1109/TETCI.
          <year>2019</year>
          .2952908
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8] “Unity”,
          <year>2023</year>
          . https://unity.com (accessed
          <year>Sep</year>
          .
          <volume>27</volume>
          ,
          <year>2023</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>