<!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>Iterative Software Design of Computer Games through FCA ?</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>David Llanso´</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Pedro Pablo Go´ mez-Mart´ın</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Marco Antonio Go´ mez-Mart´ın</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Pedro A. Gonza´lez-Calero</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Dep. Ingenier ́ıa del Software e Inteligencia Artificial Universidad Complutense de Madrid</institution>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>If iteration is the rule in modern software development practices, this is more the case in game development. While the secret recipe for fun in games remains hidden, game development will remain a highly iterative trial-and-error design process. In this paper we present a semi-automatic process that, through FCA, can assist in the software design of modern videogames. Through FCA we can identify candidate distributions of responsibilities among components, and let the users edit such distributions. We support iteration by facilitating the application of past edits when going through a new iteration of identifying candidate components to accommodate for new version of the game requirements.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>Nowadays, videogames are incredible complex software systems developed after many
months (even years) of work. At the same time, they are, for many people, considered a
specific way of art, where designers, drawers, 3D modeller and musicians work side by
side to create a rich interactive experience. The artistic aspect of videogames turns them
into a big challenge in a software engineering point of view, because their requirements
are always changing.</p>
      <p>
        One of the most affected modules of this uncertainty is the one responsible of the
management of the game entities (players, enemies, items, interactive objects, etc.).
Traditionally, this piece of code was implemented using a class hierarchy programmed
using object-oriented languages such as C++. Modern videogames, however, use a
component-based software architecture [
        <xref ref-type="bibr" rid="ref15 ref19 ref4 ref9">9, 19, 4, 15</xref>
        ]. It is important to mention that in
the context of game development this component-base architecture term has a different
meaning than the one used in Software Engineering. When talking about components
here we should think of something similar to mixins or traits [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]: they are just small
classes that implement specific and ideally independent capabilities in such a way that
a game entity is just a collection of this components (see Section 2 for details). Though
this may lead to confusion in the rest of the paper we will keep the nomenclature used in
game development and we will use the term “component” meaning this small classes.
      </p>
      <p>Even though the use of components promote flexibility, reusability and extensibility,
it does not come without costs (see Section 3 for details). One of the main issues is the
lack support in the mainstreams languages (mainly C++) that forces programmers to
create a complex source code infrastructure that supports components and the ability
of composing entities with them. This also leads to the lack of compiler support in
the detection of different problems related to the lost of datatype information that a
traditional class hierarchy would have exposed immediately to the programmer.</p>
      <p>
        In this paper, we present a new method for easing the design of a component-based
architecture. Using a visual tool called Rosette [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ] (see Figure 1) the user first
graphically defines the entity hierarchy (data and actions), a well-known task for game
programmers. Using Formal Concept Analysis (FCA) [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], Rosette automatically suggests a
component distribution that will fit the requirements of the provided classical hierarchy
(Section 4).
      </p>
      <p>The candidate distribution is shown to the user through a visual interface, where she
has the opportunity to modify it (Section 5) before Rosette generates a big percentage
of the entity manager game code.</p>
      <p>
        Our tool uses OWL (Web Ontology Language1) as the underlying representation
for the hierarchy and resulting components. It let us track all the applied changes and
reason about possible inconsistencies between entities and components that would be
hidden to the compiler. This part of the system has been described elsewhere [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ].
      </p>
      <p>
        As said before, videogames specification will surely change in the long run, and
the original hierarchy (and component distribution) will need several revisions. As a
1 http://www.w3.org/TR/owl-features/
result of that agile methodologies, such as scrum [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ] or extreme programming [
        <xref ref-type="bibr" rid="ref1 ref2">1, 2</xref>
        ],
are taking a big importance in the videogame developments. Agile methodologies give
repeated opportunities to assess the direction of a videogame throughout the entire
development lifecycle, which is split in iterations or sprints. The principal priority is
having functioning pieces of software at the end of every sprint to reevaluate the project
goals. To this end, Rosette allows an iterative hierarchy definition during these sprints,
remembering all the changes applied to the previously proposed component
distributions, and redoing them into the last one (Section 6). This process is possible using the
lattices [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] created using FCA and represented with OWL.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Component-Based Architecture</title>
      <p>Videogames are very complex systems developed by a lot of people who write a big
number of code lines during many months. Due to the changing nature of videogames,
where requirements are always changing, there are some parts of the game that should
be carefully implemented. Specifically, the module responsible of the management of
the game entities is the most affected module by those continuous changes so it must be
flexible enough to be adapted to unexpected changes in the specification and also offer
a good way to reuse code for different entities.</p>
      <p>Entity
- _name
- _position
- _orientation
+ setPosition()
+ setOrientation()</p>
      <p>RealEntity
- _physicclass
- _graphicmodel
- _physicmodel
- _scale
+ applyForce()
+ setAnimation()
+ stopAnimation()</p>
      <p>Speaker
- _soundfile
+ playSound()
+ stopSound()</p>
      <p>Persona
