You are on page 1of 1

One way to code the application is to model (or to organize) the game logic in terms of Petri Net Elements

and based on
this organization write the code (Chionglo, 2014). The following is an example of a game logic (based on a Flashcard
game) organized in terms of Petri Nets (“How to Design”, 2016). In this game there are nine cards. One card is shown at
a time then the player guesses the card. The number of correct guesses and the number of incorrect guesses are
recorded and play continues until there are no more cards to display.

Figure 1 (for the PDF version of this reply) is an interactive, dynamic diagram of the game logic; it includes “graphic
notations” of cards with standard Petri Net notations and some high-level notations of Petri Net elements. The
demonstration mode of the game logic randomly selects a card from the deck then randomly guesses the card.

Transitions Description Places Description


�0 Begin game. �0 Game not started indicator.
�1 Incorrect guess. �1 Number of cards to display.
�2 Correct guess. �2 Display next card indicator.
�3 Game over. �3 Card displayed.
�4 − �12 Display: �4 − card 1, … �12 − card 9. �4 Card guessed.
�13 − 21 Guess: �13 − ���� 1, … �21 − card 9. �5 Number of incorrect guesses.
�6 Number of correct guesses.
�7 − �15 Card not displayed yet indicator.

P1 T4 T5 T6 T13 T14 T15


�+ �+
T7 T8 T9 T16 T17 T18

T10 T11 T12 T19 T20 T21

�− �+
P7 P8 P9
9 P3 P4
P0
P10 P12 �− �−
T3 T0 �− �−
P11

P13 P14 P15 T1 T2

P2

P5 P6

Figure 1 Interactive, Dynamic Petri Net Model of Game

References
Chionglo, J. F. (2014). Net Elements and Annotations for Computer Programming: Computations and Interactions in PDF.
Available at http://www.aespen.ca/NetElementsAndAnnotationsForComputerProgramming.pdf

“How to design a state flow for a react/redux flashcard game?” (2016). Stack Exchange. Retrieved on Feb. 7, 2016 at
http://stackoverflow.com/questions/35220169/how-to-design-a-state-flow-for-a-react-redux-flashcard-game.

Feb. 12, 2016 http://www.aespen.ca/AEnswers/oejOw1455338124.pdf

You might also like