• No results found

A Simplified Representation of Finite State Machines by Generic States

N/A
N/A
Protected

Academic year: 2022

Share "A Simplified Representation of Finite State Machines by Generic States"

Copied!
3
0
0

Loading.... (view fulltext now)

Full text

(1)

http://www.diva-portal.org

This is the published version of a paper presented at Nicograph International 2014, Visby, Sweden, May

2014.

Citation for the original published paper:

Fridenfalk, M. (2014)

A Simplified Representation of Finite State Machines by Generic States.

In: Nicograph International 2014 (pp. 163-164).

N.B. When citing this work, cite the original published paper.

Permanent link to this version:

http://urn.kb.se/resolve?urn=urn:nbn:se:uu:diva-235501

(2)

A Simplified Representation of Finite State Machines by Generic States

Mikael Fridenfalk

Department of Game Design

Uppsala University Visby, Sweden

mikael.fridenfalk@speldesign.uu.se

Abstract—Wildcards are of significant value for the simplification of state diagrams and truth tables for the representation of finite state machines. In this paper a new type of wildcard is introduced, called a generic state, which without any loss of information may further simplify such representations.

Keywords-finite state machine; minimization; sequential au- tomata; simplification; state diagram; truth table; wildcard

I. INTRODUCTION

The Finite State Machine (FSM) is a universal tool that finds applications in many fields from analog and digital electronics [3,5], and artificial intelligence (AI) [8], to biotechnology [4].

In the development of computer games, FSMs are often used for the implementation of non-player characters [2,9], and in network programming. An FSM, a special case of a sequential machine [1], or automata [7], can be fully specified by a state diagram or a truth table [6]. An FSM may in general be described as a system with a limited number of states, where transitions between states are defined by logical conditions or rules that are evaluated at each state update. These logical conditions are based on the input values of the FSM as a function of the current state.

Commonly, in discrete-time systems, the current state may be denoted as z and next state as z + 1. The output values of an FSM may be defined as a function of the current state, or more generically as a combined function of the current state and the input values. The representation of an FSM is however in general implementation-neutral in the sense that no matter in which order the conditions are evaluated, the result is expected to be the same. In the general case, on an implementation level in computer programming, the transitional conditions for FSMs are often evaluated sequentially, why an FSM can be implemented in many different ways (without altered behavior).

There are many applications where an FSM can be designed graphically. An example is Stateflow [11], which in addition, by the assistance of the Simulink Coder [10], is able to convert the Stateflow diagram directly to code in C or C++, for compilation and execution on e.g., an embedded system.

II. WILDCARDS

Wildcards are presently used for the representation of FSMs to decrease the size of state diagrams and truth tables [7]. As an example, Table I shows a truth table for an FSM with originally 40 lines (3 Boolean inputs yields 23 lines for each

z i0 i1 i2 z + 1

0 1 0

0 0 1 1

0 0 0 0

1 1 0

1 0 1 1

1 0 0 0 1

1 0 0 1 2

2 1 0

2 0 1 1

2 0 0 0 2

2 0 0 1 3

3 1 0

3 0 1 1

3 0 0 0 3

3 0 0 1 4

4 1 0

4 0 1 1

4 0 0 4

Table I: As a first step, a 40 line table is reduced to 18 lines by the application of wildcards (∗) to the input values i0− i2.

z i0 i1 i2 z + 1

0 0 1 1

1 1 0

1 0 0 1 2

2 1 0

2 0 1 1

2 0 0 1 3

3 1 0

3 0 1 1

3 0 0 1 4

4 1 0

4 0 1 1

Table II: In a second step, the previous table is here reduced to 11 lines by elimination of the redundant lines. This is the maximum level of simplification that can be obtained by standard minimization techniques. This table corresponds to the state diagram in Fig. 1.

state, multiplied by 5 states), here reduced to 18 lines. In digital electronics, an uppercase X is often used to denote a wildcard. A wildcard is in this specific context a symbol that may be substituted for 0 or 1 without any consequences. Since a wildcard is often denoted by an asterisk (∗) in computer programming (such as in the Unix operating system), the same notation has also been used in this paper.

A wildcard is however, as a rule, typically only used to simplify the transitional conditions in the representation of an NICOGRAPH International 2014

− 163 −

(3)

FSM by a truth table. The use of wildcards in state diagrams is nominally implicit, as reflected by the example in Fig. 1, corresponding to Table II, where the loop transitions from each state to itself (i.e. no change), included in Table I, have been omitted. Such simplifications can be performed without information loss, but only if it is clear from the context that any transitional conditions that have not been defined, refer to a loop from a state to itself.

s2

s3

s4

s1

s0

b

a

i0

i0

i0

b

b = ¬i0∧ i1

b

i0

a a