- _soundfile
- _health
- _aim
+ playSound()
+ stopSound()
+ shootTo()
+ hurt()
ResourceBearer
- _aiscript
- _speed
+ steeringTo()
+goToEntity()
+ goToPosition()</p>
      <p>Player
- _speed
+ walk()
+ stopWalk()
+ turn()</p>
      <p>Door
- _isOpen
+ open()
+ close()
Fig. 2. An entity hierarchy</p>
      <p>TriggerEntity
- _physicclass
- _physicmodel
- _scale
- _target
+ applyForce()
+ touched()
+ trigger()</p>
      <p>Traditionally the code layer responsible of the management of the game entities
took the form of an inheritance hierarchy of C++ classes. These classes represent the
hierarchy of entities and procedures that, in some sense, may be viewed as the actions
that these entities were able to perform. Figure 2 shows one of those hierarchies. Each
entity class possesses some attributes (data) and methods that code the actions the
entity is able to perform. Furthermore, the inheritance propagates features from parents
to children; for example, all the attributes and methods of the Persona class are also
available for Players.</p>
      <p>
        However, the straightforward approach of organizing entities in class hierarchies
soon probed too rigid and hard to maintain and evolve. Although well accepted, single
inheritance is not expressive enough to handle complex entity distributions.
Programmers are usually forced to duplicate code or implement methods too high in the
hierarchy [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. In the last few years, however, the component-based software architecture is the
design of choice for managing entities in modern video games [
        <xref ref-type="bibr" rid="ref15 ref19 ref4 ref9">9, 19, 4, 15</xref>
        ], embracing
this way dynamic object composition instead of static class hierarchies.
      </p>
      <p>
        Components provide an intermediate level of abstraction between methods and
classes by gathering common behaviour and, in this way, they can be seen as mixins
or traits [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. All of them, components, mixins and traits, implement a small set of
functionality (usually only one feature) and they invoke other pieces of software that belong
to other sibling structures.
      </p>
      <p>The main difference, however, is that in the context of components and games, the
entiry hierarchy is flattened and the final result is just an entity class without subclasses
that acts as a component container. Every functionality, skill or ability that the entity
has, is implemented by a component.</p>
      <p>
        Furthermore, components are more self-contained than mixins or traits since they
can have attributes which can specify some states whilst mixins and traits are just a set
of methods (we are using the trait concept formalized in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]). A direct consequence of
this is that the entity class can be the same for every entity type, because both their
attributes and their functionality are managed by the components. It needs to be just a
component container that provides component communication. So, instead of having
entities of concrete classes that provide glue methods to connect components together
like in mixing or traits, the component communication is done like in the Command
design pattern, where method invocation is transformed into an object that is passed
around the components. The piece of information used to execute functionality is called
message and components decides which messages they will accept to execute the
corresponding functionality.
      </p>
      <p>As an example, figure 3 shows the hand-made component-based version of the
hierarchy of Figure 2. The Player entity in the legacy class hierarchy shown in Figure 2
becomes a generic entity containing an instance of the PlayerControllerComp,
FightComp, PhysicsComp, SpeakerComp and GraphicsComp components. Nonetheless, this
relationship between entities and components is now done outside the code, usually in
plain text files.</p>
      <p>Such architecture promotes flexibility, reusability and extensibility but makes the
code more difficult to understand, since now the behaviour of a given entity is built at
run-time by linking components. The use of a distributed component-based architecture
- goToEntity()
- goToPosition()
SteeringToComp
- _speed
- steeringTo()
--G__rsgacrpaahlpeihciscCmoomdepl - S_pseoauknedrfiCleomp
- setPosition() - setPosition()
- setOrientation() - setOrientation()
- setAnimation() - playSound()
- stopAnimation() - stopSound()
may be confusing for programmers due to the loss of the class hierarchy where the entity
distribution is seen at a glance. At the same time, compilers will lose important datatype
information, decreasing the amount of compile time errors that will be able to detect.</p>
    </sec>
    <sec id="sec-3">
      <title>3 Fighting Against Component Issues</title>
      <p>
        When moving from inheritance hierarchies to component-based systems, the
inheritance links are turned into aggregation links where the polymorphism is substituted by
a delegation mechanism (delegating in components). This has been identified in [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] as
role aggregation and it has its own drawbacks that we summarize in:
1. Loss of information about the domain: Despite all the issues class hierarchies
manifest, they can be seen as a conceptual entity ontology and therefore they are
a non-formal definition of the game model. In a component-based system a lot of
semantic information becomes hidden behind components and scattered between
them. Although in a component-based architecture is so easy to create a new entity,
by enumerating in a plain text file which components it will have, entities are not
related in between as in hierarchies. Even worse is that abstract classes (such as
RealEntity in Figure 2) are inevitably lost because only entities that are meant to be
used to create objects are modelled. The final result of this lack of structure is that
the adoption of such design suffered the resistance of some programmers [
        <xref ref-type="bibr" rid="ref19 ref5">5, 19</xref>
        ].
2. Entity inconsistencies: With a data-driven architecture where creating new entity
types is so easy, things may go really wrong, when declaring inconsistent entities
that cannot work at execution time. When creating entities in hierarchies, it is
obvious that some methods that execute some functionality may depends on other
methods in the same entity or in ancestor classes (i.e. the steeringTo method of
the ResourceBearer in Figure 2 depends on the applyForce method of the
RealEntity). If one invoked method does not belong to the entity, these inconsistency is
checked easier, since the compiler provides some feedback. However, when
working with components this inconsistency is not checked at compilation-time since
method invocation is carried out through message passing. If the ResourceBearer
has a SteeringToComp component (which may execute the steeringTo
functionality) but does not have the PhysicsComp component where the applyForce resides,
no error is fired at compilation-time. Even no error is produced at run-time, simply
the functionality is never executed. On the other hand, when attribute values are
also data-driven some error may arise at execution-time when the given value does
not correspond with the expected type.
      </p>
      <p>
        In order to alleviate these drawbacks, we have developed Rosette [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], a visual
authoring tool that helps experts in the task of designing a game domain with a
componentbased architecture. Instead of decompose from the very begining all the entities in
components, the tool promotes the use of conceptual hierarchies that put entities,
components, messages and attributes in order. These conceptual hierarchies recover the
possibility of seeing the entity distribution and hierarchy at a glance (solving this way the first
of the identified issues) but it is also used to create a knowledge-rich representation of
the game domain using OWL that brings a lot of semantic knowledge to light. With the
purpose of giving feedback to the end user, Rosette use the Pellet Integrity Constraint
Validator (Pellet ICV)2 to detect constraint violations in the OWL formal domain and
this way detect some domain inconsistencies, such as the ones mentioned previously.
      </p>
      <p>
        The inner details of the process has been described in [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. In short it ends with the
OWL representation of the game domain and the user being confident about its lack of
inconsistences. The next step, the one detailed here, is to find out the best set of
components that should be implemented to build the entity hierarchy using a component based
architecture. This work alleviate the transition from hierarchies to component-based
architectures taking advantage of the modelled domain where experts only describes the
entities of the game in a conceptual hierarchy. This way we are facilitating the
development of component-based architectures for novice users in this area, more used to
hierarchies, but also for expert programmers and designers that may use the system to
accelerate the designing process. As we will see in the next section, the analisys of the
domain and inference of the set of components is done by using FCA.
4
      </p>
    </sec>
    <sec id="sec-4">
      <title>Generating components through Formal Concept Analysis</title>
      <p>When using Rosette, the first step is to graphically specify the entity hierarchy of the
game. Users must provide both the entities and their features (attributes and methods).
For example, they will indicate that a Player can walk and turn whilst a ResourceBearer
must be able to goToPosition or store an aiScript.</p>
      <p>Once done, we transform the hierarchy into a formal context in order to apply FCA.
Entity types (Player, ResourceBearer) become formal objects and features (walk,
goToPosition, aiScript) become formal attributes. Therefore, our formal context hG; M; Ii
2 http://clarkparsia.com/pellet/icv/</p>
      <sec id="sec-4-1">
        <title>Entity</title>
      </sec>
      <sec id="sec-4-2">
        <title>Trigger</title>
      </sec>
      <sec id="sec-4-3">
        <title>Persona</title>
      </sec>
      <sec id="sec-4-4">
        <title>ResourceBearer</title>
        <p>. . .
. . .
. . .</p>
        <p>. . .
is built in such a way that G contains every entity type and M will have every
functionality and attribute. Finally, I is the binary (incidence) relation I GxM , expressing
which attributes of M describe each object of G or which objects are described using an
attribute. This is filled in by going through the entity hierarchy annotating the relations
between entity types and their features and considering inheritance (subclasses will
include all the formal attributes of their parent classes). Table 1 shows a partial view of
the formal context extracted from the hierarchy shown in Figure 2.</p>
        <p>
          The application of FCA over such a formal context is done by using the Galicia
project [
          <xref ref-type="bibr" rid="ref18">18</xref>
          ], a project usually used by end-users through their visual interface but that
can be used by applications like Rosette using its API. The application of FCA gives
us a set of formal concepts and their relationships, (G; M; I). Every formal concept
represents all the entity types that form its extent and will need every functionality
and attributes in its intent. Starting from the lattice (Figure 4) and with the goal of
extrapolating the formal concepts to a programming abstraction, a na¨ıve approach is
to generate a hierarchy of classes with multiple inheritance. Unfortunately, the result
is a class hierarchy that makes an extensive use of multiple inheritance, which is often
considered as undesirable due to its complexity.
        </p>
        <p>
          Therefore, though this approach of converting formal concepts into classes has been
successfully used by others [
          <xref ref-type="bibr" rid="ref10 ref12">12, 10</xref>
          ], it is not valid in our context. After all, our final goal
is to remove inheritance and to identify common entity features in order to create an
independent class (a component) for each one. Once done, we will create just a single
and generic Entity class that will keep a list of components, as promotes the
componentbased architecture. The addition of new features is done by adding new components to
the entity, and these components are independent among themselves. The consequence
of this independence is that, now, sharing the implementation of the same feature in
different entities is not hard-wired in the code, but dynamically chosen in execution,
avoiding the common problems in the long run of the rigid class hierarchies.
        </p>
        <p>Using FCA, we reach this goal focusing not on the objects (reduced extents of the
formal concepts), but in the attributes (reduced intents). The idea is based on the fact
that when a formal concept has a non-empty reduced intent this means that the concept
contributes with some attributes and/or functionality that did not have appeared so far
(when traversing the lattice top-bottom). The immediate result is that the reduced extent
of objects differs from the objects in the superconcepts in those properties and it should
be consider to build a component with them. At the same time, we will know that all
the instances of the entities in the reduced extent of the formal concept will include the
new created component.</p>
        <p>For example, when analysing the formal concept labelled 11 in Figure 4, our
technique will extract a new component containing the features turn, stopWalk and walk,
and will annotate that all entities (generic instances) of the concept Player will need to
include one of those components (and any other components extracted from the formal
concepts over it).</p>
        <p>The general process performed by Rosette with the hierarchy H created by the user
is:</p>
        <p>G = entity types(H)
M = attributes and messages(H)
I = buildRelation(H)
L = (G; M; I)
P = empty component list
for each formal concept C in L
if C == &gt; then continue
Br = reducedIntent(C)
if Br is empty then continue
add(P , component( Br ) )
end for</p>
        <p>All the lines are self-explicative except that with the add. The component function
receives the reduced intent of the formal concept and builds the component
representation that has its attributes and functionalities.</p>
        <p>In some cases, the top concept (&gt;) has a non-empty intent, so it would also generate
a component with all its features (name, position and orientation in our example of
Figure 4). That component would be added in all entities so, instead of keeping ourselves in
a pure component-based architecture with an empty generic Entity class, we can move
all those top features to it. Figure 5 shows the components extracted from Rosette using
the lattice from Figure 4. The components have been automatically named
concatenating each attribute name of the component or, when no one is available, by concatenating
all the message names that the component is able to carry out. For example, let us say
that the original name of the FightComp component was C health aim.</p>
        <p>PlayerControllerComp
- walk()
- stopWalk()
- turn()</p>
        <p>Summarizing all the process, when analysing a concept lattice, every formal concept
that provides a new feature (having no empty reduced intent) does not represent a new
entity type but a new component. The only exception is the formal concept in the top
of the lattice that represents the generic entity class, which has data and functionality
shared by all the entity types. Both the generic entity and every new component have
the ability of carrying out actions in the reduced intent of the formal concept and they
are populated with corresponding attributes.</p>
        <p>This way, we have easily obtained the candidate generic entity class and
components, but we still have to describe the entity types. Starting from every concept which
their reduced extents contain an entity type, Rosette uses the superconcept relation and
goes up until reaching the concept in the top of the lattice. For example, the Persona
entity type (Figure 4) would have components represented by formal concepts number
8, 4, 3 and 2 (the number 6 has an empty reduced intent so it does not represent a
component) whilst the ResourceBearer entity type would have the same components but
also the number 10 and 9. Obviously, components of every entity type are stored in the
generic entity container represented by the formal concept number 1.</p>
        <p>Keep in mind that the final component distribution does not include information
about what components are needed for each entity. This knowledge is not thrown away:
Rosette stores all the information in the original lattice using OWL, which provides
a knowledge-rich representation that will let it provide some extra functionalities
described in the next sections.
5</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Expert Tuning</title>
      <p>The automatic process detailed above ends up with a collection of proposed
components with a generated name, and the Entity base class that may have some common
functionality. This result is presented to developers, who will be able to modify it using
their prior experience. Some of the changes will affect to the underlying formal lattice
(that is never shown to the users) in such a way that the relationship between it and the
initial formal context extracted from the class hierarchy will be broken. At this stage of
the process this does not represent an issue, because we will not use FCA anymore over
it. On the other hand, changes could be so dramatic that the lattice could even become
an invalid one. Fortunately, Rosette uses OWL as the underlying representation, that can
be used to represent richer structures than mere partially ordered sets. In any case, for
simplicity, in the rest of the paper we will keep talking about lattices although internally
our tool will not be using them directly.</p>
      <p>Users will be able to perform the next four operators over the proposed component
distribution:
1. Rename: proposed components are automatically named according to their
attribute names. The first operator users may perform is to rename them in order
to clarify its purpose.
2. Split: in some cases, two functionalities not related to each other may end up in
the same component due to the entity type definitions (FCA will group two
functionalities when both of them appears together in every entity type created in the
formal hierarchy). In that case, Rosette gives developers the chance of splitting
them in two different components. The expert will then decide which features
remain in the original component and which ones are moved to the new one (which
is manually named). Formally speaking, this operator would modify the
underlying concept lattice creating two concepts (A1; B1) and (A2; B2) that will have
the same subconcepts and superconcepts than the original formal concept (A; B)
where A A1 A2 and B B1 [ B2. The original concept is removed.
Although this is not correct mathematically speaking, since with this operation we do
not have concepts anymore, we still use the term in this and in the other operators
for simplicity.
3. Move features: this is the opposite operator. Sometimes some features lie in
different components but the expert considers that they must belong to the same
component. In this context, features of one component (some elements of the reduced
intent) can be transferred to a different component. In the lattice, this means that
some attributes are moved from a node to another one. When this movement goes
up-down (for example from node 9 to node 10), Rosette will detect the possible
inconsistency (entities extracted from node 11 would end with missed features) and
warns the user to clone the feature also in the component generated from node 11.
If the developer moves all the features of a component the result is an useless and
empty component that is therefore removed from the system.
4. Add features: some times features must be copied from one component to
another one when FCA detects relationships that will not be valid in the long run. In
our example, the dependency between node 3 and 4 indicates that all entities with
a graphic model (4, GraphicsComp) will have physics (3, PhysicsComp),
something valid in the initial hierarchy but that is likely to change afterwards. With the
initial distribution, all graphical entities will have an scale thanks to the physic
component, but experts could envision that this should be a native feature of the
GraphicsComp too. This operator let them to add those “missing” features to any
component to avoid dependencies with other ones.</p>
      <p>The expert interaction is totally necessary, first of all because she has to name the
components but also because the system ignores some semantic knowledge and
information based in the developer experience. However, the bigger the example is, with
more entity types, the more alike is the proposed and the final set of components, just
because the system has more knowledge to distribute responsibilities.</p>
      <p>While using operators, coherence is granted because of the knowledge-rich OWL
representation that contains semantic information about entities, components, and
features (attributes and actions). This knowledge is useful while users tune the component
distribution, but also to check errors in the domain and in future steps of the game
development (as creating AIs that reason over the domain).</p>
      <p>Once users validate the final distribution, Rosette generates a big amount of source
code for all the components, that programmers will be fill up with the concrete
behaviours.
5.1</p>
      <sec id="sec-5-1">
        <title>Example</title>
        <p>Figure 5 showed the resultant candidate of components proposed by Rosette for the
hierarchy of Figure 1, that can now be manipulated by the expert to tune some aspects.
The first performed changes are component rename (rename operator) that is, in fact,
applied in the figure.</p>
        <p>A hand-made component distribution of the original hierarchy would have ended
with that one shown in Figure 3, that is quite similar to the distribution provided by
Rosette. When using a richer hierarchy, both distributions are even more similar.</p>
        <p>With the purpose of demonstrating how the expert would use the available
operators to transform the proposed set of components, we apply some modifications to the
automatically proposed distribution in order to turn it into the other one.</p>
        <p>First of all, we can consider the SpeedAttComp that has the speed attribute but no
functionalities. In designing terms this is acceptable, but rarely has sense from the
implementation point of view. Speed is used separately by PlayerControllerComp and
AIAndMovementComp to adjust the movement, so we will apply the move features
operator moving (and cloning) the speed feature to both components, and removing
SpeedAttComp completely. This operator is coherent with the lattice (Figure 4): we are
moving the intent of the node labelled 9 to both subconcepts (10 and 11).</p>
        <p>After that, another application of the move features operator results in the movement
of the touched message interpretation from the TriggerComp to the PhysicsComp. This
is done for technical reasons in order to maintain all physic information in the same
component.</p>
        <p>Then, the split operator, which split components, is applied over the
AIAndMovementComp component twice. Due to the lack of entity types in the example, some
features resides in the same component though in the real implementation are divided. In
the first application of the split operator, the goToEntity and the goToPosition message
interpretations are moved to a new component, which is named GoToComp. The second
application results in the new SteeringToComp component with the steeringTo message
interpretation and the speed attribute. The original component is renamed as AIComp
by the rename operator and keeps the aiscript attribute.</p>
        <p>Finally, although the Entity class has received some generic features (from the top
concept, &gt;), they are especially important in other components. Instead of just use
those features from the entity, programmers would prefer to maintain them also in those
other components. For this reason, we have to apply the add features operator over
the GraphicsComp, PhysicsComp and SpeakerComp components in order to add the
setPosition and the setOrientation functionalities to them.</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>6 Iterative Software Development with FCA</title>
      <p>In the previous section we have presented a semi-automatic technique for moving from
class hierarchies to components. The target purpose is helping programmers facing up
to this kind of distributed system, which is widely used in computer game
developments. Through the use of FCA, this technique splits entity behaviours in candidate
components but also provides experts with mechanisms for modifying these component
candidates. These mechanisms are the operators defined in Section 5, which execution
in the domain alter somehow the underlying formal lattice generated during the FCA
process.</p>
      <p>Attentive readers will have realized that the previous technique is valid for the first
step of the development but not for further development steps. Due to computer game
requirements change throughout the game development, the entity distribution is
always changing. When the experts face up to this situation, they may decide to change
the entity hierarchy in order to use Rosette for generating a new set of components. The
application of FCA results in a new lattice that probably does not change a lot from the
previous one. However, the experts usually would have performed some modifications
in the proposed component distribution using our operators. As the process is now
repeated, these changes would be lost every time the expert request a new candidate set
of components.</p>
      <p>Our intention in this section is to extend the previous technique in order to allow
an iterative software design. In this new approach, the modifications applied over one
lattice can be extrapolated to other lattices in future iterations. Keep in mind that the
domain operators (Section 5) are applied over components that has been created from
a formal concept. So, these operators could be applied on similar formal concepts, of
another domain, in case that both domains share the part of the lattice affected by the
operators.</p>
      <p>From a high-level point of view, in order to preserve changes applied over the
previous component suggestions, the system compares the new formal lattice, obtained
through FCA, with the previous one. The methodology identifies the part of the lattice
that does not significantly change between the two FCA applications. This way the
tuning operators executed in concepts of this part of the lattice could be reapplied in the
new lattice.</p>
      <p>The identification of the target part of the lattice is a semi-automatic process, where
formal concepts are related in pairs. Rosette automatically identifies the constant part of
the lattice, which for our purpose is the set of pairs of formal concepts that have the same
reduced intent. We do not care about the extent in our approach since the component
suggestion lays its foundations in the reduced intent. The components extrated from the
formal concepts that have not been matched up are presented to the expert. Then she
can provide matches between old components and new ones to the considered constant
part of the lattice.</p>
      <p>It is worth mentioning that some of the operators could not be executed in the new
domains due to component distribution may vary a lot after various domain iterations
but it is just because these operators become obsoleted.
6.1</p>
      <sec id="sec-6-1">
        <title>Example</title>
        <p>In Section 5.1 FCA is applied to a hierarchy and the automatic part of the proposed
methodology leads us to the set of components in Figure 5. The resultant domain was
modified by the expert, by using the tuning operators, and the component-based system
developed ends up with the components in Figure 3.</p>
        <p>Now, let us recover the example and suppose that the game design has new
requirements. The game designers propose the addition of two new entity types: the
BreakableDoor, which is a door that can be broken using weapons, and a Teleporter, which
moves entities that enter in them to a far target place. Designers also require the
modification of the ResourceBearer entity, which must have a currentEnemy attribute for the
artificial intelligence. The Rosette expert captures these domain changes by modifying
the entity hierarchy and uses the component suggestion module to distribute
responsibilities. The application of FCA to the current domain results in the lattice in Figure 6,
where formal concepts are tagged with letters from a to n.</p>
        <p>Comparing the new lattice with the lattice of the previous FCA application
(Figure 4), Rosette determines that the pairs of formal concepts &lt;1,a&gt;, &lt;2,b&gt;, &lt;4,d&gt;,
&lt;7,f&gt;, &lt;9,k&gt; and &lt;11,m&gt; remain from the previous to the current iteration. When
Rosette finishes this automatic match, the formal concepts that were not put into pairs
and with no empty reduced intent are presented in the screen. In this moment, the expert
put the formal concepts &lt;3,c&gt;, &lt;5,e&gt;, &lt;8,j&gt; and &lt;10,l&gt; into pairs, based on their
experience and in the fact that these concepts are very similar (only some attributes
changes). Just the g and h formal concepts have no pairs and will become new
components.</p>
        <p>So, in these steps, the part of the lattice that does not significantly change has been
identified and Rosette can extrapolate the modifications applied in the previous lattice to
the new one. After applying the operators to the new domain, the new set of candidate
components are finally given to the expert. Figure 7 shows these components, where
we can compare the result with the components in Figure 5. The general structure is
maintained but some actions and attributes has been moved between components.
Furthermore two new components have arisen. The stressed features denote new elements
(or moved ones) whilst the crossed out features mean that they do not belong to this
component anymore (FightComp. At this point the expert could continue with the
iteration by applying new operators to this set of components (i.e change the auto-generated
names of the new components).
7</p>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>Related Work and Conclusions</title>
      <p>
        Regarding related work, we can mention other applications of FCA to software
engineering. The work described in [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] focuses on the use of FCA during the early phases
of software development. They propose a method for finding or deriving class
candidates from a given use case description. Also closely related is the work described
in [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], where they propose a general framework for applying FCA to obtain a class
hierarchy in different points of the software life-cycle: design from scratch using a set
-goToEntity()
- goToPosition()
SteeringToComp
- _speed
- steeringTo()
of class specifications, refactoring from the observation of the actual use of the classes
in applications, and hierarchy evolution by incrementally adding new classes. The main
difference with the approach presented here is that they try to build a class hierarchy
while we intend to distribute functionality among sibling components, which solve the
problem with multiple inheritance in FCA lattices.
      </p>
      <p>
        The process of identifying components with FCA is not very different of identifying
traits [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] and aspects [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ]. In [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] Lienhard et al. present a process that identifies traits
from inheritance hierarchies that is bases in the same principles than our system but is
not exactly the same due to components are more autonomous pieces of software than
traits. Components save their own state whilst traits are just a set of methods. However,
which makes the difference between both proposals is the iterability.
      </p>
      <p>
        A possible scenario for applying the techniques described in the paper is to
reengineer a game from class hierarchy to components. In the last years, we have been
working on Javy 2 [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], a educational game that was initially developed using an
entity hierarchy (a portion was shown in Figure 1), and afterwards manually converted to
a component-based architecture (Figure 3). When Rosette was available, we tested it
using the original Javy 2 hierarchy, and the initial component distribution was quite
acceptable when compared with the human-made one. We could have saved a significant
amount of time if it had been available on time.
      </p>
      <p>In the long term, our goal is to support the up-front development of games with
a component-based architecture where entities are connected to a logical hierarchical
view. In this paper we have shown how we allow an iterative process when defining the
class hierarchy, so operators applied to the early versions of the component distribution
are automatically reapplied in the late ones. Nevertheless, more work must be done in
the code generation phase to do it reversible. Changes in the autogenerated source code
are still, unfortunately, out of the scope of Rosette so they must be manually redone for
each class hierarchy iteration.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>K.</given-names>
            <surname>Beck</surname>
          </string-name>
          .
          <article-title>Embracing change with extreme programming</article-title>
          .
          <source>Computer</source>
          ,
          <volume>32</volume>
          :
          <fpage>70</fpage>
          -
          <lpage>77</lpage>
          ,
          <year>October 1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>K.</given-names>
            <surname>Beck</surname>
          </string-name>
          and
          <string-name>
            <given-names>C.</given-names>
            <surname>Andres</surname>
          </string-name>
          .
          <article-title>Extreme Programming Explained: Embrace Change (2nd Edition)</article-title>
          .
          <source>Addison-Wesley Professional</source>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>G.</given-names>
            <surname>Birkhoff. Lattice Theory</surname>
          </string-name>
          , third editon.
          <source>American Math. Society Coll. Publ. 25</source>
          , Providence,
          <string-name>
            <surname>R.I</surname>
          </string-name>
          ,
          <year>1973</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>W.</given-names>
            <surname>Buchanan</surname>
          </string-name>
          .
          <source>Game Programming Gems</source>
          <volume>5</volume>
          ,
          <string-name>
            <surname>chapter</surname>
            <given-names>A Generic</given-names>
          </string-name>
          <string-name>
            <surname>Component</surname>
          </string-name>
          <article-title>Library</article-title>
          .
          <source>Charles River Media</source>
          ,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>M.</given-names>
            <surname>Chady</surname>
          </string-name>
          .
          <article-title>Theory and practice of game object component architecture</article-title>
          .
          <source>In Game Developers Conference</source>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>M.</given-names>
            <surname>Dao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Huchard</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Libourel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pons</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Villerd</surname>
          </string-name>
          .
          <article-title>Proposals for Multiple to Single Inheritance Transformation</article-title>
          . In MASPEGHI'
          <volume>04</volume>
          : 3rd Workshop on Managing SPEcialization/Generalization Hierarchies, pages
          <fpage>21</fpage>
          -
          <lpage>26</lpage>
          , Oslo (Norway),
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>S.</given-names>
            <surname>Ducasse</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Nierstrasz</surname>
          </string-name>
          , N. Scha¨rli, R. Wuyts,
          <article-title>and</article-title>
          <string-name>
            <given-names>A. P.</given-names>
            <surname>Black</surname>
          </string-name>
          .
          <article-title>Traits: A mechanism for fine-grained reuse</article-title>
          .
          <source>ACM Trans. Program. Lang. Syst.</source>
          ,
          <volume>28</volume>
          :
          <fpage>331</fpage>
          -
          <lpage>388</lpage>
          ,
          <year>March 2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>B.</given-names>
            <surname>Ganter</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Wille</surname>
          </string-name>
          .
          <article-title>Formal concept analysis</article-title>
          .
          <source>Mathematical Foundations</source>
          ,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>S.</surname>
          </string-name>
          <article-title>Garce´s. AI Game Programming Wisdom III, chapter Flexible Object-Composition Architecture</article-title>
          .
          <source>Charles River Media</source>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>R.</given-names>
            <surname>Godin</surname>
          </string-name>
          and
          <string-name>
            <given-names>P.</given-names>
            <surname>Valtchev</surname>
          </string-name>
          .
          <article-title>Formal Concept Analysis, chapter Formal Concept Analysis-Based Class Hierarchy Design in Object-Oriented Software Development</article-title>
          , pages
          <fpage>304</fpage>
          -
          <lpage>323</lpage>
          . Springer Berlin / Heidelberg,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <given-names>P. P.</given-names>
            <surname>Go</surname>
          </string-name>
          <article-title>´mez-Mart´ın, M. A. Go´mez-Mart´ın, P. A. Gonza´lez-</article-title>
          <string-name>
            <surname>Calero</surname>
            , and
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Palmier-Campos</surname>
          </string-name>
          .
          <article-title>Using metaphors in game-based education</article-title>
          . In K. chuen
          <string-name>
            <surname>Hui</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          <string-name>
            <surname>Pan</surname>
          </string-name>
          , R. C. kit
          <string-name>
            <surname>Chung</surname>
            ,
            <given-names>C. C.</given-names>
          </string-name>
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>X.</given-names>
          </string-name>
          <string-name>
            <surname>Jin</surname>
          </string-name>
          , S. Go¨bel, and E. C.-L. Li, editors,
          <source>Technologies for E-Learning and Digital Entertainment</source>
          . Second International Conference of E-Learning and
          <source>Games (Edutainment'07)</source>
          , volume
          <volume>4469</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>477</fpage>
          -
          <lpage>488</lpage>
          . Springer Verlag,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12. W. Hesse and
          <string-name>
            <given-names>T. A.</given-names>
            <surname>Tilley</surname>
          </string-name>
          .
          <source>Formal Concept Analysis used for Software Analysis and Modelling</source>
          , volume
          <volume>3626</volume>
          <source>of LNAI</source>
          , pages
          <fpage>288</fpage>
          -
          <lpage>303</lpage>
          . Springer,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <given-names>A.</given-names>
            <surname>Lienhard</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Ducasse</surname>
          </string-name>
          , and
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Are´valo. Identifying traits with formal concept analysis</article-title>
          .
          <source>In Proceedings of the 20th IEEE/ACM international Conference on Automated software engineering, ASE '05</source>
          , pages
          <fpage>66</fpage>
          -
          <lpage>75</lpage>
          , New York, NY, USA,
          <year>2005</year>
          . ACM.
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14. D. Llanso´,
          <string-name>
            <given-names>M. A.</given-names>
            <surname>Go´</surname>
          </string-name>
          mez-Mart´ın,
          <string-name>
            <given-names>P. P.</given-names>
            <surname>Go</surname>
          </string-name>
          <article-title>´mez-Mart´ın, and</article-title>
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Gonza</surname>
          </string-name>
          <article-title>´lez-Calero. Explicit domain modelling in video games</article-title>
          .
          <source>In International Conference on the Foundations of Digital Games (FDG)</source>
          , Bordeaux, France,
          <year>June 2011</year>
          . ACM.
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <given-names>B.</given-names>
            <surname>Rene</surname>
          </string-name>
          .
          <article-title>Game Programming Gems 5, chapter Component Based Object Management</article-title>
          .
          <source>Charles River Media</source>
          ,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <given-names>K.</given-names>
            <surname>Schwaber</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Beedle</surname>
          </string-name>
          .
          <article-title>Agile Software Development with Scrum</article-title>
          . Prentice
          <string-name>
            <surname>Hall</surname>
            <given-names>PTR</given-names>
          </string-name>
          , Upper Saddle River, NJ, USA, 1st edition,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <given-names>T.</given-names>
            <surname>Tourwe</surname>
          </string-name>
          and
          <string-name>
            <given-names>K.</given-names>
            <surname>Mens</surname>
          </string-name>
          .
          <article-title>Mining aspectual views using formal concept analysis</article-title>
          .
          <source>In Proceedings of the Source Code Analysis and Manipulation, Fourth IEEE International Workshop</source>
          , pages
          <fpage>97</fpage>
          -
          <lpage>106</lpage>
          , Washington, DC, USA,
          <year>2004</year>
          . IEEE Computer Society.
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <given-names>P.</given-names>
            <surname>Valtchev</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Grosser</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Roume</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M. R.</given-names>
            <surname>Hacene</surname>
          </string-name>
          . Galicia:
          <article-title>An open platform for lattices</article-title>
          .
          <source>In In Using Conceptual Structures: Contributions to the 11th Intl. Conference on Conceptual Structures (ICCS'03</source>
          , pages
          <fpage>241</fpage>
          -
          <lpage>254</lpage>
          . Shaker Verlag,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <given-names>M.</given-names>
            <surname>West</surname>
          </string-name>
          .
          <article-title>Evolve your hiearchy</article-title>
          .
          <source>Game Developer</source>
          ,
          <volume>13</volume>
          (
          <issue>3</issue>
          ):
          <fpage>51</fpage>
          -
          <lpage>54</lpage>
          , Mar.
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>