{'fraction_non_alphanumeric': 0.02960620049011227, 'fraction_numerical': 0.00775061264033738, 'mean_word_length': 4.5180817610062896, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Novel CNet-assisted Evolutionary Level Repairer and Its Applications to Super Mario Bros

Applying latent variable evolution to game level design has become more and more popular as little human expert knowledge is required. However, defective levels with illegal patterns may be generated due to the violation of constraints for level design. A traditional way of repairing the defective levels is programming specific rule-based repairers to patch the flaw. However, programming these constraints is sometimes complex and not straightforward. An autonomous level repairer which is capable of learning the constraints is needed. In this paper, we propose a novel approach, CNet, to learn the probability distribution of tiles giving its surrounding tiles on a set of real levels, and then detect the illegal tiles in generated new levels. Then, an evolutionary repairer is designed to search for optimal replacement schemes equipped with a novel search space being constructed with the help of CNet and a novel heuristic function. The proposed approaches are proved to be effective in our case study of repairing GAN-generated and artificially destroyed levels of Super Mario Bros. game. Our CNet-assisted evolutionary repairer can also be easily applied to other games of which the levels can be represented by a matrix of objects or tiles.


I. INTRODUCTION
Procedural content generation (PCG) refers to the generation of game content (including rules, levels, maps, sound, background stories and so on) automatically without or with limited help of human designers [1]. It has become a popular area in recent years. With the development of video games, the scale of game production teams is also expanding. This leads to increasingly expensive development costs of game production. PCG techniques can reduce the workload of game designers or give designers inspiration. That means, for big game companies, PCG techniques can decrease the costs and shorten cycle for game production. On the other hand, PCG can also lower the technology and capital threshold of complex game development so that those small teams, even singleperson developers, who have good ideas can realize their ideas with PCG techniques. What's more, some games need automatic content generation after their publication, including real-time content generation. Those games will be the biggest beneficiaries of development of PCG.
Mario AI framework is designed for the game AI competition for Super Mario which includes a PCG track [2]. After T. Shu and Z. Wang contributed equally to this work. 2010, some level generation methods for Super Mario based on the Mario AI framework have been proposed (e.g., [3]- [8]). Some of those methods are based on human designed grammars [3] or patterns [4]- [6]. Those methods have their own advantages respectively. However, they still need human designers to specify the behaviors of generators.
In 2018, Volz et al. [7] successfully applied latent variable evolution (LVE) [9] to level generation of Super Mario Bros. They trained a Deep Convolution Generative Adversarial Networks (DCGAN) and use its generator to generate Super Mario Bros levels. Their approach is powerful, but they mentioned GAN will generate broken pipes sometimes in [7]. This raised our interests in repairing the logic errors of levels generated by GAN.
When the DCGAN generates the tiles to build a level, it cannot "consider" the surrounding neighbor tiles of each tile. We think this is the reason of broken pipes generated by GAN. Broken pipe is a microcosm of a stubborn problem of GANbased method: there are usually some rules for game level design but the model cannot learn them due to its own network structure. One may think of using a Recurrent Neural Network (RNN) as the model of GAN [10]. RNNs can partially handle the broken pipes problem since they take some connection with neurons in the same layer. But the constraints of level may be complex, and the correctness of a tile may be influenced by the neighbor tiles in multiple directions. Besides, in terms of level generation, the network model of DCGAN may have some potential superiority comparing to RNNs. In fact, we have tried to train a GAN on a dataset of more levels in Super Mario Bros with 35 types of tiles in total. New types of tiles bring more constraints and cause more logic errors made by the GAN. Therefore, an automatic algorithm to repair levels with logic errors is desired.
A straightforward way to automatically repair logic errors is writing a script to edit the level files based on some predefined rules. However, as mentioned previously, a significant advantage of LVE approach is that it can learn how to design levels without expert knowledge. If we need to design a repairing rule for each different game and each different type of errors, why not designing a pattern-based or grammar-based generator directly? We'd like to devise an approach to repair the levels generated by GAN without the help of human designers. In this work we focus on using AI techniques to (i) exam the generated level and detect the logic errors, and then (ii) repair the logic errors in levels without human designers' help.
In this work, we come up with an approach to learn the level constraints from real levels and then repair the defective levels generated by GAN. This approach is inspired by the thinking process of human when repairing broken pipes for Super Mario Bros levels. When one sees a broken pipe, this person will detect several possibly error tiles by observing their surrounding tiles. And then, this person may think of some schemes to replace those error tiles and analyze if this scheme is proper. After considering several replacement schemes, the best one and the resulted optimally repaired level will be determined. Our proposed approach imitates this process. First, we train a Multi-Layer Perceptron (MLP) model to judge whether a tile disobeys the constraint or not by taking its surrounding tiles as input. When repairing a defective level, we use the model to label the error tiles first, and then use a genetic algorithm (GA) to search for replacement schemes for those error tiles. In our case study, we have applied our approach to determining and repairing the broken pipes in Super Mario Bros levels generated by MarioGAN [7] and our experimental study has validated its effectiveness.
The remainder of this paper is organized as follows. Some related work on PCG and Mario level generation are presented in Section II. Section III presents our proposed CNet for detecting error tiles in generated levels and recommending alternatives for repairing. Our novel evolutionary repairer is presented in Section IV. The experimental studies on these two approaches are described in Sections III-D and IV-D, respectively. Section VI concludes and discusses future work.

II. BACKGROUND
Section II-A reviews the level generation methods for Super Mario Bros. Section II-B presents particularly the MarioGAN framework. The other ingredient, genetic algorithm, is briefly introduced in Section II-C.

A. Mario Level Generation
Level generation is an important part in PCG. The 2010 Mario AI Championship held an academic PCG competition [2] which the participants need submit a generator for Super Mario Bros level. This competition touched off a series of studies on Mario level generation. Shaker et al. used Multi-Layer Perceptron (MLP) models to predict the players' preference [11], and applied grammar evolution to generate personalized level by optimizing the predicted value of their model [3]. Steve et al. designed many patterns for Mario levels [4] and using patterns as objectives and generate levels by evolutionary algorithms (EA) [6]. Those methods belong to search-based methods [12], they usually need some expert knowledge.
In recent years, Procedural Content Generation via Machine Learning (PCGML) [13] has been more and more popular since it needs little expert knowledge of target games. Those methods usually represent the levels as a matrix of tiles, just like image, then generate the tiles one by one using some machine learning technologies for image processing. Snodgrass and Ontan generated Mario levels with Markov chains [14]. In 2016, Jain et al. applied autoencoders on level generation, repair, and recognition [15]. They focused on repairing unplayable levels but not logic errors of levels [15]. Summerville et al. trained LSTM to learn level distribution and generate new levels [16]. Gutierrez and Schrum [17] combined a GAN method and a graph grammar method to generate levels for The Legend of Zelda. Schrum et al. [18] used Compositional Pattern Producing Networks (CPPNs) to combine Zelda level segments generated by GANs into complete levels. [19] presented an interactive level design tool which allows the human designer to edit latent vectors of the trained generative models to generate diverse levels that can be represented as two-dimensional arrays of tiles. In 2019, Lucas and Volz used Kullback-Leibler (KL) to analyze game levels, proposed a level generation method called Evolution with Tile Pattern KL Divergence (ETPKLDiv) [8]. Broken pipes also occur in the generated levels illustrated in Figure 6 of [8].
There are many methods for Mario level generation, each method has its own advantages. However, broken pipes problem is a common problem for some Mario level generators, especially those who need little expert knowledge.

B. MarioGAN
DCGAN was successfully applied to level generation of Super Mario Bros in 2018 [7]. In [7], a level was represented by a two-dimensional array of tile codes, while each code referred to one of the 10 different tile types. The Video Game Level Corpus (VGLC) [20] encoding is to used represent the levels. Table I shows the tiles, their corresponding VGLC encoding and the mapped values. We use the same encoding in our work. In their work, only one level of Super Mario Bros was used to train a Generative Adversarial Network (GAN), and then a Covariance Matrix Adaptation Evolution Strategy (CMA-ES) was used to search in the latent space to further optimize the generated levels [7]. In the optimization phase, an AI agent was used to test the generated levels. This framework also called Exploratory Latent Search GAN (ELSGAN) by Lucas and Volz [8]. One of the most attractive qualities of ELSGAN is that it can learn how to design levels automatically without predefined generation rules, grammars or patterns for the specific game. That's to say, it may be applied in any games whose level can be represented as a twodimensional array of discrete values without the knowledge of the specific game. However, this framework cannot learn the combination constraints of levels which leads to some generated levels with logic errors. Taken the Super Mario Bros as an example, broken pipes may appear in the levels generated by GAN.

C. Genetic Algorithm
Evolutionary computation techniques have been widely applied in optimizing game-playing strategies and designing games, in particular tuning game AI agents and evolving game  [7], [8], [18], [19] and this paper. skill-depth, such as in [21], [22]. Genetic Algorithm (GA) [23] is a family of evolutionary algorithms which simulates the process of the inheritance and evolution of the creature. GA is suitable for approximately solving black-box optimization problems in discrete domain. At each generation, GA applies some search operators to generate new individuals (solutions) and select the best ones to survive for the next generation. Two of the major challenges of GA are the design of representation and fitness function. In this work, we have designed a novel fitness function for repairing game levels and defined a narrowed search space but with diversities to accelerate the search. We designed a MLP model, named as CNet, to learn the constraints of pipes in Super Mario Bros levels and check the levels generated by GAN.

III. CNET: A NOVEL AUTOMATIC QUALITY CONTROLLER
Before introducing the CNet in details, we present the definitions used in this paper. For any position (i, j) in a level, we consider a tile grid of size 3 × 3 with (i, j) as the center. A combination is defined as a sequence of the height of the central tile and the 9 tile types in the 3 × 3 grid. A surrounding info is defined as a sequence of the height of the central tile and the tile types for its 8 surrounding tiles.
For each position and tile type, the surrounding info which appears in the training data is called true surrounding info, while the ones do not appear in the training data are called fake surrounding info. For instance, given a combination (13, 2, 2, 5, 0, 6, 7, 0, 8,9), then the type of the central tile is 6 (top-left pipe) and its height is 13. The corresponding surrounding info is (13, 2, 2, 5, 0, 7, 0, 8,9). For a given true surrounding info, a tile is called legal tile if there exist a combination in training data which contains the surrounding info and this tile as center tile. Otherwise, this tile is called illegal tile. For example, giving (13, 2, 2, 5, 0, 7, 0, 8,9), the "6" is a legal tile. The "0" is an illegal tile since the combination (13, 2, 2, 5, 0, 0, 7, 0, 8,9) does not appear in the training data.

A. CNet
The CNet executes as follows. For each of the tiles of a given generated level being checked, the CNet takes its ycoordinate and its surrounding tiles (i.e., a surrounding info) as input, as we assume that the vertical position of the tile may be significant to judge its rationality in this game, and outputs the predicted possible types of this tile being inspected. The process is illustrated in Fig. 1. The input layer can be seen as a hollow cube of (3 * 3−1) * 12 size plus one single input. Width and height of the cube correspond to the relative position of the center and the 12 channels correspond to the 12 tile types including the outer type which refers to the periphery of the level. There are 2 full connected hidden layers in CNet. The first layer has 100 neurons and the second one has 50 neurons. Softmax is used at the output layer and CrossEntropy loss is used. The output layer gives the probability distribution over the tile types listed in Table I, of which the sum is 1.

B. CNet as a tile inspector
For each position (i, j) in the generated level being checked, let t denote the present tile type. the CNet takes into its surrounding tiles as input and output the probabilities of having different tile types at (i, j). If the probability of having the tile type t at position (i, j), denoted as P (T i,j = t), is under a given threshold θ, it is a wrong tile. 1

C. CNet as a tile recommender
When the CNet determines a wrong tile, it can also recommend tiles for this position. To do so, a truncation step is introduced to detect the less possible tile types for classification. For any position, the tile type with a probability above the threshold θ is defined as a candidate type for this position. There could be one or more candidate types at the tile being checked. Therefore, a wrong tile can also be defined as the tile that is not filled with a candidate type.

D. Experiments and results
We define unstable tiles as the tiles that have more than one candidate types of a level l being repaired. The set of unstable tiles in a level l is denoted as U(l). C l i,j denotes the set of candidate type at position (i, j) of level l. An unstable value, U V (l), is defined as the sum of number of candidate types for all unstable tiles in it, formalized as follows: To test our CNet and evolutionary repairer, we have designed three experiments and corresponding test data sets to answer the following three questions: • How does CNet perform in recommending legal tiles and eliminating illegal tiles? • How would CNet perform giving a fake surrounding info? • When the surrounding info is fake, thus it does not appear in training data, will the amount of unstable tiles and unstable values increase? In all the experiments, seventeen levels from the Mario AI framework are used as training data. The CNet has been training for 4, 000 epoch using all non-repeated 3 * 3 grids from the training data. The truncation threshold, θ, is set as 0.05 in all experiments.
1) CNet classifies excellently legal tiles and illegal tiles: To test the performance of CNet in recommending legal tiles and eliminating illegal tiles, we have designed two tests and generated two test data sets.
The first test data set contains all combinations which appear in the training data. It is aimed to test whether the set of candidate type provided by our CNet contains the legal tile's type giving true surrounding info. The second test data set contains all combinations which do not appear in the training data, but there is no fake surrounding info. It is aimed to test whether illegal tiles will be detected by our CNet giving true surrounding info. These results are categorized by the type of central tile. The "True" column of Table II summaries the results of the first test. Note that all the tiles are legal in this test, thus there is no negative data. For each central tile, if the candidate types recommended by our CNet contains the legal tile, then it is considered as a correct classification. The reason is that giving a true surrounding info, there could be more than one legal central tile. Results show that the candidate tiles always contains the legal tiles of which the codes are 6, 7, 8 and 9. They are the codes for composing pipes. It means that our CNet is able to learn the combination constraints of different types of pipes. But for tiles around pipes, such as the ground tiles ("0"), breakable tiles ("1") and monster tiles ("5"), legal tiles are sometimes eliminated from candidate types. Especially, the full question tile ("3") is always wrongly eliminated from the set of candidate types. Actually, the total number of combinations which have a full question tile as central tile is 2. It is possible that the CNet did not learn this constraint well due to the very limited amount of data. The "True" column of Table III gives results of the second test. When giving true surrounding info, our CNet successfully detected correctly most of the illegal tiles.
In conclusion, CNet performs excellently in recommending legal tiles and eliminating illegal tiles. 2) Fake surrounding info made classification harder: True surrounding info may become fake when there is one or more error tiles in it. In the generated levels, multiple error tiles may be adjacent. When repairing one of them, the surrounding info is fake. To test the performance of CNet giving fake surrounding info, we generate test data on basis of the test data in the previous experiments. We randomly change the type of one, two or three tiles in the true surrounding info to make it fake.
Firstly, we want to test whether legal tiles of true surrounding info still contains in the candidate types of fake surrounding info. The columns "Fake 1", "Fake 2", and "Fake 3" of Table II show the results of using the data sets with one, two and three randomly changed tiles in combinations. When the surrounding info is fake, the number of cases of eliminating legal tile wrongly increases substantially.
Secondly, we want to test whether illegal tiles of true surrounding info will be detected from the candidate tiles of fake surrounding info. Table III shows the result. When the surrounding info is fake, the elimination rate decreases. This means that more illegal tiles are contained in candidate tiles. "|U |" refers to the number of unstable tiles and "U V " is the unstable value.
3) The Unstable Value is informative: In this experiment, we want to answer the third research question and check if the unstable value and unstable tiles can assist with the identification of broken areas in a level. To do so, we have generated three test data sets by editing the original training data. Giving a surrounding info as input, the trained CNet outputs the candidate types for the center cell. Then the unstable value (Eq. (1)) of this center tile is calculated to determine whether it is an unstable tile or not. Then we randomly change the type of one, two or three tiles in the surrounding info to generate a new tile probably with the fake surrounding info. Again, the unstable values and amount of unstable tiles are calculated for each case. We also calculate the original unstable values without classification of CNet for the training data as reference. In the training data, if any two different tile types have the same surrounding info, we say that this surrounding info corresponds to an unstable tile and the unstable value is at least two. Table IV shows the results. We can see that the amount of unstable tiles in the "True" column is greater than the amount in the "Original" column. It reflects that CNet mixed illegal tiles into the candidate types for some surrounding info. The "Fake1", "Fake2", "Fake3" columns have greater unstable values and larger amount of unstable tiles than the "True" column. This implies that fake surrounding info is linked with unstable tile. CNet may not judge well giving fake surrounding info. Therefore, the possibility is shared, making more tile types into the set of Candidate Types. So the unstable value and the amount of unstable tiles increase. When repairing levels, we can use the unstable value as an indicator. Smaller unstable value means less fake surrounding info in levels. Less fake surrounding info means fewer broken areas in levels.
In conclusion, unstable value indicates the amount of fake surrounding Info. And unstable value can assist with the identification of broken areas in a level.

