You are on page 1of 1

eCo: Managing a Library of Reusable Behaviours

Gonzalo Flrez-Puga, Guillermo Jimnez-Daz, Pedro A. Gonzlez-Calero Group of Arti cial Intelligence Applications Complutense University of Madrid
Funded by Complutense University of Madrid. Supported by the Spanish Ministery of Science and Education (TIN2009-13692-C03-03)

Creating behaviours for NPCs is a non-trivial task, involving programmers and designers Designers usually dont have the knowledge to implement the behaviours they have designed. They can use visual languages to do so Tipically, simple behaviours tend to recur in different, more complex behaviours In our paper we present eCo, a visual authoring tool that integrates CBR techniques into the game authoring domain

Allows the user to draw the behaviours, using well-known visual techniques like Finite State Machines or Behaviour Trees Programmers or programming-savvy designers can create the basic building blocks using the integrated code editor Can be adapted to different games or simulation environments Allows storing, indexing, retrieving and reusing behaviours previously created by AI programmers and designers Using sketch-based retrieval eCo offers advice on how to complete a behavior using the information in the library

In the image retrieval domain, sketch-based retrieval consists in nding a complex image using an approximate representation of it (an sketch) as a query We can translate that idea to the behaviour domain, where a sketch is a partial representation of a behaviour (for instance, a FSM that is missing some edges or where the behaviour of a node has not been speci ed) In sketch-based retrieval of behaviours we search in a library for behaviours that are similar to the one the user is drawing, making suggestions about how to complete it We use graph similarity techniques to find similar FSMs or BTs Despite the usefulness of this feature, it poses a difficult problem and an open question

Assessing graph similarity is an NP-complete problem, and becomes intractable when the number of nodes grow [1]
To reduce complexity we make use of an alternative heuristic approach based on the graph edit distance [2], that finds solutions which are practically indistiguishable from the optimum solution [3] Instead of searching the whole solution space we generate the node mapping with the best cost and add to it the edge mappings necessary to complete the edit sequence

Do structurally similar behaviours actually represent behaviours that behave similarly in the game?
To find the answer to this question we ran an experiment: we compared the results of structural similarity with those of a reference function that measures functional similarity For the experiment we needed a test set, that was built with 700 SoccerBots for the SoccerBots simulation environments To build the reference measure we made matches between the behaviours in the test set and a set of trainer teams. We gathered statistics in those matches and used them to build the similarity function Using the structural similarity function we compared each behaviour in the Test Set with the remaining behaviours. We sorted the results by similarity to obtain the Structural Ranking

Trainer Teams

Play Matches


Functional Similarity with each other team in the Test Set

Functional Ranking

For each team in the Test Set Structural Similarity with each other team in the Test Set


Structural Ranking

We did the same thing with the functional similarity function and obtained the Functional Ranking To compare both rankings we used NDCG and P@k [4] with k in the interval between 1 and 30

In this paper we have presented eCo, a visual behaviour editor oriented to game designers One of the most notable features of eCo is the sketch-based retrieval. Sketch-based retrieval relies on comparing a behaviour graph that is partially drawn (the sketch) with respect to a repository of existing behaviours We have described different algorithms that allow graph comparison and provided an heuristic structure-based similarity for graphs that preserves behaviour similarity and can be computed at reasonable cost The question that raises then is whether structural similarity can be used to retrieve behaviours, not only with a similar structure, but also with a similar behaviour. To answer this question we have run an experiment By the results obtained in the experiment we can state that: The functional and the structural similarity functions rank the results in a similar order Relevant results are obtained within the first few results retrieved
Precision 1 0.9 0.8 0.7 0.6


Precision @ k
f edge f id Random

1 0.9 0.8 0.7 0.6 NDCG 0.5 0.4 0.3 0.2 0.1


0.5 0.4 0.3 0.2 0.1 0 0 5 10 15 Documents retrieved 20 25 30

f id f edge Random


15 k





Execution times
f edge f id


[1] Flrez Puga, G., Daz Agudo, B., Gonzlez Calero, P.: Similarity Measures in Hierarchical Behaviours from a Structural Point of View. FLAIRS (2010) [2] Riesen, K., Bunke, H.: Approximate Graph Edit Distance Computation by Means of Bipartite Graph Matching. Image and Vision Computing (2009) [3] Flrez-Puga, G., Gonzlez-Calero, P., Jimnez-Daz, G., Daz-Agudo, B.: Supporting sketch-based retrieval from a library of reusable behaviours. Expert Systems with Applications (2012) [4] Manning, C. D., Raghavan, P., and Schtze, H.: Introduction to Information Retrieval. (2008)

Time (ms)












21 Nodes








More information about eCo can be found at: