modeling methodology for npc’s using interpreted petri nets...

6
*Supported by project PROMEP 103.5/09/1158 Abstract ––In the context of video games design, Artificial Intelligence (AI) a broad of techniques have been used to generate the behavior of Non-Players Characters (NPC’s). In this document, is explored the use of Supervisory control in Discrete Event Systems for design the behavior of NPC’s, where the interaction between them it is not blocking. The modeling tool used is Interpreted Petri Nets (IPN) which are an extension of Petri Nets (PN) allow to relate input signals and output signals for PN models. Keywords –– Feedback control, Non-player characters, Petri Nets, Supervisor using p-invariant. I. INTRODUCTION In the sorts of video games of adventures and strategies, the hero and/or main character is controlled generally by the user of the game. Whereas the rest of the characters are programmed, some of them have the roll to play like opponents; when these simulate to be an intelligent character NPC's are used. For the developers of NPC's Artificial Intelligence (AI) has come to mean the broad range of used techniques to generate the behavior of these adversaries, the units of equipment, battlefield, or any other thing that simulate intelligence [1]. Some of these techniques, such as finite state machines [2], [3], search algorithms like A * [4], [5], [6], methods based on software engineering [7], [8], dynamic tables of probability [9] among others, have been used in the last years. According to [1] in the most basic level, the machines of finite states are used to model and to specify the possible behaviors of a character. Thus, a series of conditions define the events that allow the NPC to change its state, whereas a code fragment allows that the NPC acquires certain conduct associated to the state. Later, the game strategies that will execute the NPC are designed. In this case the planning routes are used generally to specify the set of behaviors that will have the NPC, where the objective is to arrive from the point A to point B. Being the A* search algorithms the most used. Although finite state machine are decomposed in a very efficient way, all the behavior of the NPC, its application is explicitly must consider all the NPC´s states, consequently resulting in huge models. Also the complexity is increased when the simultaneous behavior of all NPC´s is considered in the video game environment. Making very difficult to validate the behavior between players in order to avoid blocking situations and search situations using A* algorithm. In order to avoid these disadvantages, in this paper we use IPN to model the behavior of NPC's, which allow to capture behaviors like: causal relationship, synchronizations, asynchronies, exclusions, concurrence or parallelism, among others, in a compact way avoiding to enumerate the large amount of states that arise in the automaton. In addition, they have a mathematical support that makes suitable for analysis of qualitative and quantitative properties. In other to cope the issues mentioned before, this paper is based on the use of state feedback control for Discrete Event Systems (DES) [10], [11] where the modeling tool used is IPN during the design of the NPC's through two main stages. 1) To design the individual behavior of the NPC; and 2) To design the behavior prohibited between NPC's, to avoid blocking through the implementation of a feedback control based on control places. This paper is organized as follows. Section 2 reviews Petri nets (PN) and IPN notation and concepts used in this article. Section 3 presents the contributions of this paper, i.e. the proposal methodology for the NPC design, whereas the section 4 presents a case of study (game of strategy) to illustrate the use of the methodology in the design of a video game. Finally, section 5 provides conclusions and future work. II. PETRI NETS AND INTERPRETED PETRI NETS CONCEPTS AND PROPERTIES This section presents a review the main concepts of the PN and IPN formalism used in this paper. An interested reader can consult [12], [13] and [14] for more details. A. Petri nets Definition 1. A PN system is a pair ) , ( 0 M N where ) , , , ( O I T P N = is a bipartite digraph that specifies the net structure and + Z P M : 0 is the initial marking. Each element of N is defined as follows } , , , { 2 1 n p p p P = is a finite set of places; } , , , { 2 1 m t t t T = is a finite set of transitions; + × Z T P I : and + × Z T P O : are functions representing the weighted arcs going form places to Modeling methodology for NPC’s using interpreted Petri Nets and feedback control* A. Santoyo-Sanchez 1 , M. A. Pérez-Martínez 1 , C. De Jesús-Velásquez 2 , L.I. Aguirre-Salas 3 , M.A. Alvarez-Ureña 4 1 Department of Computing, Universidad de Guadalajara – CUCEI, Guadalajara, Jalisco, México 2 Compatibility Validation, Intel Tecnología de México S.A., Tlaquepaque, Jalisco, México 3 Department of Engineering, Universidad de Guadalajara – CUCSUR, Autlán de Navarro, Jalisco, México 4 Department of Industrial Engineering, Universidad de Guadalajara – CUCEI, Guadalajara, Jalisco, México Phone (33) 36398038 E-mail: [email protected] 2010 7th International Conference on Electrical Engineering, Computing Science and Automatic Control (CCE 2010) Tuxtla Gutiérrez, Chiapas, México. September 8-10, 2010. IEEE Catalog Number: CFP10827-ART ISBN: 978-1-4244-7314-4 978-1-4244-7314-4/10/$26.00 ©2010 IEEE 369