E. Discussion
The CNet performs well in detecting the illegal tiles and recommending alternative for fixing the wrong tiles. To fix a wrong tile, it seems to be straightforward to directly replace it by the candidate tile type with the highest probability classified by the CNet. However, our primary experimental study (omitted due to the length limit) shows that this simple repairing operation, winner-takes-all, performed poorly on the Mario levels generated by GAN. There are mainly two reasons. First, an error tile will influence the decision of its surrounding tiles. Secondly, our CNet does not always make perfect classification. To offset the imperfection of CNet, we propose to use a genetic algorithm to search in the combination space and design some novel heuristic functions to direct the search.

IV. EVOLUTIONARY REPAIRERS WITH A NOVEL HEURISTIC
As a level is a two-dimensional array of discrete values, we use a genetic algorithm (GA) to search for good replacement schemes (thus, combinations) in the original level to repair the broken areas. Although we're actually optimizing a replacement scheme, our work treats the solution of the search as a complete level for convenience. The encoding of the solution is a dictionary whose key is the position to be replaced and value is the alternative type.

A. A narrowed search space with diversities
Defining the search space is not trivial. Primary experimental study using only the wrong tiles as the solution space showed that, sometimes, only replacing those tiles could not lead to a correct level at all. However, we still want to narrow the solution space as much as possible to guarantee the efficiency of our algorithm and keep the features from the original levels as much as possible. Therefore, we define the solution space as the set of all the error tiles and all the tiles that have alternatives. We use S l to denote the set of wrong tiles and unstable tiles in a training level l.