Figure 1: A simplified representation of an FSM, reduced by standard methods. Here, a = ¬i0∧ ¬i1∧ i2.

s2

s3

s4 s1

s0

∗ a

a = ¬i0∧ ¬i1∧ i2

a

i0

¬i0∧ i1

Figure 2: The same FSM as in previous figure, further simplified by a generic state, denoted by an asterisk (∗).

z i0 i1 i2 z + 1

1 0

0 1 1

1 0 0 1 2

2 0 0 1 3

3 0 0 1 4

Table III: By the application of a generic state (denoted by an asterisk in the z column), Table II is in a final step here reduced to 5 lines.

This table corresponds to Fig. 2, which represents a lossless reduction of the state diagram in Fig. 1.

III. FURTHERSIMPLIFICATION

This paper presents a proposal to extend the use of wildcards from input values solely, to states. The idea is that a generic state could similarly be denoted with an asterisk to represent any arbitrary state of the FSM.

This notation has for some years been included in a univer- sity course in AI for game programming at Uppsala University (Campus Gotland), where it has saved much extra work for students in the completion of state diagrams. As an example, the state diagram in Fig. 1, which has already been reduced by two steps in Table II, was further reduced in Fig. 2, without any information loss.

As shown in Fig. 2, using a generic state, while the number of states was increased by one, the number of transitions was in this example reduced by over 50%. Such transitions are common in the design of FSMs for AI-systems in computer games (for instance to reset a non-player character to its original state or in general any state that is a destination for a multiple number of states).

IV. CONCLUSION

The new proposal using a generic (or wildcard) state seems to work well for the simplification of state diagrams and truth tables. Since the type of transitions that a generic state is able to simplify is common in practical applications, this method could potentially contribute to streamline the representation of FSMs, particularly for systems of high complexity.

REFERENCES

[1] J. A. Brzozowski, “Sequential Machine”, Encyclopedia of Computer Science, 4th ed., Wiley, 2003.

[2] M. Buckland, Programming Game AI by Example, Jones & Bartlett Learning, 2004.

[3] J. Davis and R. Reese, Finite State Machine Datapath Design, Opti- mization, and Implementation, Morgan & Claypool, 2008.

[4] R. Gao, W. Hu, and T. J. Tarn, “The Application of Finite State Machine in Modeling and Control of Gene Mutation Process”, Transactions on NanoBioscience, IEEE, vol. 12, no. 4, pp. 265-274, 2013.

[5] K. Jezernik, R. Horvat, and J. Harnik, “Finite-State Machine Motion Controller: Servo Drives”, Industrial Electronics Magazine, IEEE, vol. 6, no. 3, pp. 13-23, 2012.

[6] A. Maruoka, Concise Guide to Computation Theory, Springer London, 2011.

[7] E. J. McCluskey, “Switching Theory”, Encyclopedia of Computer Sci- ence, 4th ed., Wiley, 2003.

[8] D. O. Sales, D. O. Correa, L. C. Fernandes, D. F. Wolf, and F. S. Osorio,

“Adaptive Finite State Machine Based Visual Autonomous Navigation System”, Engineering Applications of Artificial Intelligence, vol. 29, pp. 152-162, 2014.

[9] B. Schwab, AI Game Engine Programming, 2nd ed., Charles River Media, 2009.

[10] Simulink Coder, Mathworks, Inc. [Online]. Available: http://www.

mathworks.se/products/simulink-coder/

[11] Stateflow, Mathworks, Inc. [Online]. Available: http:// www.mathworks.

com/products/stateflow/

NICOGRAPH International 2014

− 164 −

References

Related documents

This section presents the resulting Unity asset of this project, its underlying system architecture and how a variety of methods for procedural content generation is utilized in

46 Konkreta exempel skulle kunna vara främjandeinsatser för affärsänglar/affärsängelnätverk, skapa arenor där aktörer från utbuds- och efterfrågesidan kan mötas eller

The increasing availability of data and attention to services has increased the understanding of the contribution of services to innovation and productivity in

Tillväxtanalys har haft i uppdrag av rege- ringen att under år 2013 göra en fortsatt och fördjupad analys av följande index: Ekono- miskt frihetsindex (EFW), som

Re-examination of the actual 2 ♀♀ (ZML) revealed that they are Andrena labialis (det.. Andrena jacobi Perkins: Paxton & al. -Species synonymy- Schwarz & al. scotica while

For these reasons along with the primary limitation of SRT (i.e., narrow focus of what is repression and violence), that there are many different types of violence being utilized by

The lost rights to tax land over the period 1600’s – 1900’s through delimitation of land and other proceedings as well as the transformation of Lapp tax land to

Swedenergy would like to underline the need of technology neutral methods for calculating the amount of renewable energy used for cooling and district cooling and to achieve an