Upload: others

Post on 18-Dec-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modeling methodology for NPC’s using interpreted Petri Nets ...professor.unisinos.br/linds/simul/paperpetri3.pdfFor the developers of NPC's Artificial Intelligence (AI) has come

*Supported by project PROMEP 103.5/09/1158

Abstract ––In the context of video games design, Artificial Intelligence (AI) a broad of techniques have been used to generate the behavior of Non-Players Characters (NPC’s). In this document, is explored the use of Supervisory control in Discrete Event Systems for design the behavior of NPC’s, where the interaction between them it is not blocking. The modeling tool used is Interpreted Petri Nets (IPN) which are an extension of Petri Nets (PN) allow to relate input signals and output signals for PN models.

Keywords –– Feedback control, Non-player characters,

Petri Nets, Supervisor using p-invariant.

I. INTRODUCTION In the sorts of video games of adventures and strategies, the hero and/or main character is controlled generally by the user of the game. Whereas the rest of the characters are programmed, some of them have the roll to play like opponents; when these simulate to be an intelligent character NPC's are used. For the developers of NPC's Artificial Intelligence (AI) has come to mean the broad range of used techniques to generate the behavior of these adversaries, the units of equipment, battlefield, or any other thing that simulate intelligence [1]. Some of these techniques, such as finite state machines [2], [3], search algorithms like A * [4], [5], [6], methods based on software engineering [7], [8], dynamic tables of probability [9] among others, have been used in the last years. According to [1] in the most basic level, the machines of finite states are used to model and to specify the possible behaviors of a character. Thus, a series of conditions define the events that allow the NPC to change its state, whereas a code fragment allows that the NPC acquires certain conduct associated to the state. Later, the game strategies that will execute the NPC are designed. In this case the planning routes are used generally to specify the set of behaviors that will have the NPC, where the objective is to arrive from the point A to point B. Being the A* search algorithms the most used. Although finite state machine are decomposed in a very efficient way, all the behavior of the NPC, its application is explicitly must consider all the NPC´s states, consequently resulting in huge models. Also the complexity is increased when the simultaneous behavior of all NPC´s is considered

in the video game environment. Making very difficult to validate the behavior between players in order to avoid blocking situations and search situations using A* algorithm. In order to avoid these disadvantages, in this paper we use IPN to model the behavior of NPC's, which allow to capture behaviors like: causal relationship, synchronizations, asynchronies, exclusions, concurrence or parallelism, among others, in a compact way avoiding to enumerate the large amount of states that arise in the automaton. In addition, they have a mathematical support that makes suitable for analysis of qualitative and quantitative properties.

In other to cope the issues mentioned before, this paper is based on the use of state feedback control for Discrete Event Systems (DES) [10], [11] where the modeling tool used is IPN during the design of the NPC's through two main stages. 1) To design the individual behavior of the NPC; and 2) To design the behavior prohibited between NPC's, to avoid blocking through the implementation of a feedback control based on control places.

This paper is organized as follows. Section 2 reviews Petri nets (PN) and IPN notation and concepts used in this article. Section 3 presents the contributions of this paper, i.e. the proposal methodology for the NPC design, whereas the section 4 presents a case of study (game of strategy) to illustrate the use of the methodology in the design of a video game. Finally, section 5 provides conclusions and future work.

II. PETRI NETS AND INTERPRETED PETRI NETS CONCEPTS AND PROPERTIES

This section presents a review the main concepts of the PN and IPN formalism used in this paper. An interested reader can consult [12], [13] and [14] for more details. A. Petri nets