B. Search operators
Algorithm 1 presents our search operators. The crossover operator aims to combine good replacement schemes randomly to get better solutions. For a given solution x, our mutation operator generates a new solution x by replacing the tiles in S l with types in candidate types of original level l at position (i, j). We design this operator to add new individuals into the population. The repair operator changes the types of the unstable tiles to a randomly selected candidate type. We design it to search in the local space. Our main process (Algorithm 2) performs crossover, selection, mutation, selection, repair and selection in turn at each generation. For the selection operator, we just select the best n individuals.

C. Fitness design
We want to minimize the number of errors in the final solution. Besides, we want to keep the features from the original levels as much as possible. So we minimize the number of Replaced Tiles, |R(x)|. Additionally, the Unstable Value is used as a third item to assist with repairing. When the amount of fake surrounding info decreases, the performance of CNet will be better. As a result, a weighted sum of the above three metric is used as the fitness function in our work, formalized as follows: Algorithm 1 Search operators for repairing a level l. S l denotes the set of wrong tiles and unstable tiles in l, represented by their positions. x(i, j) denotes the element at position (i, j) of 2D array x.

D. Experimental setting and results
We design two levels with flaw to test the performance of our evolutionary repairer. In the first test, we train a GAN with the same structure of the one described in [7], while the same training data as for training the CNet (detailed previously in Section III). Then, some defective levels are collected from the levels generated by GAN (Fig. 2a). In the second test, different types of pipes from the training maps have been collected and put in one map. Then, tiles in this map are randomly selected to be destroyed. An example is shown in Fig. 3a.
In all the experiments, the weights in the fitness function (Eg. 2) are set as ω 1 = 5, ω 2 = 3 and ω 3 = 1 after fine tuning. All the individuals in the population are initialized by randomly setting a tile type for the unstable tiles in solution space (cf. Section IV-A) using uniform distribution and applying repair once as described in Algorithm 1. The initial values of parameters are shown in the first line of Algorithm 2.
When a tile is determined as a wrong tile, its alternative can be randomly selected from the Candidate Tiles following Algorithm 2 Evolution process for repairing a level l. while |X | < n do 8: Choose different x i , x j from X according to probability P x (x ∈ X ) 9: x 1 , x 2 ←CROSSOVER(x i , x j ) 10: end while 12: for x in X do 13: if U nif ormRandom(0, 1) ≤ p m0 then Evaluate fitness of all x in X 21: X ← The best n individuals of X ∪ X selected using Round-robin Tournament. 22: Update the best individual 23: end while 24: return the best individual a designed probability distribution. Three of the most common ways are using (i) a distribution with one element of 1 and others 0, thus winner-takes-all; (ii) a normalized distribution after truncating the probability output by the CNet or (iii) a uniform distribution. We have tested all of them in our experiments and only give the results of the third one in Figs. 2a and 3a due to its superior performance comparing to the other two and the length limit of the paper. The failure of (i) has been explained previously in Section III-C. The failure of (ii) is probably due to the fact that empty tiles often occupy with the highest probability when surrounding info is fake. Fig. 2 illustrates an example of the progress of repairing a defective level generated by GAN. At the beginning (Fig.  2b), there are some wrong tiles (highlighted by red boxes) and many unstable tiles (highlighted by blue boxes), due to the influence of fake surrounding info and the low truncation threshold θ (cf. Section III-C). When the optimization continues, the number of wrong tiles and unstable tiles is decreasing. After 4 generations only (Fig 2e), there are only 2 wrong tiles and a small amount of unstable tiles left. Then, after 8 generations (Fig 2f), only one wrong tile remains. After 25 generations, the level is almost perfectly repaired. Compared with the original level, the flaws are repaired perfectly and only a few tiles were changed. It is consistent with the design of the fitness function. Some broken pipes are erased, while some  are repaired. This case study shows that genetic algorithm can get a variety of reasonable results. Fig. 3 shows the results of repairing randomly destroyed levels. From Fig. 3b, we can see that destroyed tiles are well recognized and marked by our CNet. Fig. 3g shows the best repaired level after 25 generations. We can see that all different broken pipes are well repaired. However, a few tiles around pipes are changed. There are two possible reasons: the evolutionary process is uncertain; the CNet has not been trained perfectly and may mark some legal tiles as wrong tiles.
To visualize the evolution process, we present the evolu-tionary curves of the values of fitness and the three items in the fitness function (Eq. (2)) among the population averaged over 30 trials in Fig. 5. The Unstable Value (yellow curve) and the number of Wrong tiles (blue curve) decrease rapidly. This is because of the repair step described in Algorithm 1. The number of replaced tiles increases slowly. When it stops increasing around generation 5, the other values still decreases and the number of replaced tiles takes a main part of the fitness value, as what we expected, replacing fewer tiles while repairing the level better. Fig. 4 is the scatter diagram of all individuals when repairing a randomly destroyed level in an arbitrary optimization run. The fitness values of individuals converge gradually and the diversity among individuals' fitness is clearly shown.

E. Discussion
We design an evolutionary repairer to search for optimal replacement schemes for repairing defective levels. This evolutionary repairer is equipped with a novel search space being constructed with the help of CNet, and a novel fitness function considering the number of wrong tiles, the number of replaced tiles and unstable tiles in a level. The proposed approach is proved to be effective in our experiments of repairing GANgenerated Mario levels (Fig. 2) and randomly destroyed levels (Fig. 3a).

V. STATISTICAL SIGNIFICANCE AND ANALYSIS OF REPAIRED LEVELS
To examine the statistical significance of our CNet and evolutionary repairer, we trained 10 CNet models using distinct random seeds which were further used to repair 10 randomly destroyed levels generated from the level with all types of pipes designed in Section IV-D. Each model has been trained for 4,000 epochs and uses more strict criteria to evaluate repair results. Tiles whose surrounding info appear (height is not included) in training data are labelled as right, otherwise, the tiles are wrong. Batch size is set as 1. We compare the tiles in the level segments before and after repairing, and analyse the number of tiles that have been edited and their status in Table V.
The notations used in Table V are defined as follows. The symbols "→" and "=" indicate if a tile is replaced or not after repair. "W" and "R" indicate if a tile is labelled as wrong or right. Therefore, W → W refers to the situation that a wrong tile is replaced but remains being labelled as wrong; W = R refers to the situation that a tile is not replaced, but its label is changed from wrong to right after being repaired due to the changes of it's surrounding tiles; W = W means that a wrong tile is not replaced at all. R → R, R = R, R → W , W → R are defined similarly. The bottom row illustrates the ratio between the amount of wrong tiles after and before repair, thus the smaller the better. A venn diagram (Fig. 6) is also included to assist the understanding of relations between these changes of tile status.
We can see that the amount of R→R and R→W is zero which means our method will not replace the right tiles. The    yellow set is very small compared with the red set. It means our method can fix most of wrong tiles. W=W takes a big part of the yellow set. The reason is that our CNet is not trained perfectly. Our CNet will regard some wrong tiles as right tiles. So these tiles are not replaced during evolution process and remain wrong. So the performance of our method is based on the quality of CNet a lot. Avoiding overfitting and training a better CNet will decrease the wrong tiles after repair.

