A dialogue system for a video game using word embeddings and fuzzy logic

06.06.2022

This thesis aims to create the proof of concept of a dialogue system of a videogame. The system consists various parts. A dialogue graph which has been done using Ink. A word search to allow the player to interact with a non-player character (NPC) which uses word embeddings and cosine similarity to check the semantic similarity between words. And finally, some fuzzy logic variables to control the state of the character. Besides, it aims to check the feasibility of these methods.

Inspiration

Over the last few decades, video game industry has grown quickly from a small market to a massive industry (Osathanunkul 2015). Despite all the innovations and the rapid growth, there are a lot of methods that have not been explored to make NPC’s more emotional responsiveness and to create experiences closer to a real conversation for the player. The dialogue of this game has been inspired by games such as Event[0], Her Story and Scribblenauts. The state variables have been inspired by the personality engine, ExtremeAI (Georgeson and Child 2016).

Fuzzy logic variables for emotional states

Fuzzy logic intends to model logical reasoning with vague or imprecise statements (Cintula et al. 2021). The biggest difference they present when compared to the classical logic is that they allow for a bigger set of truth values instead of only true and false. For this reason, using fuzzy logic variables presents an advantage as it allows a degree of truth for states such as happy, sad or trust. This is useful because of the abstract nature of these concepts. In this case, some variables are created to modulate the level of trust the NPC has towards the player. Once some variables are defined, a provisional set of rules is determined manually as there is no ground truth to define emotional states. The output variable will be the one to choose the path and, in that way the answer, inside the dialogue graph.

Word embeddings and word search

In this system, the user inputs a word and the game finds questions that contain such word or similar ones. Some methods are suitable for this task, however, in this case a method that not only include synonyms but also words with a close semantic similarity are desired.

The method used the following steps. Firstly, the possible questions in the word search are split, transformed to singular, and stop words are removed. Secondly the word embeddings, which is a way of representing words in a numeric vector, are created using Global vectors for word representation (GloVe), which is an unsupervised learning algorithm for obtaining vector representations for words. (Pennington et al. 2014). Thirdly, the word embeddings are serialized, which is the process of converting an object into a stream of bytes, and saved.

Finally, the word embeddings are deserialized on runtime and used every time a search is done. The embeddings are compared using cosine similarity. This method measures the similarity between two vectors of an inner product space (Han et al. 2012) and gives back a percentage of similarity between two words. Any similarity above a threshold is chosen and shown as an option.

Conclusions

After finalizing the dialogue systems, it has revealed some findings. The system as a whole works as intended however, the system is assessed by functionalities. The embeddings created with GloVe resulted to be too generic, this resulted to be problematic when deciding a threshold for the cosine similarity as some words that had a considerable semantic similarity were not always detected as such. For that reason, the GloVe algorithm for the word embeddings should considered to be replace by another algorithm or a custom-made model.

In contrast, the dialogue graph and the fuzzy logic state variables have been shown to achieve a desired outcome. However, different rules for the fuzzy logic system should be considered as well as some changes in the variables: in the fuzzy subsets and membership functions. Moreover, some improvements and further modifications could be done in the future to refine the system.

References

Cintula, P., Fermüller, C. and Noguera, C., 2021. Fuzzy Logic (The Stanford Encyclopedia of Philosophy). Plato.stanford.edu. [Referred on 26 March 2022] (online). Available at: https://plato.stanford.edu/entries/logic-fuzzy/

Georgeson, J. and Child, C., 2016. NPCs as People, Too: The Extreme AI Personality Engine

Han, J., Kamber, M. and Pei, J., 2012. Data mining. 3rd ed. Amsterdam: Elsevier/Morgan Kaufmann.

Osathanunkul, C., 2015. A classification of business models in video game industry. International Journal of Management Cases, 17(1), pp.35-44.

Pennington, J., Socher, R. and Manning, C.D., 2014. Glove: Global vectors for word representation. In Proceedings of the 2014 conference on empirical methods in natural language processing (EMNLP) (pp. 1532-1543).

Dialogue system based on fuzzy logic and word embeddings, Sara Jose (2022)