Definition 1. A PN system is a pair ),( 0MN where ),,,( OITPN = is a bipartite digraph that specifies the net

structure and +→ ZPM :0 is the initial marking. Each element of N is defined as follows },,,{ 21 npppP …= is a finite set of places; },,,{ 21 mtttT …= is a finite set of transitions; +→× ZTPI : and +→× ZTPO : are functions representing the weighted arcs going form places to

Modeling methodology for NPC’s using interpreted Petri Nets and feedback control*

A. Santoyo-Sanchez1, M. A. Pérez-Martínez1,

C. De Jesús-Velásquez2, L.I. Aguirre-Salas3, M.A. Alvarez-Ureña4 1Department of Computing, Universidad de Guadalajara – CUCEI, Guadalajara, Jalisco, México

2Compatibility Validation, Intel Tecnología de México S.A., Tlaquepaque, Jalisco, México 3Department of Engineering, Universidad de Guadalajara – CUCSUR, Autlán de Navarro, Jalisco, México

4Department of Industrial Engineering, Universidad de Guadalajara – CUCEI, Guadalajara, Jalisco, México

Phone (33) 36398038 E-mail: [email protected]

2010 7th International Conference on Electrical Engineering, Computing Science and Automatic Control (CCE 2010) Tuxtla Gutiérrez, Chiapas, México. September 8-10, 2010.

IEEE Catalog Number: CFP10827-ART ISBN: 978-1-4244-7314-4 978-1-4244-7314-4/10/$26.00 ©2010 IEEE

369

Page 2: Modeling methodology for NPC’s using interpreted Petri Nets ...professor.unisinos.br/linds/simul/paperpetri3.pdfFor the developers of NPC's Artificial Intelligence (AI) has come

transitions and from transitions to places, rinitial marking of PN 0M is a function thaplace of N a non-negative number of tokblack dots inside the places.

A PN structure N can be represented matrix mnjicC ×= ][ , , where ),(, jiji ItpOc −=

jt• = { ip | 0),( ≠ji tpI } and •jt = { ip | Othe set of input and output places of respectively, which are denominated psuccessors of jt respectively. Analogously,and output transitions of a place ip a

0),( ≠ji tpI } and •ip = { 0),( ≠ji tpO } rePN system, a self-loop is a

0),(),(, =−= jijiji tpItpOc and ),( ≠ji tpOIn this work the self-loop structure is repmatrix mrjifF ×= ][ , , where ),(, jiji tpOf ∧=is the number of places with self-loops.

The marking at the k-th instant is often vector nkkkk pMpMpMM )()()([ 21=marking M can be represented by

],,,,2,1[ )()()()( 21 ni pMpMpMpM ni whereomitted if 0)( =ipM and exponents ( pM

omitted. For example, a marking M 02[=

represented by the list M = [ 4,3,12 ]. A transition jt is enabled at marking

),()( jiik tpIpM ≥ ; when an enabled transithen a new marking 1+kM is reached. Thiscomputed as kkk CvMM +=+1 , where kvfiring vector whit 1)( =jvk when jt is

0)( =ivk if ji ≠ and jt is not fired, kv vector; the equation kkk CvMM +=+1 is calequation.

A firing sequence of a PN system

transition sequence kji ttt …=σ such as M

⎯→⎯ktkM .. The firing language of ( ,N

( )0,MNL = ∧=σσ kji ttt …{ ⎯⎯→⎯ it MM 10

while the Parikh vector mZT )(: +→σ of σ mto the number of occurrences of t in reaching kM from 0M by firing an enabledenoted by ⎯→⎯σ

0M kM . The set of all reafrom 0M is ),( 0MNR = { kM | ⎯→⎯σ

0M( )0,MNL } and it is called reachability set.

Definition 2: A p-invariant Y of a Psolution to equation 0=CY T . Support p-in

}0)(|{|| ≠= jiji pYpY .

respectively. The at assigns to each kens, depicted as

by its incidence ),( ji tpI . The sets

0),( ≠ji tpO } are a transition jt

predecessors and , the sets of input are ip• = { jt |espectively. In a relation where 0≠ , 0),( ≠ji tpI .

presented by the ),( ji tpI∧ , and r

represented by a T]) . Hereafter, a

y a list M = e i-th item is

1) =ip are also T]110 can be

kM if Ppi ∈∀ , ition jt is fired, s new marking is k is an m-entry fired once and is called Parikh lled the PN state

m ),( 0MN is a

⎯→⎯itM0 ⎯→⎯jtM1

)0M is the set ⎯→⎯ jt ⎯→⎯kt

kM , maps every Tt ∈

σ . The fact of ed sequence σ is achable markings → kM and σ ∈

PN is a rational nvariant iY is set

Example 1: Consider the PN of of 8 places },,,{ 821 pppP …= and 5

⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢

=C

(a) Fig. 1.a) Petri Net System A, b) Incidence m

},,,{ 521 tttT …= . The incidence ma1b. The sets of input and output pland •1t = { 32 , pp } respectivel

TM ]11011020[0 = or set of enabled transitions at 0M itransition 3t fires the net reache

8,7,6,5 2 ]. A p-invariant of the

]00200012[ and it}, 62 pp .

B. Interpreted Petri nets

Definition 3. An IPN s),,,,,'( ϕΨλΦΣ= NQ where (' NN =

},,,{ 21 rααα=Σ … is the input alphabsymbol; },,,{ 21 sδδδ=Φ … is the outwhere iδ is an output symbol; :λ Tthat assigns an input symbol to eawith the following constraint: t∀

}0),(),( ≠= kiji tpItpI and both λ)()( kj tt λ≠λ . In this case, ε repre

event. If ε≠λ )( it then transition itotherwise uncontrolled. cT and uT aand uncontrolled transitions, respeca labeling function of places that aor the null event ε to each place

kip δ=Ψ )( if ip represents an outε=Ψ )( ip . In this case (|{ Ψ= im ppP

place set and || mPq = is the numbWhile nmP = P \ mP is the set oFinally, qZMNR )(),(: 0

+→ϕ is a fuoutput vector to every reachable follows: Pmkk MM |)( =ϕ , where M

kM over mP i.e. if kM = k pM )([ 1

f Fig. 1a. The net consists 5 transitions

⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥

−−

−−

1-1 0 0 0 0 11 0 0 10 1 0 0 0 1-0 1 0 0 0 1-1 0 0 0 0 11 0 0 20 2 1 0 0 0 1

(b) matrix of Petri Net System A.

atrix is illustrated in Fig. laces of 1t are 1t• = { 1p } y. The initial marking is

0M = [ 8,7,5,4,22 ]. The s },{)( 430 ttME = . When s the marking 1M = [e system A is =0Y

s support is ,{|| 10 pY =

system is a 6-tuple ), 0MN is a PN system;

bet, where iα is an input tput alphabet of the net,

}{ε∪Σ→T is a function ach transition of the net,

Ttt kj ∈, , kj ≠ , if ip∀ ε≠)( jt , ε≠λ )( kt , then

esents an internal system is said to be controlled, are the sets of controlled ctively. }{: ε∪Φ→Ψ P is assigns an output symbol e of the net as follows: tput signal, in otherwise

}) ε≠ip is the measurable ber of measured places. of non-measured places. unction that associates an

marking of the net as PmkM | is the projection of

Tnkk pMpM ])()( 2

2010 7th International Conference on Electrical Engineering, Computing Science and Automatic Control (CCE 2010) Tuxtla Gutiérrez, Chiapas, México. September 8-10, 2010.

IEEE Catalog Number: CFP10827-ART ISBN: 978-1-4244-7314-4 978-1-4244-7314-4/10/$26.00 ©2010 IEEE

370

Page 3: Modeling methodology for NPC’s using interpreted Petri Nets ...professor.unisinos.br/linds/simul/paperpetri3.pdfFor the developers of NPC's Artificial Intelligence (AI) has come

and mP = },,,{ hji ppp … then T

hkjkik pMpMpM ])()()([ . Notice thlinear and can be represented as a matrix ϕeach row ),( •ϕ k of this matrix is an elwhere 1),( =ϕ ik if place ip is the k-th meotherwise 0),( =ϕ ik and it is called non- me

In this paper, a measured place is depiccircle, while a non-measured place is depcircle. Similarly, uncontrollable transitionsfilled bars and controllable transitions aunfilled bars. Also, ),( 0MQ will be u

),,,,,'( ϕΨλΦΣ= NQ to emphasize the factinitial marking in an IPN.

Example 2: Consider the IPN shown in and output alphabets are },{ ba=Σ andrespectively. Functions Ψ and λ are given

i 1 2 3 4 5 6)( ipΨ 1δ ε ε ε 2δ 3δ

Thus, the controlled transitions are Tc

uncontrolled ones are },,{ 432 tttTu = . The are },,{ 651 pppPm = and the non

},,,,{ 87432 pppppPnm = . In this case, the othe matrix:

⎢⎢⎢

⎡=ϕ

100000010000000001

The initial output is My 10[)( 00 =ϕ=Similarly to a PN, in an IPN system, a

enabled at making kM if ∀ pi P∈ ; Mhowever jt has fire conditions. When jt iis controllable for that jt fire, it is necessasignal ε≠λ )( jt must be given as input. enabled transition jt is uncontrollable, theIn both cases, when a transition jt is fired

),(1 jkk tCMM •+=+ is reached and the)( 11 ++ ϕ= kk My is observed. Also, the firin

firing language is computed and denoted as To enhance the fact that there exists a

in an IPN ),,,,,'( ϕΨλΦΣ= NQ in this pape),( 0MQ .

Next some concepts related to concontrol useful in the development ofmethodology and a case of study appear.

III. MODELING DESCRIPTIONIn this paper, feedback control proposed

k 1 2 3 4)( ktλ a ε ε ε

PmkM | =

hat function ϕ is nqij ×ϕ=ϕ ][ , where

lementary vector easured place and easured. ted as an unfilled

picted as a filled s are depicted by are depicted by used instead of t that there is an

Fig. 2. The input d },,{ 321 δδδ=Φ

by: 6 7 8

(1) 3 ε ε

(2)

},{ 51 tt= and the measured places

n-measured are output function is

⎥⎥⎥

001000000

(3)

T]0 . a transition jt is kM (pi) ≥ I(pi, tj) s enabled and jt ary that the input Otherwise when

en it can be fired. d a new marking output symbol ng sequence and in PN system.

an initial marking er it is denoted as

ntrollability and f the modeling

N d by [10] is used

Fig. 2) Interpreted Petri N¶

for compute a controller blockingAccording to Supervisory controlsupervisory control [16] consists oDynamic Discrete event system (system to be controlled; 2) the resystem, called specification; and 3) supervisor, which restricts the behabehavior of the specification bycontrollable events.

In the context of NPC's the mfollowing elements. A. Modeling the game In this paper the NPC's are modthe propose methodology in [17permissive relationship between considered, since these represent bethis work they comprise the modeavoid the blockings.

Algorithm 1: Modelin

Inputs: Any. Outputs: IPN model of the game. Procedure: 1. Identify each player of the ga

variables”. In this step the stateach player. The state variabbehavior of each player for exaconsider the variables: positionIn general a state variable is den

2. Code each state variable intoone of these code values will bstate variable. In general form variable j with p “sta

},,,{ 21ijp

ijijsv valvalvalvalues i

j…= .

the state variable position for arelevant values are: room1, room

3. Code each relevant value into

5b

et System A.

g states between NPC’s. l theory [15], feedback of three elements: 1) A (DES), representing the equired behavior for the an external agent, called

avior of the system to the y the manipulation of

model description has the

deled with IPN's adapting ], in this proposal the state variables are not

ehavior restrictions and in el of the specification to

g the game.

ame and generate “sate e variable are defined for

ble are related with the ample, a player it is usual n, movement, bullets, etc. noted as i

jsv . o relevant values. Each be called a “state” of the to player i and the state

ates” is coded as: Consider for example

a player, in this case the m2, …, room7.

o a Petri net place. If the

2010 7th International Conference on Electrical Engineering, Computing Science and Automatic Control (CCE 2010) Tuxtla Gutiérrez, Chiapas, México. September 8-10, 2010.

IEEE Catalog Number: CFP10827-ART ISBN: 978-1-4244-7314-4 978-1-4244-7314-4/10/$26.00 ©2010 IEEE

371

Page 4: Modeling methodology for NPC’s using interpreted Petri Nets ...professor.unisinos.br/linds/simul/paperpetri3.pdfFor the developers of NPC's Artificial Intelligence (AI) has come

value of state variable ijsvvalues is coded into p states,