VI. CONCLUSION AND FUTURE WORK
In the last few years, more and more PCGML methods have been applied to level generation. However, logic errors may occurs in the generated levels. Therefore, we focus on video game levels that can be represented by 2D images and design a CNet and an evolutionary repairer for automatically detecting errors in levels generated by PCGML and repairing the defective levels.
In this work, we consider a specific case: broken pipes in levels of Super Mario Bros. We design a CNet to detect and repair error tiles in Mario levels, and an evolutionary repairer with a special search space and novel heuristic to search V: Repair results of 10 CNet models trained with distinct random seeds. The original level segment with all pipe types has been randomly destroyed to generate 10 broken level segments, which have been repaired individually using the evolutionary repairer described in Section IV. Each cell shows the result averaged over the 10 levels fixed by each CNet model. The notations are explained in Section V.

Before
Index of Net Avg.  Table V. The universal set represents all tiles which contains pipes in surrounding info. The red set contains tiles which are wrong before repair. The yellow set contains tiles which are wrong after repair. The blue set contains tiles which are replaced during repair. R = R represents the complementary set of the union of the blue, red and yellow sets.
for replacement schemes used for repairing the defective levels. Our CNet-assisted evolutionary repairer by combining these two approaches successfully identified the error tiles in levels generated by MarioGan [7] and repaired nearly without specific human knowledge for this game in our experiments. This CNet-assisted evolutionary repairer can be used together with the MarioGan [7] for designing and repairing levels for other games which can be encoded in the similar way.
Our approaches can be further improved in different ways. The performance of our CNet-assisted evolutionary repairer highly relies on the quality of the trained CNet model. Improving the structure or the training process of CNet to make it more reliable is worth investigating. What's more, our CNet was tested on learning the constraints of pipes in Super Mario Brosonly. Training CNets for all the constraints with the whole set of 35 tile types in Super Mario Brosis challenging but worthy of study in the future. Another future work is applying our approaches to other games of which the levels can be represented as images, such as The Legend of Zeld and Angry Birds, and to generating landscapes for 3D games.