<!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 />
    <article-meta>
      <title-group>
        <article-title>Takagi-Sugeno fuzzy systems as a method of acting opponents in games</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Karolina Ke ̨sik Institute of Mathematics Silesian University of Technology Kaszubska 23</institution>
          ,
          <addr-line>44-100 Gliwice</addr-line>
          ,
          <country country="PL">Poland</country>
        </aff>
      </contrib-group>
      <fpage>5</fpage>
      <lpage>9</lpage>
      <abstract>
        <p>-Controlling a hero in 2D or 3D games can occur on different rules. To increase the level of gameplay, there are objects in the entire game with which the player can interact. Such an action is quite often implemented using artificial intelligence, which has been growing in recent years. In this paper, we propose using a model of a fuzzy system to move objects in the games. Movement takes place on the principle of moving between two points, where the first one is the player's position and the second is destination point. The paper presents the mathematical model of the Takagi-Sugeno system and tests for the correctness of the movement.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>I. INTRODUCTION</p>
      <p>The field of artificial intelligence is developing rapidly,
which is visible in various applications around us. Especially
in devices of the Internet of Things, whose times are coming
thanks to the 5G network. Enabling communication between a
huge number of devices results in acquiring and generating a
large amount of digital information. This information must be
processed so that it can be forwarded or take some decisions
based on it. More often, such problems are solved using
artificial intelligence (AI) techniques.</p>
      <p>In practice, almost everyone uses a smartphone, on which
various applications are installed. Especially often of these
applications are games that use AI methods. Their practical
use is based on the movement of opponents or the
generation of boards/environment. The movement can be simulated
using various tools such as artificial neural networks, fuzzy
controllers and heuristic algorithms. In this paper, we show
the simple use of the Takagi-Sugeno system to simulate the
movement of objects.</p>
    </sec>
    <sec id="sec-2">
      <title>A. Related works</title>
      <p>
        Heuristic methods are used only to simulate player action