then there must exist p Petri nets places, each one to represent each different state of the state variable i.e. the set },,,{ 21

ijp

ijijsv pppp i

j…= is defined, where

|||| ij

ij svsv pvalues = . For example, if for state variable

position the relevant values are: room1, room2, …, room7 then seven Petri net place will be need to represent this codification, the set of places is {p1, p2, p3, …, p7}.

4. Define the change between the states of each state variable. If a state variable i

jsv changes from state ijxval to state ij

wval , the Petri net transition ijwxt − must be

added to Petri net model. An arc goring from the place ijxp which represents the state ij

xval to transition ijwxt −

must be added. Also an arc going form the added transition ij

wxt − to the place ijwp that represents the state

ijwval must be added. For example if the player can

travel from de room1 to room2 (represented with the places p1, p2 respectively). Then a transition must be added, in this case suppose that it is the transition t1. Next the arcs going from p1 to t1 and from t1 to p2 must be added. Thus, the change between states is captured into the model.

5. Define the initial marking. The token for each state variable must be added, in this case using the follow criteria: when the initial value of the state variable is the place ij

xp then 1)(0 =ijxpM , in other case =)(0

ijwpM 0 ,

where wx ≠ . For example, in this case suppose that player starting in the room1 then a token must be added in the place p1, thus 1)( 70 =pM and the others place representing the position of the player the marking is zero.

6. Define the interpretation. In this step the functions λ and ϕ are defined. Consider for example, that for the transition t1 the input signal O1, i.e. open door and travel to room2. While the function ϕ is de identity matriz, due to the game is composed only by measured places.

7. Synchronize the state variables. In this step the transitions representing common operations in the different state variable models are merged into a single one.

B. Modeling the specification.

In this paper proposes a methodology to capture the permissive and exclusion requirements between NPC’s as a set of linear inequalities. In the case of IPN, a linear restriction represents a limit in the number of marks that the places and that are modeled using the following algorithm. Algorithm 2: Modeling methodology of the specification

Inputs: The IPN model of the system. Outputs: The matrix of restrictions L, and the vector of limit B. Procedure: 1. Composition permissive or relational. The purpose of

this step is to obtain the causal relationship between the state variables of the system. Basically consist in adding arcs from places to transitions and back for, using the different state variables.

2. To define exclusions. In this step a set of inequities l are established expressed as bji ≤+ μμ where iμ and

jμ are the tokens for places ip and jp between different state variables corresponding to different players. b is an integer, that works as the maximum amount of tokens that must exist simultaneously in ip and jp . For instance, supposed that player1and player2 can not be in the room1 simultaneously, i.e., just one player can be inside the room, then b=1. Where the place p1 represents that player1is inside room1, while the place p8 represents that player p2 is inside room1. Then a restriction }1{ 81 ≤+∪= μμll is added to the specification, indicating that p1 and p8 cannot have tokens simultaneously.

3. Transforming the restrictions. With the purpose of using the mathematical structure of PN, in this step the set of restrictions l is transformed in the matrix nrL × and the vector rB where r is the number of restrictions and n is the number of places of the IPN model for the video game. The step lla ∈∀ do 1),( =klL a if kμ appears in the restriction al , in other case is 0, with =k

n,,2,1 … and abaB =)( .

In general, there are more types of restrictions, but never the less in this work we will only consider the definition of exclusions like part of the specification. Next an algorithm proposed in [10] is synthesized for the calculation of the supervisor.

C. Design a supervisor. In the supervisor design phase, a controlled place

control scheme is used [10]. This technique uses the linear inequalities to avoid that system reach forbidden conditions. Algorithm 3: Compute the supervisor.

Inputs: IPN of the model of the game, the matrix of restrictions L, and the vector of limit B. Outputs: A model in IPN of the close loop system with the supervisor. Procedure: 1. Transforming restrictions in inequities. Define

][ ILL = where aaI × is an identity matrix and a is the

2010 7th International Conference on Electrical Engineering, Computing Science and Automatic Control (CCE 2010) Tuxtla Gutiérrez, Chiapas, México. September 8-10, 2010.

IEEE Catalog Number: CFP10827-ART ISBN: 978-1-4244-7314-4 978-1-4244-7314-4/10/$26.00 ©2010 IEEE

372

Page 5: Modeling methodology for NPC’s using interpreted Petri Nets ...professor.unisinos.br/linds/simul/paperpetri3.pdfFor the developers of NPC's Artificial Intelligence (AI) has come

number of row in L. In this way thshould have the form baji ≤++ μμμ .

2. Defining the IPN matrix under TCLCC ][ −= where C is the incid

the IPN of the game and C represenmatrix for the system under control.

3. Defining the initial marking for control. Establish the initial mar

TLMBM ][ 00 − where 0M is the initisystem.

The application from all algorithms showis illustrated in the next case study.

IV. CASE OF STUDY: STRATEGY Fig. 3 represents the strategy game consid

of study. It is a dungeon environment, whby seven rooms (h1, h2, …, h7). Inside a dthe following elements: a player (j1), four oo3 and o4), and a reward. The behavior inside dungeon is the following.

Player (j1) has the goal of finding the from the dungeon. Also, player should avoiding to be detected by opponents. This indicated by the user game. Four opponenthave the goal of finding the player. In thisgame consists in moving and watching betrooms, which is computed by an algorithmcontains the model for the all behavior possand opponents, in a future work the strategywill present.

Using the algorithm 1 the fist step is player of the game and generate “sateillustrate this step consider the player gamvariable “position”. Next, the second stepstate variable into relevant values, in this ccoded in the values h1, h2, …, h7, i.e. the plaeach dungeon’s room. The third step each coded into a Petri net place, it is showed in contains the places p1, p2, …, p7. In the possible travel between rooms is defined, player can travel from the room1 to room2 must be added, in this case the transition isfrom p1 to t1 and from t1 to p2 are added, ithe rest of transitions and arcs will added.

