scieee AI-readable full text Open interactive document viewer

Statistical analysis of user-created game levels

Marco Añó, Álvaro

Abstract

[EN] In some videogames, players have an enormous amount of maps to choose, the question that this thesis tries to answer is, what are the differences between a “good” map and a “bad” map? In this project a machine learning scheme was designed to try to answer this question for Minecraft map

Full text

Escola Tècnica Superior d’Enginyeria Informàtica Universitat Politècnica de València Statistical analysis of user-created game levels Trabajo Final de Grado Grado en Ingeniería Informática Author: Álvaro Marco Añó UPV supervisor: Roberto Paredes Palacios ETH supervisor: Mubbasir Kapadia and Severin Klingler September 3, 2014 Als que sempre han estat ahí. Abstract In some videogames, players have an enormous amount of maps to choose, the question that this thesis tries to answer is, what are the differences between a “good” map and a “bad” map? In this project a machine learning scheme was designed to try to answer this question for Minecraft maps. Keywords: Machine learning, Data mining, Regression analysis, Game studies, Minecraft. Resumen En algunos videojuegos, los jugadores tienen a su alcance una enorme cantidad de mapas entre los que elegir, la pregunta que este TFG trata de responder es, ¿cuáles son las diferencias entre un “buen” mapa y un “mal” mapa? En este proyecto un esquema de aprendizaje automático se ha diseñado y aplicado para responder a esta pregunta en los mapas de Minecraft. Palabras clave: Aprendizaje automático, Minería de datos, Análisis de la regresión, Ludología, Minecraft. CONTENTS 1. Introduction 1 1.1. Aim and motivation . . . . . . . . . . . . . . . . . . . . . . . 2 1.2. Minecraft ............................. 2 2. Popularity prediction for Minecraft 7 2.1. Thepipeline............................ 7 2.2. Acquiringthedata ........................ 9 2.2.1. Thedata.......................... 11 2.3. Features.............................. 13 2.3.1. Low-level features . . . . . . . . . . . . . . . . . . . . . 13 2.3.2. High-level features . . . . . . . . . . . . . . . . . . . . 16 2.4. Learning.............................. 18 3. Results 21 3.1. Analysis of the results . . . . . . . . . . . . . . . . . . . . . . 21 4. Conclusions 25 4.1. Futurework............................ 25 Bibliografía 27 i LIST OF FIGURES 1.1. Automatically generated world in survival mode. . . . . . . . . 3 1.2. NBTExplorer, a tool for reading and writing NBT files (to be introduced later) showing the general structure of a world. . . 4 2.1. Diagram displaying the pipeline used during in the analysis of features............................... 8 2.2. Diagram displaying the standars approach followed adopted for dealing with machine learning problems. . . . . . . . . . . 9 2.3. Screenshot of the website http://www.minecraftworldmap. com/................................. 10 2.4. Barchart of normalized number of downloads (left) and barchart of number of maps with less than 201 downloads (right). 12 2.5. Screenshots of a village with NPCs (on the left) and different types of biomes (on the right). . . . . . . . . . . . . . . . . . . 15 2.6. A map rendered in Google Maps. . . . . . . . . . . . . . . . . 16 2.7. Heat maps of height (left) and logs (zoomed, right) of the worldinfigure2.6. ........................ 17 2.8. Scheme of the weka learning process used. . . . . . . . . . . . 18 3.1. Average prediction error of the RBF kernel using different values of γand C. .......................... 24 4.1. Screenshots of user-created levels with complex constructions. 26 iii 1.2. Minecraft Chapter 1. Introduction game worked and at this point there are a lot of resources available in this sense. The community did apply techniques such as reverse engineering to know the functioning of the game, but also Mojang developers post frequently in a blog and give crutial information about the game mechanics. There are tools available for rendering and visualizing maps (both in 2D and 3D), libraries for reading and writing Minecraft formats, map editors, map generators, texture editors, backup utilities and so on. Figure 1.2: NBTExplorer, a tool for reading and writing NBT files (to be introduced later) showing the general structure of a world. On the “player-side” there exist websites with even more than 30000 maps freely available for downloading, websites dedicated to mods that change the mechanics of the game, free servers for online gaming and an ongoing list of material. Moreover Mojang has always encouraged the creation and sharing of this type of materials and they even planned to release a Plugin API to allow developers to easily add new content to the game, nonetheless this API is still under development, but when available it will allow the creation of plugins without modifying the minecraft.jar executable. Minecraft has five different game modes (without the use of any mod): adventure, survival, hardcore, creative and spectator. Each one of this modes 4 Chapter 1. Introduction 1.2. Minecraft has different objectives, for instance in the creative mode access to an infinite amount of almost all blocks is provided, blocks can be destroyed instantly and players are invulnerable (they cannot die). In survival mode players have to acquire resources to build, craft and gain experience and also they have to maintain their health and hunger bars. Adventure mode is very similar to survival mode but in this mode blocks can only be broken with the correct tools and there are even blocks that cannot be destroyed to avoid spoiling the adventure map. This thesis is focused on the analysis of advenutre maps. In the game, worlds can be automatically generated by using a seed and a level generator. Another widespread option is to generate an automatic map and then build structures on it, locally or collaboratively online, and finally share the map through one of the many websites on the Internet dedicated to this aim. This thesis analyzes user-created game levels available on the Internet. For all of these reasons Minecraft was chosen to be analyzed in this thesis. 5 CHAPTER 2 POPULARITY PREDICTION FOR MINECRAFT In this chapter the machine learning pipeline used for the popularity prediction of Minecraft levels is detailed. In the first section, an overview of the pipeline is given and in each of the following sections one of the components of the pipeline is introduced. The second section describes the process for acquiring the Minecraft maps and shows statistics on the collected data; in the third section the designed features are detailed and finally in the last section the learning process is presented. 2.1. The pipeline The pipeline followed during the development of the analysis covers the entire process of a machine learning schema and is formed by three main components, which are subdivided as well into smaller subcomponents. This problem does not have such a big research investment so far as other problems, such as speech recognition or OCR1. In these other mentioned problems 1Optical Character Recognition 7 2.1. The pipeline Chapter 2. Popularity prediction for Minecraft with many years of research there exist a clear set of features that are wellknown and work well for their analysis and classification, however this is not the case of the problem presented in this thesis. For this reason, the main effort of the research project was put on the design and modelling of the features. The first implemented step in the pipeline consists in the acquisition (and preprocessing) of a set of Minecraft maps for their further analysis. Next, maps are parsed and features extracted from them. The last step consists on applying learning techniques to predict the popularity of the maps. After that, iterations over this last two steps are needed to check how well the predictions are functioning and devise new features to improve the results. The diagram in figure 2.1 pictures the described pipeline. Data acquisition Feature design and modelling Learning Figure 2.1: Diagram displaying the pipeline used during in the analysis of features. Moreover, some of this stages are subdivided into smaller substages, but this substages will be presented in the corresponding section. Once the features provide consistent results the pipeline in figure 2.2 may be used. This is the standard machine learning approach, in which a model is built using a training set and afterwards this model is used for performing predictions on the testing or “real-world” data. In the next sections the elements of the pipeline are described in detail. 8 Chapter 2. Popularity prediction for Minecraft 2.2. Acquiring the data Data acquisition Feature extraction Learning Data acquisition Feature extraction Model Classification/ Regression Prediction Training Testing Figure 2.2: Diagram displaying the standars approach followed adopted for dealing with machine learning problems. 2.2. Acquiring the data Even though Minecraft has a huge community of people behind it Mojang does not offer an official website for sharing the worlds, mods, textures or plugins created by the users. Recently, Minecraft Realms was released but this service only offers players to create and manage their own private server and there is not a world-sharing service so far. However there exist lots of unofficial websites, some of them with tons of material and some of them (most) with not that much. There is not a clear structure among these unofficial websites in terms of the meta-information that they provide. The meta-information provided in the websites varies from one website to another but this is a short list of some of the offered data: Number of downloads and comments Raw comments Author of the map Upload and update date Map version Description of the map Topics Map size 9 2.2. Acquiring the data Chapter 2. Popularity prediction for Minecraft Ratings, likes, favorites and other social-network-related information Screenshots ... When choosing a website for downloading the levels two considerations were taken into account. First the website needed a quite big amount of levels, and second the maps had to be directly available for download from that website. Many websites do not allow a direct download, but they offer a link to an upload server from where you can download the level. This situation is problematic because it complicates the automatic download of the levels (each website has a different procedure for downloading: waiting one minute, captchas, etc). A website that fulfills both requirements is the website http://www.minecraftworldmap.com/ which was the one finally chosen for downloading the levels. Figure 2.3: Screenshot of the website http://www.minecraftworldmap. com/. The selected website has more than 30000 maps available for download and also is quite meta-information rich. However it does not provide any 10 Chapter 2. Popularity prediction for Minecraft 2.2. Acquiring the data API or system to allow an easy download of the maps and meta-information, consequently a web crawler was developed in order to download the maps and its corresponding information. The crawler works as follows: it downloads a webpage, opens each world link in that webpage and stores the world and its meta-data. In this way, a big number of levels can be downloaded in an easy way just by iterating over the sections in the website. The library jsoup was used as a help for parsing the html files. Each uploaded level has the following associated information available directly on the website: number of downloads, number of comments, raw comments, author, upload date, size, description, topics and a render of the map navigable through Google Maps. However not every piece of this information can be used easily, for example comments need to be parsed and analyzed separately and the results of doing this work are uncertain. Due to that the information stored is: number of downloads, number of comments, author, upload date and size. For storing the meta-information a database was designed and implemented using SQLite. In this database not only the meta-information is stored, but also the features extracted from the worlds. In the next subsection some descriptive statistics on the downloaded levels are presented. 2.2.1. The data When downloading the maps some preprocessing was made to check that the downloaded file was alright and actually contained the map (uncompressing the file, checking the existance of the files, etc). After this preprocessing a total of 1717 were downloaded (all the levels that do not contain errors in the category “adventure” of the website). This is a total of 19.5 GB, with an average file size of 10 MB and with the “biggest” level with a weight of 420 MB. Table 2.1 shows how the number of downloads is distributed among the levels: the first column is the number of downloads, the second column the number of levels that have at least that number of downloads and the third column the percentage of the total number of levels that were downloaded at least that given number of times. 11 2.2. Acquiring the data Chapter 2. Popularity prediction for Minecraft Table 2.1: Distribution of the number of downloads. Number of downloads Number of levels Percentage 1 136 7.9 % 10 773 45.0 % 50 1278 74.4 % 80 1379 80.3 % 100 1419 83.0 % 200 1537 89.5 % 500 1623 94.5 % 1000 1660 96.7 % 10000 1711 99.7 % 100000 1717 100.0 % Not surprisingly, there are a lot of maps that have very few downloads (three quarters of the worlds have 50 or less downloads!) and a few fraction of the maps receives most of the attention. This can also be seen in figure 2.4. Figure 2.4: Barchart of normalized number of downloads (left) and barchart of number of maps with less than 201 downloads (right). A similar situation occurs with the number of comments; most maps have only a few comments, but now the case is more extreme since 1696 maps (98.7%) have 5 or less comments. For this reason the focus is put in the number of downloads because the comments on the used website are not extensively used. 12 Chapter 2. Popularity prediction for Minecraft 2.3. Features On the other hand, the topic tagging system of the website does not impose any restictions on the number or format of these topics. Due to this reason, things like worlds without any topic, worlds with 20 topics or topics like “minecraft” or “asdfasdfasdf” are common. This leads to a similar situation as in the raw comments, in order to take some advantage of the topic system some preprocessing has to be done first for filtering and mapping the topics. This context is almost identical to the raw comments one, therefore the topics were not considered when downloading the meta-data. 2.3. Features To extract the features out of the Minecraft levels, they must be read and parsed; Minecraft has its own file format for the various files in which it stores the data. This file format is the NBT2format and it is formed by a tree structure made up of various tags [Per]. Moreover this information is arranged in a way that makes easier the compression of the files (which is made in the gzip format). The library jnbt was used for parsing the NBT files and some other tools were developed as well to facilitate this task. In this section the designed features are listed and described detailedly. First the low-level features, which are more simple are introduced; after that the high-level features are presented. 2.3.1. Low-level features The low-level features are features contained in the world file structure itself or features that are easy to obtain after parsing a map (e.g. counts, or averages). Here it is an extensive list of the low-level features extracted from the meta-information files: Generator of the level The features obtained from the generator of the level: Generator type Possible values are: default, flat, largeBiomes, amplified or customized. Each one of them produces a different kind of level. 2Named Binary Tag 13 CHAPTER 3 RESULTS The results obtained after applying the process described in the second chapter of this document are analyzed in the following section. 3.1. Analysis of the results As previously mentioned, different regressors were tested for solving the problem. The regressor that obtained the best results is the SVM with a huge difference. Using this regressor, different parameters need to be set, such as the kernel function or the regularization paramters. Two different kernel functions were tried: the polynomial kernel (PolyKernel) and the RBF1kernel (RBFKernel). The polynomial kernel is defined as: K(x, y) =< x, y >p(3.1) And it has as a parameter the exponent and the regularization parameter C. 1Radial Basis Function 21 3.1. Analysis of the results Chapter 3. Results On the other hand, the RBF kernel function is defined in this way: K(x, y) = e−(γ<x−y,x−y>2)(3.2) The two parameters of this kernel function are γand the regularization parameter C. First, the polynomial kernel was tested with different values for the exponent (and some variations for C); clearly the best exponent was 1. Table 3.1 contains the results obtained. Table 3.1: SVM regression with polynomial kernel. Total error Average error Variance C Exponent 5726.065 58.900 2046447.385 1 1 2665.579 27.441 527407.587 0.1 1 163.163 1.669 140.656 0.01 1 330.996 3.403 5131.735 0.001 1 72482417.220 747222.895 5.39E+9 0.1 2 1239.186 12.760 117844.233 0.01 2 It can be seen in the table 3.1 that the best model trained with the polynomial kernel got an average prediction error on the number of downloads per day of 1.669 and it has a variance of 140.656. After observing and analyzing the results of the polynomial kernel, the RBF kernel was tested. As in the case of the polynomial kernel, the best results come when finding the appropiate values for the parameters. Table 3.2 shows the results obtained with this kernel function. 22 Chapter 3. Results 3.1. Analysis of the results Table 3.2: SVM regression with RBF kernel. Total error Average error Variance C γ 68.62669971 0.702951778 5.01650386 1 0.1 60.04567207 0.615084691 5.02906642 0.1 0.1 57.30524711 0.587013491 5.14551194 0.001 0.1 57.01203592 0.584006570 5.20180667 0.0001 0.1 62.20121474 0.637095065 5.08452111 1 0.01 59.15346329 0.605910599 5.13774146 0.1 0.01 57.17557337 0.585678120 5.19795612 0.001 0.01 62.20121474 0.637095065 5.08452111 0.0001 0.01 60.08830397 0.615470567 5.17649649 1 0.001 57.16230031 0.585541728 5.20004569 0.1 0.001 56.94613503 0.583329872 5.22294997 0.001 0.001 56.99820582 0.583864299 5.23160565 0.0001 0.001 It can be observed in the table that the best model was obtained using the parameters C=0.01 and γ= 0.001. Figure 3.1 plots the values on table 3.2. The results obtained for the best model on each one of the folds of the cross-validation is presented in the table 3.3. Table 3.3: 10-fold results for the RBF kernel with C=0.01 and γ= 0.001. fold Total error Average error Variance 1 20.59717227 0.210175227 0.193403736 2 133.4066447 1.361292293 17.95626855 3 31.13547913 0.317708970 0.508038573 4 55.72015753 0.568573036 3.963004249 5 46.62647497 0.475780356 1.248203319 6 36.74163923 0.374914686 1.317500484 7 31.64706606 0.322929245 0.890236494 8 69.29391184 0.714370225 5.768442868 9 92.87732111 0.957498155 18.17760173 10 51.41548349 0.530056530 2.206799699 23 3.1. Analysis of the results Chapter 3. Results Figure 3.1: Average prediction error of the RBF kernel using different values of γand C. To conclude with this chapter and after studying the data presented, it can be stated that for this problem the best regression predictor is clearly a SVM regressor with an RBF kernel. 24 CHAPTER 4 CONCLUSIONS In this work the problem of predicting the goodness of Minecraft levels was introduced and a machine learning scheme was designed and implemented to accomplish the goal. Finally the results obtained were analyzed carefully. The task of predicting the popularity of user-created game levels is quite complex, however the results obtained were quite good. In the following section future work to be done is presented briefly. 4.1. Future work Future research work for continuing the project could include the design of new high-level features. Some examples are given in the next paragraphs. A good starting point could be implementing other high-level features that take into account not only 2D structures but also 3D ones. For example extracting features of caves in the worlds or even automatize and generalize the process of feature extraction could be done. However a smart preprocessing should probably be done before applying any learning technique because the number of blocks in some maps is enormous, in the order of hundreds of millions, but even higher in some worlds. 25 4.1. Future work Chapter 4. Conclusions As a way of illustration, another completely different set of high-level features could be obtained by performing diffs between the downloaded levels and the corresponding “original” ones, that may be generated using the seed of the level. By doing this operation the position and kind of the blocks that were placed, changed or removed can be known. In this way, the “work” done by the players can be used as a new set of features. Figure 4.1: Screenshots of user-created levels with complex constructions. Finally, parsing the raw comments and the topics of a world using NLP1 tools would provide a good set of features to be tested as well. After doing this, conclusions as knowing if the players take into account the topics for downloading a world or if “zombie” maps are more popular could be obtained. On the other hand, an obvious next step to perform is to generalize the scheme, try it with other videogames and observe the results. 1Natural Language Processing 26 BIBLIOGRAPHY [Bai07] William S. Bainbridge. The scientific research potential of virtual worlds. Science, 317(5837):472–476, July 2007. [FHH+05] E. Frank, M. A. Hall, G. Holmes, R. Kirkby, B. Pfahringer, and I. H. Witten. Weka: A machine learning workbench for data mining., pages 1305–1314. Springer, Berlin, 2005. [HFH+09] Mark Hall, Eibe Frank, Geoffrey Holmes, Bernhard Pfahringer, Peter Reutemann, and Ian H. Witten. The weka data mining software: An update. SIGKDD Explor. Newsl., 11(1):10–18, November 2009. [Koh95] Ron Kohavi. A study of cross-validation and bootstrap for accuracy estimation and model selection. In Proceedings of the 14th International Joint Conference on Artificial Intelligence - Volume 2, IJCAI’95, pages 1137–1143, San Francisco, CA, USA, 1995. Morgan Kaufmann Publishers Inc. [Per] Markus Alexej “Notch” Persson. Named binary tag specification. http://web.archive.org/web/20110723210920/http://www.minecraft.net/docs/NBT.txt. [Online; accessed 31-August-2014]. [SS98] A.J. Smola and B. Schoelkopf. A tutorial on support vector regression. Technical report, 1998. NeuroCOLT2 Technical Report NC2-TR-1998-030. [Yee] Nick Yee. Crafting and trading from “The Daedalus Project”. http://www.nickyee.com/daedalus/archives/001629.php. [Online; accessed 2-September-2014]. 27