[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], but also to create a game environment. An example is the
creation of labyrinths [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. The same algorithms can be used
for play-testing in various games, especially in card ones [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
Quite often, there is a need for the opponent’s intelligence to
be trained. This is a popular situation with games that have
large amounts of different rules, such as chess [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] or go [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
The second of these games is much more difficult, which made
training AI quite problematic. In [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] deep learning of neural
c 2019 for this paper by its authors. Use permitted under Creative
Commons License Attribution 4.0 International (CC BY 4.0).
networks and tree searching were used to obtain impressive
results. A year later, the authors presented a learning algorithm
without the need for knowledge given by programmers [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
Again in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], the authors presented idea to train deep neural
networks to play othello ie a game on a board with 64 fields
and black and white verticals. An interesting idea is to extract
knowledge from how others play the game [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], or using the
idea of games in other areas, such as medicine. An example
is creating decision systems using game theory and rough sets
[
        <xref ref-type="bibr" rid="ref9">9</xref>
        ].
      </p>
      <p>
        The idea of multi-agents and collective using many objects
is a frequent use in games. The results of research on this
topic are presented in [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] using fuzzy logic. This field
of science can also be used in solving various problems [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ],
[
        <xref ref-type="bibr" rid="ref13">13</xref>
        ].
      </p>
      <p>
        Fuzzy logic was proposed by L. A. Zadeh in 1965, where
unlike classical sets, partial membership is allowed [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. So
the sets can be described using the adaptation function
      </p>
      <p>A : X ! [0; 1]:
Fuzzy set A on space X can also be described by a set
of ordered pairs (x; A(x)), where A(x) is the degree of
ownership of the x object to the fuzzy set A</p>
      <p>A = f(x; A(x)); x 2 X; A 2 [0; 1]g:
Zadeh suggested another notation for fuzzy sets. For the
discrete space X, we have</p>
      <sec id="sec-2-1">
        <title>Again, for continuous space X</title>
        <p>A = X</p>
        <p>A(x)=x
A =</p>
        <p>A(x)=x
x2X
Z</p>
        <p>X
(1)
(2)
(3)
(4)
triangular
variables of the system into the values of its output variables.
8 0;
&gt;&gt; x
&gt;
&gt;
A(x; a; b; c) = &lt; cb
&gt;
&gt;&gt; c
&gt;
: 0;
a
a
x
b
x</p>
        <p>a;
; a &lt; x
; b &lt; x
x &gt; c
b</p>
        <p>c).
(x m)2
2 2 ;
where a, b, c are parameters (a
Gaussian</p>
        <p>A(x; m; ) = e
where m; are parameters. For x = m, this function
assumes the value 1 and the parameter &gt; 0 determines
the width of the fuzzy set.
inverse trapezoid</p>
        <p>A(x; a; b; c; d) =
8 b
&gt;
&gt;&gt;&lt; b</p>
        <p>0
&gt; x
&gt;
&gt;
: d
x
a
c
c
a &lt; x
b &lt; x
c &lt; x &lt; d
b;
c; ;
b;
c;
;
(5)
(6)
(7)
where a, b, c and d are parameters (a b c d).</p>
        <p>In addition, we distinguish two types of fuzzy sets.
Type1 fuzzy sets on the one hand describe uncertain terms, and
on the other hand, the values of the membership function
are precise, because they are specific numbers. The idea was
born that the values of the membership function were fuzzy
sets and were called fuzzy sets of type-2. Fuzzy sets that
represent the values of membership functions are described
precisely. Hence, the further generalization that they can
be represented again by fuzzy sets. This reasoning can be
continued indefinitely, creating the concept of fuzzy sets of
type-m.</p>
        <p>Apart from the harvest itself, we define the concept of a
fuzzy number A~, which is a convex and normal fuzzy set
with a limited medium, defined on the axis of real numbers
R.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>A. Fuzzy system</title>
      <p>A fuzzy system is a set of interrelated elements separated
from the environment. Characteristic for the system is the fact
that internal connections are dominant in relation to
connections with elements from outside the system. If connections
with elements outside the system occur, then we understand
them as inputs and outputs from the system. We say then that
the system processes the input values to the output ones. At
the entrance of such a system we define
linguistic values (in the form of fuzzy sets),
numerical values - where is the need to apply some fuzzy
operations.</p>
      <p>
        Each fuzzy system contains a knowledge base written in
the form of fuzzy conditional rules if–then and so-called an
approximate motor of approximation based on fuzzy set theory
and fuzzy reasoning [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ]. The aforementioned motor combines
parts of knowledge contained in the rules if-then and with
approximate inference methods transforms the values of input
      </p>
      <p>III. TAKAGI–SUGENO FUZZY SYSTEMS</p>
      <p>The knowledge base of this system [16] is a set of if-then
rules</p>
      <p>R = n (i)ol</p>
      <p>R i=1
= nif ^n=1 x0n is A(ni); then y = fi(x0)</p>
      <p>N
ol
i=1
;
where l is the amount of rules in knowledge base, x0n is input
singleton, x0 = [x01; x02; : : : ; x0N ]T , A(ni) is the linguistic
(8)
value and y = f (x0) is a function in the conclusion i-th
ifthen rule.</p>
      <p>Each of the conditional rules leads to the numeric type
output value, and output is determined as a weighted average
calculate using the following formula
y0 = i=1</p>
      <p>I
X F (i)(x0);</p>
      <p>y(i)(x0)</p>
      <p>I
X F (j)(x0)
j=1
(9)
where y(i)(x0) = fi(x0) determines the position of the
singleton in conclusion of i-th rule or or numerical result of
inference using i-th rule, F (i)(x0) is activation degree of i-th
rule defined as
F (i)(x0) =</p>
      <p>A(i) (x01) ?T</p>
      <p>A(2i) (x02) ?T : : : ?T</p>
      <p>A(i) (x0N );</p>
      <p>N (10)
where ?T means t-norm.</p>
      <p>A function y = fi(x0) in conclusion of i-th rule can be
understand as fuzzy singleton with the following membership
function</p>
      <p>B(i) (y) = y;y(i)(x0) =
1; y = y(i)(x0);
0; y 6= y(i)(x0):
(11)</p>
      <sec id="sec-3-1">
        <title>Start;</title>
        <p>Define the object;
Define the goal;
Create rules;
Create a system based on previously created rules;
Create a set composed of angles and the current angle
of the object, distances and distance between the
target and the current position;
while the target did not reach its destination do</p>
        <p>Calculate the angle value using the system and the
current object parameters;
Correct the angle of the object;</p>
        <p>Move the object forward;
end
Stop;
Algorithm 1: The code of moving the object in the game
using the Takagi–Sugeno system.</p>
        <p>IV. TAKAGI–SUGENO FUZZY SYSTEM FOR GAMES
Takagi–Sugeno systems can be responsible for the
movement of certain objects in 2D or even 3D games. The main
idea is that the movement takes place between two points
– the location of the object, and the planned destination
position. To make this possible, a base of rules must be
created. As previously stated, the rules are based on if-then.
The simplest way is to create two variables – distance and
angle. The first one is responsible for the moving distance
and contains three linguistic variables from the following set
flef t; straight; rightg and a triangular membership function,
and the second one is a movement angle. The variable has one
of two membership functions – triangular or inverse trapezoid,
where the points of the bend will be the angles given in the
numerical angles from the range h0; 360i. Rules were created
based on these two variables and given functions. Each rule
takes input and output values and returns value of the weight.
The created rule model works on the principle of adjusting the
values of variables.</p>
        <p>Using the Takagi–Sugeno system described in the previous
section, it was implemented and described in Algorithm 1.
Examples of screenshots from the car’s movement on the
surface are shown on Fig. 1.</p>
      </sec>
      <sec id="sec-3-2">
        <title>V. EXPERIMENTS</title>
        <p>Proposed system was tested with car placed on the road
with two lanes. The car was supposed to fit in the lanes at the
turn. During the testing, different target distances were used
to see which option would be most advantageous. The distant
goal turned out to be ineffective, what can be seen in Fig.
2. The car left the road choosing the shortest path. Then the
target distances were reduced and set at a distance of 1 4
unit in UNITY. The effect for one field was the best, what is
visible on Fig. 3.</p>
      </sec>
      <sec id="sec-3-3">
        <title>VI. CONCLUSIONS</title>
        <p>In this paper, the idea of using the Takagi-Sugeno system to
make movement of objects in games. The simplicity of
implementation and creation of rules means that such systems are
accurate under additional conditions, as noted in the previous
section. Setting close goals allows to move objects on arcs,
which is the correct movement on the road. Unfortunately,
this is not an ideal solution which is visible by finding new
goals and setting them. However, it is a solution that does not
require training as opposed to neural networks[17].
(a)
(c)
(b)
(d)
International Conference on Clean Electrical Power (ICCEP). IEEE,
2015, pp. 602–609.
[16] T. Takagi and M. Sugeno, “Fuzzy identification of systems and its
applications to modeling and control,” IEEE transactions on systems,
man, and cybernetics, no. 1, pp. 116–132, 1985.
[17] G. Capizzi, G. L. Sciuto, C. Napoli, and E. Tramontana, “Advanced and
adaptive dispatch for smart grids by means of predictive models,” IEEE
Transactions on Smart Grid, vol. 9, no. 6, pp. 6684–6691, 2017.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>A.</given-names>
            <surname>Winnicka</surname>
          </string-name>
          , “
          <article-title>The opponent's movement mechanism in simple games using heuristic method,” Symposium for Young Scientists in Technology, Engineering and Mathematics (SYSTEM</article-title>
          <year>2018</year>
          ), pp.
          <fpage>12</fpage>
          -
          <lpage>16</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>D.</given-names>
            <surname>Połap</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wozniak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , and E. Tramontana, “Is swarm intelligence able to create mazes?”
          <source>International Journal of Electronics and Telecommunications</source>
          , vol.
          <volume>61</volume>
          , no.
          <issue>4</issue>
          , pp.
          <fpage>305</fpage>
          -
          <lpage>310</lpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>P.</given-names>
            <surname>Garca-Snchez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Tonda</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. M.</given-names>
            <surname>Mora</surname>
          </string-name>
          , G. Squillero, and
          <string-name>
            <given-names>J. J.</given-names>
            <surname>Merelo</surname>
          </string-name>
          , “
          <article-title>Automated playtesting in collectible card games using evolutionary algorithms,” Knowledge-Based Systems</article-title>
          , vol.
          <volume>153</volume>
          , no. C, pp.
          <fpage>133</fpage>
          -
          <lpage>146</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>O. E.</given-names>
            <surname>David</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N. S.</given-names>
            <surname>Netanyahu</surname>
          </string-name>
          , and L. Wolf, “Deepchess:
          <article-title>End-to-end deep neural network for automatic learning in chess</article-title>
          ,” in
          <source>International Conference on Artificial Neural Networks</source>
          . Springer,
          <year>2016</year>
          , pp.
          <fpage>88</fpage>
          -
          <lpage>96</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>X.</given-names>
            <surname>Zhao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Ma</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Zhang</surname>
          </string-name>
          , and H. Liu, “
          <article-title>Elm-based convolutional neural networks making move prediction in go</article-title>
          ,” Soft Computing, pp.
          <fpage>1</fpage>
          -
          <lpage>11</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>D.</given-names>
            <surname>Silver</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Huang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. J.</given-names>
            <surname>Maddison</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Guez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Sifre</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Van Den Driessche</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Schrittwieser</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I.</given-names>
            <surname>Antonoglou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Panneershelvam</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Lanctot</surname>
          </string-name>
          et al.,
          <article-title>“Mastering the game of go with deep neural networks and tree search,” nature</article-title>
          , vol.
          <volume>529</volume>
          , no.
          <issue>7587</issue>
          , p.
          <fpage>484</fpage>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>P.</given-names>
            <surname>Liskowski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W. M.</given-names>
            <surname>Jaskowski</surname>
          </string-name>
          , and
          <string-name>
            <given-names>K.</given-names>
            <surname>Krawiec</surname>
          </string-name>
          , “
          <article-title>Learning to play othello with deep neural networks</article-title>
          ,
          <source>” IEEE Transactions on Games</source>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>J.</given-names>
            <surname>Föcker</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Cole</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. L.</given-names>
            <surname>Beer</surname>
          </string-name>
          , and
          <string-name>
            <given-names>D.</given-names>
            <surname>Bavelier</surname>
          </string-name>
          , “
          <article-title>Neural bases of enhanced attentional control: Lessons from action video game players,” Brain and Behavior</article-title>
          , p.
          <fpage>e01019</fpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>J.</given-names>
            <surname>Yao</surname>
          </string-name>
          and
          <string-name>
            <given-names>N.</given-names>
            <surname>Azam</surname>
          </string-name>
          , “
          <article-title>Web-based medical decision support systems for three-way medical decision making with game-theoretic rough sets</article-title>
          ,
          <source>” IEEE Transactions on Fuzzy Systems</source>
          , vol.
          <volume>23</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>3</fpage>
          -
          <lpage>15</lpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>H.</given-names>
            <surname>Zhang</surname>
          </string-name>
          , J. Zhang, G.
          <string-name>
            <surname>-H. Yang</surname>
            , and
            <given-names>Y.</given-names>
          </string-name>
          <string-name>
            <surname>Luo</surname>
          </string-name>
          , “
          <article-title>Leader-based optimal coordination control for the consensus problem of multiagent differential games via fuzzy adaptive dynamic programming</article-title>
          ,
          <source>” IEEE Transactions on Fuzzy Systems</source>
          , vol.
          <volume>23</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>152</fpage>
          -
          <lpage>163</lpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>Q.</given-names>
            <surname>Kong</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Sun</surname>
          </string-name>
          , G. Xu, and
          <string-name>
            <given-names>D.</given-names>
            <surname>Hou</surname>
          </string-name>
          , “
          <article-title>The general prenucleolus of n-person cooperative fuzzy games</article-title>
          ,
          <source>” Fuzzy Sets and Systems</source>
          , vol.
          <volume>349</volume>
          , pp.
          <fpage>23</fpage>
          -
          <lpage>41</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>T.</given-names>
            <surname>Verma</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Kumar</surname>
          </string-name>
          , “
          <article-title>Ambika methods for solving matrix games with atanassov's intuitionistic fuzzy payoffs</article-title>
          ,
          <source>” IEEE Transactions on Fuzzy Systems</source>
          , vol.
          <volume>26</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>270</fpage>
          -
          <lpage>283</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>F.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Shi</surname>
          </string-name>
          ,
          <string-name>
            <surname>C.-C. Lim</surname>
          </string-name>
          , and L. Wu, “
          <article-title>Fault detection filtering for nonhomogeneous markovian jump systems via a fuzzy approach</article-title>
          ,
          <source>” IEEE Transactions on Fuzzy Systems</source>
          , vol.
          <volume>26</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>131</fpage>
          -
          <lpage>141</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>L. A.</given-names>
            <surname>Zadeh</surname>
          </string-name>
          et al.,
          <source>“Fuzzy sets,” Information and control</source>
          , vol.
          <volume>8</volume>
          , no.
          <issue>3</issue>
          , pp.
          <fpage>338</fpage>
          -
          <lpage>353</lpage>
          ,
          <year>1965</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>F.</given-names>
            <surname>Bonanno</surname>
          </string-name>
          , G. Capizzi,
          <string-name>
            <given-names>G. L.</given-names>
            <surname>Sciuto</surname>
          </string-name>
          , and
          <string-name>
            <given-names>C.</given-names>
            <surname>Napoli</surname>
          </string-name>
          , “
          <article-title>Wavelet recurrent neural network with semi-parametric input data preprocessing for microwind power forecasting in integrated generation systems,” in 2015</article-title>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>