Fig. 3) Component of the game.

he restrictions al

control. Define dence matrix for nts the incidence

system under rking as =0M

al marking of the

wn in this section

GAME dered in this case

hich is composed dungeon there are opponents (o1, o2, of each element

reward and exit achieve its goal strategy game is s (o1, o2, o3 y o4)

s case its strategy tween dungeon’s . This paper only

sible of the player y game algorithm

to identify each e variables”. To me and the state is to code each

case “position” is ayer can be inside

relevant value is Fig. 4a in which fourth step the for example the then a transition

s t1. Now the arcs in a similar form

Fig. 4.a) Places for the values of the state v

The Petri net model of the playe4b note that this model contains player is inside the room1.

Next an extension to PN is dextension consists in assigning inpPN models. IPN is defined as followalphabets

,,,,,,{ 25345343521221 −−−−−−−=Σ aaaaaaa

}57−a and },,,,,,{ 7654321 δδδδδδδ=ΦΨ and λ are given by:

¶ i 1 2 3 4

)( ipΨ 1δ 2δ 3δ 4δ

2 3 21−a 12−a 52−a

6 7 8 35−a 34−a 43−a

11 57−a

All transitions are controllemeasured. Thus the output functionIn the final step it is necessary tvariables, in this case it step is not n

The algorithm 1 is used to defopponent. Fig. 5a and Fig. 5b shopponents denominated A and B IPN model of the strategy game is model of the elements: player and o

Fig. 5.a) Opponet A IPN model. b) O

k 1)( ktλ

k)( ktλ

k)( ktλ

variable “position”. b) Player PN.

er is showed in the figure the initial marking, the

defined in this case the put and output signals to ws. The input and output

are: ,,,,, 567565352 −−−− aaaa

} respectively. Functions

5 6 7 (4) 5δ 6δ 7δ

4 5 25−a 53−a (5)

9 10 65−a 56−a (6)

12 75−a (7)

ed and all places are n ϕ is an identity matrix. to synchronize the state

necessary. fine the behavior of each how IPN model by two respectively. Finally the composed by all the IPN pponents.

Opponent B IPN model.

2010 7th International Conference on Electrical Engineering, Computing Science and Automatic Control (CCE 2010) Tuxtla Gutiérrez, Chiapas, México. September 8-10, 2010.

IEEE Catalog Number: CFP10827-ART ISBN: 978-1-4244-7314-4 978-1-4244-7314-4/10/$26.00 ©2010 IEEE

373

Page 6: Modeling methodology for NPC’s using interpreted Petri Nets ...professor.unisinos.br/linds/simul/paperpetri3.pdfFor the developers of NPC's Artificial Intelligence (AI) has come

To capture the permissive and exclusion requirements between NPC’s as a set of linear inequalities is used the algorithm 2. In this case the restriction is the following: “In each room only must be an opponent”. By the algorithm 2 ¶the linear restriction is defined as:

; ;

(8)

(9)

Finally using the algorithm 3 the closed-loop produced guarantees the restriction rule, which is illustrated in the Fig. 6 note that the control places are out the box for each opponent.

V. CONCLUSIONS This paper presents a novel technique for model NPC’s based on IPN and controlled place. The procedure includes a method to capture restriction operation in term of the linear equations. As future work the IPN model obtained with this methodology will analyze to establish the control law based in feedback supervisory control to simulate intelligence in the NPC’s.

VI. ACKNOWLEDGMENT This work was supported by SEP in the scope of the project PROMEP 103.5/09/1158.

Fig. 6. IPN Control places among opponet A and opponent B.

VII. REFERENCES [1] M. van Lent, “Game Smarts”, Computer, Vol. 40, pp 99-101, April

2007. [2] W. M. Wonhan, and P.J. Ramadge, “On the Supremal Controllable

Sublanguage of a Given Language”, SIAM Journal on Control and Optimization, Vol. 25, No.3, pp. 635-659, 1987.

[3] J.E. Hopcroft and J.D. Ullman. “Introduction to automata theory, languages, and computation”, Ed. Addison-Wesley, 1979 [4] P.E. Hart, L.J. Nilsson and B. Raphael. “A formal basis for the heuristic determination of minimum cost paths”, IEEE Transactions on Systems Science and Cybernetics, Vol. 4, No. 2, pp. 100-107, 1968.

[5] P.E. Hart, L.J. Nilsson, and B. Raphael. Correction to “A formal basis for the heuristic determination of minimum cost paths”, SIGART Newsletter, No. 37, pp. 28-29, 1932.

