<!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>Petri Net games, examples and quizzes for education, contest and fun, Geneva, Switzerland, June</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Leveraging the Pedagogical Potential of Tile-Based Games for Teaching Petri Net Modeling, the Sokoban Case</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>João-Paulo Barros</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Luis Gomes</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Intelligent Systems Associate LAboratory (LASI)</institution>
          ,
          <country country="PT">Portugal</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>NOVA University Lisbon, School of Science and Technology</institution>
          ,
          <country country="PT">Portugal</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Polytechnic Institute of Beja</institution>
          ,
          <addr-line>Beja</addr-line>
          ,
          <country country="PT">Portugal</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2024</year>
      </pub-date>
      <volume>25</volume>
      <issue>2024</issue>
      <fpage>0000</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>Students face unfamiliar abstract concepts when learning about formal methods and Petri net modeling. These concepts are challenging for students to understand fully and for teachers to design captivating modeling exercises that align with the intended learning outcomes. The proposed exercises should provide significant opportunities to apply abstract concepts in familiar domains, bridging the gap between the concrete and the abstract. Board games ofer a range of modeling problems in an area that many students know. This paper introduces a model for Sokoban, a classic computer-based, one-player puzzle game. After, a sequence of possible Petri net modeling exercises focused on the game movement rules and model composition are proposed. The complete model is created by composing multiple instances of the previously defined models acting as modules. The complete model can then be used to verify game termination and obtain the net step sequence leading to the intended final net marking.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Board games</kwd>
        <kwd>Modeling</kwd>
        <kwd>Formal methods</kwd>
        <kwd>Education</kwd>
        <kwd>Reachability graph</kwd>
        <kwd>Petri nets</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Exercises are a core component of learning and assessment and must fulfill a dual role: they must align
with the intended learning outcomes and be perceived by students as interesting and motivating.</p>
      <p>
        Due to the well-known capacity to engage students, games are frequently used for pedagogical
purposes (e.g., [
        <xref ref-type="bibr" rid="ref1 ref2">1, 2</xref>
        ] ) and are often a way to introduce students to programming (e.g., [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]). Furthermore,
games ofer domains that are well-known by most students.
      </p>
      <p>We propose using simple tile-based games, sometimes called grid-based games, as an adequate basis
for teaching and learning Petri net modeling. More specifically, we argue that many of those games
ofer the following advantages:</p>
      <sec id="sec-1-1">
        <title>1. Game domain, which should foster student engagement;</title>
        <p>2. Huge variety, from very simple to very complex ones;
3. Graphical representations allowing a visual mapping between the physical board and the Petri
net model structure;
4. A clear diferentiation between the passive part (the board) and the active part (moving pieces
and their movement rules, including restraints).</p>
        <p>We present the Sokoban game as an illustrative example. This game, with its grid-based structure
and movement rules, is a concrete application that exemplifies the above-listed advantages.</p>
        <p>The paper is structured as follows. In the next section, we present the game Sokoban. In Section
3, we present a sequence of proposed exercises and the respective possible solutions focusing on the
movement rules of the game and the subsequent composition that yields the complete model amenable
to simulation or state-based exploration. Finally, we conclude with some proposals for future work.</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>2. The Sokoban game</title>
      <p>
        Sokoban has been named "the quintessential “block pushing” game " [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. It is a single-player tile-based
board game with simple rules. However, it can quickly become highly challenging. It is played on a
"map" made of adjoining tiles. Each tile can be seen as a cell in a grid. The player moves in one of four
directions: left to right, right to left, top to bottom, and bottom to top. The objective is for the player to
push all the boxes around the grid to put them in the final marked locations. If a box is adjacent, the
player can push the box to the next cell in the same direction. However, for that to happen, the ending
box position must be free, which means no (other) box or "wall" can be in that cell. Each tile can be
from one of three types:
      </p>
      <sec id="sec-2-1">
        <title>Free cell A cell that can also contain the player or a box;</title>
      </sec>
      <sec id="sec-2-2">
        <title>End cell A free cell that is marked as a final destination of any one box;</title>
        <p>Wall A cell that cannot be occupied by the player or a box; these cells also serve to delimit the level
board.</p>
        <p>
          The Wikipedia webpage provides a simple and short introduction to the Sokoban game, illustrated
with an animated gif [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ]. Numerous Sokoban implementations and levels are readily available on the
Internet. As a specially significant example, the website https://sokoban.info/ provides "more than 7500
levels". Fig. 1 illustrates one of the smallest and simplest levels available.
        </p>
        <p>
          Even Sokoban basic levels necessitate significant computational resources, as there are many branches
and possible deadlocks, and a vast number of steps can quickly be needed to reach a solution [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ]. More
precisely, the game domain has been proven NP-Hard [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], and PSPACE-complete [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. Sokoban has also
been the object of several studies regarding possible algorithms (e.g., [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]). Here, our object is to use the
modeling of the level (board) and movement rules as motivating exercises for model construction using
Place/Transition Petri nets. The Petri net reachability graph can then be used to explore the existence
of solutions and the respective paths to them.
        </p>
        <p>The following section presents a sequence of possible student exercises. It corresponds to a step-wise
and module-based approach for constructing a complete Sokoban level.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. A Modular Petri net for a Sokoban level</title>
      <p>Here, we present six sequential exercises toward a complete model for a Sokoban game level and its
analysis using Place/Transition nets. First, we focus on the player movement, either by simply moving
to an adjacent position or by pushing a box; secondly, we present how that model can be split into a
passive and an active part; finally, using a textual description, we show how multiple instances of these
two small modules can be composed to generate a level with all the possible movements in that level.</p>
      <sec id="sec-3-1">
        <title>3.1. Modeling the player movement</title>
        <p>When presenting the game to the students, the obvious challenge is to model the player’s movements.
Here, we split the player movement into two cases: (1) the end position is free; (2) the end position has
a box.
3.1.1. Free movement</p>
        <sec id="sec-3-1-1">
          <title>1. How the initial and free positions are modeled;</title>
          <p>2. How do we know where the player is;
3. How the model moves the player from one position to the other;
4. How the model checks if the end position is free.</p>
          <p>The student’s first solution does not need to distinguish between an end position with a box or a
wall. This distinction can be required for a second solution, as it should be clear that it will be needed
for the case where the player has to move a box. Fig. 2b illustrates a solution with two places, for the
begin and end positions, respectively, that need the end position to be free for the transition freeMove
to be enabled. The transition firing models the player’s movement.
3.1.2. Movement pushing a box
The cases to be presented to students in a second exercise are shown in Fig. 3a. The player moves to a
position where a box is. The students have to consider the following aspects that are to be expressed in
the model:
1. How the initial and end box position are modeled;
2. How to know where the player is;
3. How the model moves the player from one position to the other;
4. How the model moves the pushed box from one position to the other;
5. How the model moves the player and the pushed box synchronously;
6. How the model checks if the end position has a box;
7. How the model checks if the box’s intended end position is free (from a box or a wall).</p>
          <p>In this second exercise, it should be apparent from the beginning that the box and the player must
change their positions. An additional complication is that a total of three positions must be considered,
as the position after the box is also a possible restriction to the player’s (and the box’s) movement. The
need to test and update the presence and the absence of a box presents a new dificulty that provides an
opportunity to discuss the use of complementary places. In addition, it is helpful to discuss whether we
need a complementary place for the wall and what information we need in each position.</p>
          <p>Fig. 3b illustrates a solution. It is centered on the "push box" action, which is modeled by transition
pushBox. It uses complementary places for boxes in the initial box position and in the position where
the box is going to be pushed. It also checks whether or not there is a wall in the box end position. The
chosen layout has all places related to the same cell (position) in the same row to highlight the number
of positions involved and the data needed for each position state.
3.1.3. Movement composition
A third, more straightforward exercise is to compose both movements into a single one. The solution is
presented in Fig. 4.</p>
        </sec>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. Position state and two-way movement</title>
        <p>A fourth exercise is identifying all the state information needed for each position as a step toward
modeling movement in both directions. Fig. 5a presents the solution presented in Fig. 4 with all the
places needed to store each position’s state. Their use in the two-way movement is illustrated in Fig. 5b.</p>
      </sec>
      <sec id="sec-3-3">
        <title>3.3. Creating the complete model using module composition</title>
        <p>The complete model, for a whole level, requires multiple compositions. A two-step approach can be
presented to students: (1) identify the modules to be composed; (2) express the multiple compositions.
3.3.1. Modules identification
The modeling of the two movements in two opposite directions can be seen as the modeling of the
"passage" between those two positions. The following exercise can be the identification of the model for
each position (each cell in the grid). Next, both the "passage" and the "cell" should be transformed into
composable modules by identifying the "interface" nodes. The "interface" nodes are the ones that will
be fused (merged) with nodes in other modules. It seems worth discussing the dual nature of "passages,"
which encapsulate the actions (moving from one position to another), and "cells," which encapsulate the
game state. This duality is analogous to the one between Petri nets transitions and places. Hence, the
module composition is particularly interesting when allowing and exhibiting this duality.</p>
        <p>Figures 6a and 6b allow the composition of cell module instances with passages modules in between.
Fig. 7 shows a high-level view of the whole game level of Fig. 1 as the composition of juxtaposed cell
and passage instance modules.
3.3.2. Complete model
The last modeling exercise can be the specification of all the necessary compositions. This exercise relies
heavily on a tool that comprehensively supports model composition. Some textual language is probably
the preferable approach. We present a possible pseudo-code for such composition (see Algorithm 1).
The  procedure receives four-cell module instances and one passage module instance. A set of
place fusions connects the five instances. The whole level is built by the  procedure. This
procedure calls the  procedure for each pair of positions (cells) with a passage between them.
The function  returns the positions with a passage between them, thus efectively
defining the game-level structure but not the initial state (marking). The   function receives
those two positions’ coordinates and returns the four module instances needed for the composition.
Functions . and . create new instances of module  and module 
(identified by the respective parameters) if not yet created, and return the respective instance if already
created.</p>
        <p>If suitable tools are available to obtain the model for the complete level, using it for simulation or
state-space analysis should be interesting. The state-space analysis is especially interesting for checking
the reachability of the intended final marking (all boxes in the end cells) and the shortest path (step
sequence) to reach it.</p>
        <p>Algorithm 1 Create board (complete Petri net model)
1: procedure createBoard((1, 1), (2, 2))
2: for all ((1, 1), (2, 2)) ∈ () do
3: Connect( FourCells( (x1, y1), (x2, y2) ), passage.create((x1, y1), (x2, y2)) )
4: end for
5: end procedure
6: function connectionsList( )
7: ◁ Position pairs with a passage in between
8: return (
▷</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusions and future work</title>
      <p>
        Using the Sokoban game as an example, we have shown how a classic tile-based game can be used as a
basis for engaging P/T net modeling exercises. Considering low-level nets, the model also ofers good
opportunities to discuss and use test arcs, inhibitor arcs, or both to simplify the model. The game also
provides a suitable ground for high-level Petri net modeling, including coloured Petri nets [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] and
reference nets [
        <xref ref-type="bibr" rid="ref11 ref12 ref13">11, 12, 13</xref>
        ]. The presented exercise sequence can be adapted to the modeling of other
tile-based games by P/T nets, high-level nets, or even non-autonomous nets.
      </p>
      <p>In our future work, we recognize the necessity for a straightforward method to define and implement
multiple module compositions. Specifically, this method should enable the composition of modular
models in a declarative manner, utilizing a textual language.</p>
    </sec>
    <sec id="sec-5">
      <title>Acknowledgments References</title>
      <p>This work was financed by Portuguese Agency FCT – Fundação para a Ciência e Tecnologia, in the
framework of project UIDB/00066/2020.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>K.</given-names>
            <surname>Sung</surname>
          </string-name>
          ,
          <article-title>Computer games and traditional cs courses, Commun</article-title>
          . ACM
          <volume>52</volume>
          (
          <year>2009</year>
          )
          <fpage>74</fpage>
          -
          <lpage>78</lpage>
          . URL: https://doi.org/10.1145/1610252.1610273. doi:
          <volume>10</volume>
          .1145/1610252.1610273.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>V. F.</given-names>
            <surname>Martins</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. A.</given-names>
            <surname>Eliseo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Omar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. L. A.</given-names>
            <surname>Castro</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. G. D.</given-names>
            <surname>Corrêa</surname>
          </string-name>
          ,
          <article-title>Using game development to teach programming</article-title>
          ,
          <source>in: Handbook of Research on Immersive Digital Games in Educational Environments, IGI Global</source>
          ,
          <year>2019</year>
          , pp.
          <fpage>450</fpage>
          -
          <lpage>485</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>A.</given-names>
            <surname>Vahldick</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. J.</given-names>
            <surname>Mendes</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. J.</given-names>
            <surname>Marcelino</surname>
          </string-name>
          ,
          <article-title>A review of games designed to improve introductory computer programming competencies</article-title>
          ,
          <source>in: 2014 IEEE Frontiers in Education Conference (FIE) Proceedings</source>
          ,
          <year>2014</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>7</lpage>
          . doi:
          <volume>10</volume>
          .1109/FIE.
          <year>2014</year>
          .
          <volume>7044114</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>M. J.</given-names>
            <surname>Wolf</surname>
          </string-name>
          (Ed.),
          <article-title>The video game explosion: a history from Pong to Playstation®and beyond</article-title>
          , Greenwood Press,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>Wikipedia</surname>
            <given-names>contributors</given-names>
          </string-name>
          , Sokoban - Wikipedia, the free encyclopedia, https://en.wikipedia.org/w/ index.php?title=
          <source>Sokoban&amp;oldid=1219730853</source>
          ,
          <year>2024</year>
          . [Online; accessed 21-April-2024].
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>T.</given-names>
            <surname>Virkkala</surname>
          </string-name>
          , Solving Sokoban,
          <source>Ph.D. thesis</source>
          , Masters thesis, University Of Helsinki,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>D.</given-names>
            <surname>Dor</surname>
          </string-name>
          , U. Zwick,
          <article-title>SOKOBAN and other motion planning problems</article-title>
          ,
          <source>Computational Geometry</source>
          <volume>13</volume>
          (
          <year>1999</year>
          )
          <fpage>215</fpage>
          -
          <lpage>228</lpage>
          . URL: https://www.sciencedirect.com/science/article/pii/S0925772199000176. doi:https://doi.org/10.1016/S0925-
          <volume>7721</volume>
          (
          <issue>99</issue>
          )
          <fpage>00017</fpage>
          -
          <lpage>6</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>J.</given-names>
            <surname>Culberson</surname>
          </string-name>
          ,
          <article-title>Sokoban is PSPACE-complete</article-title>
          ,
          <source>Technical Report</source>
          , University of Alberta,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>N.</given-names>
            <surname>Froleyks</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Froleyks</surname>
          </string-name>
          ,
          <article-title>Using an algorithm portfolio to solve sokoban</article-title>
          ,
          <source>Symposium on Combinatorial Search</source>
          (
          <year>2016</year>
          ). doi:
          <volume>10</volume>
          .5445/ir/1000073699.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>K.</given-names>
            <surname>Jensen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. M.</given-names>
            <surname>Kristensen</surname>
          </string-name>
          ,
          <source>Coloured Petri Nets: Modelling and Validation of Concurrent Systems</source>
          , 1st ed., Springer Publishing Company, Incorporated,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>O.</given-names>
            <surname>Kummer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Wienberg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Duvigneau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Köhler</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Moldt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Rölke</surname>
          </string-name>
          , Renew - the Reference Net Workshop, in: E. Veerbeek (Ed.),
          <source>Tool Demonstrations. 24th International Conference on Application and Theory of Petri Nets (ATPN</source>
          <year>2003</year>
          ).
          <source>International Conference on Business Process Management (BPM</source>
          <year>2003</year>
          )., Department of Technology Management, Technische Universiteit Eindhoven,
          <source>Beta Research School for Operations Management and Logistics</source>
          ,
          <year>2003</year>
          , pp.
          <fpage>99</fpage>
          -
          <lpage>102</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>O.</given-names>
            <surname>Kummer</surname>
          </string-name>
          ,
          <article-title>Introduction to petri nets and reference nets</article-title>
          ,
          <source>Sozionik Aktuell</source>
          <volume>1</volume>
          (
          <year>2001</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>O.</given-names>
            <surname>Kummer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Wienberg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Duvigneau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Cabac</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Haustermann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Mosteller</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. M.</given-names>
            <surname>Arbeitsbereich</surname>
          </string-name>
          , Renew User Guide,
          <source>Technical Report</source>
          , University of Hamburg,Department for Informatics, Theoretical Foundations Group,
          <year>2022</year>
          . Available online: https://www2.informatik.uni-hamburg.de/ TGI/renew/4.0/renew4.0.
          <source>pdf (accessed on 2022-11-23).</source>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>