# A Swarm-Based Approach to Generate Challenging Mazes
## 3 Swarm Movements to Generate Challenging Mazes
### Proposed Methodology to Generate a Challenging Maze
The maze with the highest value of complexity obtained during 40 iterations in the same run is shown in Figure 4. Referring to Figures 3 and 4, generated mazes have complexities of 8478 and 16,875, respectively (an improvement is equal 99.05%). Note that mazes are shown in terms of blocked (black) and \begin{table}
\begin{tabular}{c c c c c|c c c c} \hline \hline \multirow{2}{*}{**Population**} & \multicolumn{3}{c|}{**Complexity**} & \multicolumn{3}{c}{**Improve [\%]**} \\ \cline{2-9}  & **Min** & **Max** & **Average** & **STD** & **Min** & **Max** & **Average** & **STD** \\ \hline
5 & 6768 & 9381 & 7972.11 & 1239.39 & 22.84 & 275.75 & 137.91 & 73.68 \\
15 & 13,325 & 16,875 & 14,358.57 & 1198.08 & 87.46 & 240.03 & 168.55 & 61.00 \\
25 & 15,470 & 19,039 & 17,207.54 & 809.63 & 55.97 & 329.14 & 241.09 & 93.67 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Selected statistics after 40 iterations. Figure 2: The best run of the presented method for generating mazes with the highest measure of complexity during 40 iterations, for various sizes of the population. The vertical axis is the value of complexity, and the horizontal axis is the number of iterations. accessible (white) cells. The path for these mazes is marked as red line. Green and blue squares denote the entry and exit points, respectively. When analyzing the results obtained with the use of the algorithm, we should notice that the increase of the population size increases the number of function evaluations in each iteration. Therefore, Table 3 corresponds to a comparable number of function evaluations (1000 during the whole run of the algorithm). Figure 4: The maze with the highest measure of complexity after 40 iterations for a swarm of 15 individuals (green represents the start point, blue denotes the exit). Figure 3: The maze in the initial population of 15 individuals with the highest measure of complexity (green represents the start point, blue denotes the exit). The statistics obtained over 100 independent runs for the test maze indicate that the variability of the results obtained is inevitable. Figure 5 shows the average (mean) and standard deviation (STD) values of complexity changing during 40 iterations (Figure 5a) and the number of function evaluations equalling 1000 (Figure 5b). It is clearly visible that for a small population (five individuals in our case), the increase of the number of iterations and so the number of function evaluations leads to a slight improvement in the results obtained. One can see a very small improvement in the average value of complexity for the population size of 15 individuals. ### Experiments for the Complexity of the Path and Branches

What if we take the second objective function (see Equation (3))? The motivation for using this function is that it is more complicated and the swarm algorithms can result in a lack of improvement. We still use the same way of movement as we used before. Note that the basic instance that we consider in this work is the maze size of 25-by-25 cells. Recall, the control parameters of our approach can influence the results obtained and the algorithm behavior. Therefore, experiments were conducted and repeated to determine how selected parameter values influenced the degree of complexity of the generated maze. Moreover, a result is kept of how the number of iterations it takes to build mazes with higher complexity on each run. Figure 6 shows the results of the selected run process for the second objective function, for the population size ranging from five to 25 solutions. As can be seen, a fairly significant improvement of the optimization process occurs upon increase of the population size. The approach was able to improve the results in all of the trials. Firstly, each run of the presented algorithm was terminated after 40 iterations. The best result was obtained for the population equal to 25. Note that the best initial solution for said population size was the same as the best solution for the population equalling 15 individuals.