[6] V. Kumar, and D. S. Nau. “A general branch-and-bound formulation for AND/OR graph and game tree search”, Search in Artificial Intelligence, pp. 91-130, Ed. Springer-Verlag, 1988.

[7] M. McNaughton, M. Cutumisu, D. Szafron, J. Schaeffer, J.Redford, and D. Parker. “ScriptEase: Generating Scripting Code for Computer Role-Playing Games”, in Proc.19th IEEE International Conference on Automated Software Engineering ASE´04, 2004, Linz, Austria, pp. 386 – 387.

[8] L. Wei-Po, L. Li-Jen, and C. Jeng-An; “A Component-Based Framework to Rapidly Prototype Online Chess Games for Home Entertainment”; in Proc. IEEE International Conference on Systems, Man, and Cybernetics SMC’06, 2006, Taipei, Taiwan, Vol. 5, pp 4011-4016, 2006.

[9] W. Yingxu. “Mathematical models and properties of games”. in Proc. Of the Fourth IIEEE Conference Cognitive Informatics ICCI´05, 2005, Irvine, CA, USA, pp. 294-300.

[10] K. Yamalidou, J. Moody, M. Lemmon, and P. Antsaklis, “Feedback Control of Petri Nets Based on Place Invariants”, Automatica, Vol. 32, No.1, pp. 15-28, 1996.

[11] R. Campos-Rodríguez, M. Alcaraz-Mejia, and J. Mireles-Garcia. “Supervisory Control of Discrete Event Systems using observers”, in Proc. Of the 15th IEEE Mediterranean Conference on Control & Automation MED´07, 2007, Athens, Greece , pp. 1-7.

[12] T. Murata, “Petri nets: Properties, analysis, and application”, in Proc. Of the IEEE, Vol. 77, No.4, pp. 541-580, 1989.

[13] J. Desel, J. Esparza and C. J. van Rijsbergen, Free choice Petri nets, pp. 1-5, Ed. Cambridge University Press, 2005.

[14] M. E. Meda, A. Ramirez and A. Malo, “Identification in discrete event systems”, in Proc.1998 IEEE International Conference Systems, Man and Cybernetics, SMC 1998,San Diego CA., pp. 740-745.

[15] P.J. Ramadge, and W. M. Wonhan, “Supervisory Control of a Class of Discrete Event Processes”, SIAM Journal on Control and Optimization, Vol. 25, No.1, pp. 206-230, 1987.

[16] A. Santoyo-Sanchez, A. Ramírez-Treviño, C. De Jesús Velásquez, L.I. Aguirre-Salas, “Step State-feedback Supervisory Control of Discrete Event Systems using Interpreted Petri Nets”, in Proc.13th IEEE International Conference on Emerging Technologies and Factory Automation, ETFA 2008, Hamburg Germany, pp. 926 – 933.

[17] K. L. Muñoz Pizano, “Restablecimiento de Sistemas Eléctricos con asistencia de un Sistema Experto”, Master disertation, Ed. Universidad de Guadalajara Maestrìa en Sistemas de Información, Julio 2007.

⎪⎪⎪⎪

⎪⎪⎪⎪

⎪⎪⎪⎪

⎪⎪⎪⎪

≤μ+μ≤μ+μ≤μ+μ≤μ+μ≤μ+μ

≤μ+μ≤μ+μ

=

2,2,2,2,2

,2,2

2114

2013

1912

1811

1710

169

158

l T2] 2 2 2 2 2 [2B =

⎥⎥⎥⎥⎥⎥⎥⎥⎥

⎢⎢⎢⎢⎢⎢⎢⎢⎢

=

1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 00 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 00 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 00 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 00 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 00 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 00 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0

L

Opponent B

p22p10

p 17

p23

p24p25

p26

p27

p28

p11

p12

p 8 p9

p14 p 13

p 18

p 15

p 19

p 21 p 20 p 16

t25

t26

t35

t36

t30

t29 t27 t28 t34

t33

t32 t31

t19 t20

t22

t21 t16

t15

t17t18

t13 t14

t24 t23

Opponent A

2010 7th International Conference on Electrical Engineering, Computing Science and Automatic Control (CCE 2010) Tuxtla Gutiérrez, Chiapas, México. September 8-10, 2010.

IEEE Catalog Number: CFP10827-ART ISBN: 978-1-4244-7314-4 978-1-4244-7314-4/10/$26.00 ©2010 IEEE

374