Software Platform for Designing and Running Artificial Intelligence Competitions with a Visualization Subsystem D.A. Korostelyov1, A.O. Radchenko1, N.S. Silchenko1, R.A. Krylov1, P.N. Migal1 nigm85@mail.ru|jameslistener@gmail.com|silchenko.nk@gmail.com|oktopy@gmail.com|p.migal@yandex.ru 1 Bryansk State Technical University, Bryansk, Russia The paper describes the solution to the problem of testing the efficiency of new ideas and algorithms for intelligent systems. Simulation of interaction of the corresponding intelligent agents in a competitive form implementing different algorithms is proposed to use as the main approach to the solution. To support this simulation, a specialized software platform is used. The paper describes the platform developed for running competitions in artificial intelligence and its subsystems: a server, a client and visualization. Operational testing of the developed system is also described which helps to evaluate the efficiency of various algorithms of artificial intelligence in relation to the simulation like "Naval Battle". Keywords: artificial intelligence, intellectual agent, artificial intelligence competition. performed certain actions aimed at winning in the most effective 1. Introduction way. Among the main advantages of the platform are the following: At present artificial intelligence technologies are 1. A unique set of competition rules is implemented. increasingly penetrating into various spheres of human activity. 2. The interactive visualization subsystem displays To apply and develop the technologies and methods of artificial complete statistics during simulation. intelligence effectively, it is necessary to take into account these 3. The interactive visualization subsystem has an intuitive trends in the educational process for training modern display of the competition elements represented by a matrix. professionals, as well as in professional activities in various 4. The visual interactive player uses primitives for display, fields: information technologies, economics, finances, design of so its load on the system is minimal. engineering and control systems, etc. To form corresponding competences both classical methods of training (study of relevant algorithms), and more progressive approaches based on game or competitive principles are used [1]. For implementing the competitive (game) approach a specialized software platform is usually designed or used, which is a system of multiagent simulation. Each participant loads into this system his algorithm represented as a program that implements a special interface to interact with the system. This program in the system represents one or more intelligent agents interacting with each other as a result of simulation (or several simulations). The rules of interaction and capabilities of intelligent agents are determined by scenarios and the corresponding software interface of the system (platform), and the process of development and simulation becomes competitive. One of the key components of such platforms is a visualization subsystem of simulations of intelligent agents’ interaction, which contributes to a better understanding of the implemented algorithms and results in improving and developing them more effectively. By means of the visualization subsystem it is possible to demonstrate the work of both artificial intelligence algorithms and various data processing algorithms in a more visual and comprehensive form. This aspect has a positive impact on students' understanding of the principles of relevant Fig. 1. Interface of Ants AI Challenge visual player algorithms. Such competitions, in addition to training and developing skills in the use and implementation of artificial intelligence As for the disadvantages, they are the following: methods, also allow to find the most talented among the 1. There is no opportunity to participate in the competition, participants [2]. Usually, to participate in the competition not because it has already been held and completed. many skills are necessary, but to win you need to use unique 2. The visual interactive player does not have control algorithms, universal strategies and much more. components. At the moment, there are a considerable number of different Russian AI Cup is a competition of artificial intelligence and platforms for competitions in artificial intelligence [2-5]. intelligent agents who fight in the virtual world instead of their However, such platforms are often developed for one specific owners (Fig. 2) [4]. At all the previous championships more than competition, and after this completion either become open in the 40,000 users have registered on the platform, and they have form of a sandbox, or are completely forgotten by both developed more than 150,000 different solutions in total. Each developers and participants. Among the most famous platforms new championship is a new challenge with its own rules, laws are Ants AI Challenge [3], Russian Ai Cup [4], Mini AI Cup [5]. and mechanic. Ants AI Challenge is a Google product [3]. It was a The main advantages of the platform are the following: competition of intelligent agents, in which users were given API 1. A variety of competitions and problems of simulation to interact with the system (Fig. 1). The user developed artificial the interaction of intelligent agents. intelligence, which based on the tasks of the competition, Copyright © 2019 for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). 2. The competitions take place in both two-dimensional of the visualization system, which could be quite an effective tool and three-dimensional world. for visual evaluation of algorithms implemented in the form of 3. There is online access to the visual interactive player intelligent agents, provided that it is possible to adapt them to a of simulations. specific simulation problem. Therefore, the development of a universal platform that provides competitions in artificial intelligence for different scripts and tasks with different visualization methods is an urgent problem. 2. Description of building a platform for simulating the interaction of intelligent agents Artificial intelligence competitions should be as honest, open and universal as possible. To ensure this, server-based simulating of intelligent agents’ interaction is used. This guarantees to avoid scenario substitution or other violations of the tournament. The server allows intelligent agents developed by specialists located far from each other to compete. Also, with the help of the server, an unlimited number of tournaments for different groups of Fig. 2. Interface of Russian AI Cup visual player participants with unique scenarios can be held. In order to run the tournament according to any scenario developed by the There are some disadvantages as well. They are: organizer, without additional interventions into the system, as 1. For each competition, a new visual display module is well as to debug the implementation of the algorithms in the form used, independent of the previous ones. of intelligent agents, a system of simulating the interaction of 2. There is no most part of the statistics. One can view only intelligent agents is necessary. This feature allows to organize a the main points of the simulation. large number of tournaments with a small amount of time for 3. The visual player has no control components. preparing. 4. There is no possibility of step-by-step simulation In order the participation in the competition should be more playback. visual, and the peculiarities of the algorithms – intuitive, a Mini AI Cup is a product of Mail.Ru Group, which is an visualization subsystem of the competition is necessary. Thus, opportunity to prepare for a larger Russian AI Cup competition the reasons for agents’ winning or losing will be clear not only (Fig. 3). The conditions for competition seem to be simpler [5]. for the authors of the agents themselves, but also for observers of The platform is a set of mini-contests related to artificial the competition, who will also be able to view the visual results intelligence and writing intelligent agents. of the interaction of intelligent agents and evaluate the efficiency of certain implementations of behavioral algorithms. Also, the visualization subsystem allows to track the errors of algorithms and their illogical actions from the point of view of a particular simulation, that improves the efficiency of algorithms determining the behavior of intelligent agents. It also should be noted that holding competitions on insecure devices is not recommended, so that to avoid the possibility to break the logic of the competition and to win unfairly. Having other users' intelligent agents on one device is also not acceptable, because they can be used to update their intelligent agents. 3. Description of software platform The software platform for designing and holding artificial intelligence competitions with visualization subsystem was implemented in C++ using Visual Studio environment. The main feature of the platform is interaction with a large number of people (both participants and organizers). For more convenient interaction, client-server architecture was used, Fig. 3. Interface of Mini AI Cup visual player which is based on the fact that users have an application by means of which they can interact with the organizers (Fig. 4). Among the main advantages of the platform are the The server subsystem allows to design tournaments for any following: scenarios and agents developed in accordance with the 1. A variety of competitions and problems of simulation the requirements of the platform. It receives requests from the interaction of intelligent agents. administrator or from the client application and processes them 2. There is a control system to play back simulations. according to the command sent. The administrator can also 3. Detailed displaying of statistics. receive requests from the organizer for certain actions. The basic The disadvantages are the following: commands are to design a tournament, enter the agent or scenario 1. For each competition, a new visual display module is into the database, to register or authorize the user, connect the used, independent of the previous ones. user to the tournament and run the tournament. 2. There is no possibility of step-by-step simulation The server subsystem is directly connected with the playback. subsystem of the tournament by artificial intelligence. Referring As one can see from the description above, the existing to it, the server runs the tournament and receives the results that platforms for artificial intelligence competitions are not invariant can be provided to administrators, organizers and participants. to the problems for which it is possible to develop intelligent agents. Also in the existing systems there is a lack of flexibility The results are obtained on the server, so the organizer himself must choose how to present the results to the participants. Fig. 5. Player interface by the example of "Naval Battle" simulation To demonstrate the capabilities of subsystems, examples of scenarios and intelligent agents for them were developed, including algorithms visualizing the operation (Fig. 6). Fig. 6. Visualization of sorting algorithm operation Also, with the help of the developed platform, an experimental study was carried out to evaluate the efficiency of various algorithms of intelligent agents’ behavior by the example of "Naval Battle" scenario. Fig. 4. Software platform architecture 4. Description of intelligent agents algorithms The client subsystem allows users to interact with the server under study using a convenient graphical interface when participating in the tournament. The client subsystem of intelligent agents’ The experimental study of the efficiency of artificial interaction is located on the client, and the tournament module is intelligence algorithms [6] was carried out on the basis of 3 main located both on the client and on the server. options for implementing algorithms of intelligent agent Work with the artificial intelligence of running tournament behavior for "Naval Battle" scenario and some of their can be initiated in one of two ways: the user tests the agent before modifications. sending or the administrator begins to calculate the results of the 1. Algorithm based on random events for the scenario. competition. The subsystem of the competition is located on the 2. Algorithm based on the field analytics. client and on the server, which allows to test intelligent agents 3. Algorithm based on the analytics of ship positions. for users quickly, and to calculate the competition on the server easily. 4.1. Algorithm based on random events for the The subsystem of visual display allows script writers to use scenario their materials to display the actions of intelligent agents, using The algorithm of the simplest intelligent agent based on both primitives and textures (Fig. 5). The visual display random events performs the following actions: subsystem is located on the client. It receives data from the server 1. Selection of random coordinates to move. (scripts, test intelligent agents) or from the organizers (textures, 2. Waiting for the opponent's move. competition rules), and then using the script it generates the 3. Checking if the simulation is not finished, then go to simulation and displays it. The generated simulation can be saved step 1. and then loaded for further watching and analysis. This agent makes an extremely large number of moves due There are two ways to start working with the player. The first to the lack of checkings, as it can shoot at the same point, or make is to load the saved simulation. The second is agent testing. In the moves where there is no enemy knowingly (for example, next to case of agent testing, the subsystem of the tournament is the shot ships). initialized and the competition is held. The tournament If coordinate validation is additionally made, the intelligent subsystem interacts with the scenario, which in its turn interacts agent will be able to make a lot fewer moves. This is due to the with the agent. We get an action log as a result, which is then fact that now he does not choose the same coordinates and used by the player for visual display. If we load the saved action analyzes his move in accordance with the rules of the game (if log, the simulation is played at the player's request by frames the enemy is dead, there isn’t definitely any other ship in a radius (moves), and the player displays the data on the screen. of one cell; if the enemy is wounded, then there is exactly a continuation of the ship around). Let us consider 3 modifications for this variant of the intelligent agent. 1. Modification 1 is dividing the field. The field is divided of the algorithm copes with random arrangements in fewer into 4 areas of 5x5 cells. Then moves are made in them by turns. moves, as it does not analyze potentially useless information, In the case of engaging the target, the next move is made in the unlike the other two modifications. same field. 2. Modification 2 is random moves at the beginning. It 4.3. Algorithm based on the analytics of ship implies ignoring damaged ships in the first 10 moves. positions The essence of this modification is that in the first few moves The principle of the algorithm is as follows: before the move, we can find several damaged ships. In some cases, this will allow the agent receives a set of data about the field and counts the us to determine in which direction the ship is directed at once, remaining ships, their quality and quantity [8]. Further, based on and then finish shooting it. Value 10 for the threshold of the this analysis, the agent chooses his move. The basic agent initial moves is chosen based on the fact that the average party performs the analysis but does not use it. This analysis allows to lasts 50 moves. find large enemy ships more likely (three - and four-deck) and as When using this algorithm, during the first 10 moves, if a quickly as possible to get rid of them, opening the space around wounded opponent is found, the rule is applied to him as to the the destroyed ships. killed: the moves are not made within a radius of one cell from Let us consider 3 modifications for this variant of the it. Thus, by the end of the tenth move, up to 90% of the playing intelligent agent. area can be analyzed. 1. Modification 1 is looking for neighbors. This This algorithm is most effective if the opponent places his modification allows to look for neighbors effectively. Firstly, ships remotely from each other. having found a damaged ship, next but one cells from the ship 3. Modification 3 is greedy match. If there is a hit, then not are checked. In the best case, you can find neighbors or the end adjusting cells are checked firstly, but the cells next but one. of the three-deck ship. In case if there are no two-, three - and This modification is similar to the second, but has some four-deck ships left, restrictions are removed. If there are no more differences: if the second modification tries to view as much places that meet the requirement, the agent tries to finish shooting space on the field, the third does it more consistently and them, "connecting" neighboring damaged cells. If there are still throughout the whole game. ships in the field, neighboring cells are checked. The use of modification 3 saves moves on damaging three- This algorithm works very well with space strategies that try and four-deck ships. to leave the maximum amount of free space in order to place the ships as close as possible to each other. 4.2. Algorithm based on the field analytics 2. Modification 2 is "greedy" finishing. This agent The principle the algorithm operating on the basis of the field calculates whether there are two-, three - or four-deck ships left analysis [7] is as follows: before the move, the agent checks the in the field. If left, the next move is made with the indentation of presence of damaged ships on the field and acts accordingly to two, one or zero cells, depending on the remaining ships. The destroy them. If there are no more damaged areas, the algorithm agent tries to finish shooting the ship immediately, starting from makes predetermined moves. The basic version of the algorithm the end. goes through the field from left to right, from top to bottom. It is the most effective if the opponent puts his ships close to Let us consider 3 modifications for this variant of the each other. It also makes it easy to finish shooting large ships. intelligent agent. 3. Modification 3 is limiting the field depending on the 1. Modification 1 is diagonal analytics. On average this remaining ships. This modification ignores the part of the field analysis makes it more likely to find ships from larger to smaller. depending on the remaining ships. If there is one four-deck ship The essence of the algorithm is that initially the parallels to the left, the moves are made with a margin of 3 cells from the edge. diagonal line with an indentation between them equal to the size Thus, 6x6 field is analyzed first of all. The restriction is ignored of the largest ship are checked sequentially. If the largest ship has when trying to finish the ship. If a four-deck ship is found and already been destroyed, reduce the indentation to the currently destroyed, the indentation is changed to 2 cells. If all three-deck largest ship. ships are found, indentation is changed to one cell. If there are no This algorithm has a great dependence of efficiency on the more double-deck ships or no cells satisfying the condition, the angle in which the opponent has ships, and from what angle he restrictions are removed completely. starts. If ships are evenly spaced, the dependence disappears. Using this modification can significantly speed up finding 2. Modification 2 is staggered order. It is the most effective ships if they are located in the direction of the center. if the opponent has placed his single-deck ships on one of the colors of the checker. 5. Experiment results 3. Modification 3 is the method of "dogtooth". This A series of experiments in the form of simulation of modification makes the combinations of moves on the field, intelligent agents’ interaction was carried out with each of the shown in Fig. 7, so covering the whole field. algorithms. According to the results of the experiments, statistical data characterizing these algorithms were obtained. The average values of these characteristics are presented in table. 1. The fastest option in terms of the number of moves was modification 3 of the algorithm, based on the field analytics. This is due to the fact that it has the most versatile analytics that allows to reduce the average number of moves to search. It should be noted that the time to execute a single move in an analytics-based algorithm without modification is extremely fast. This is due to the fact that the algorithm does not need to calculate any action, and it is enough to focus only on checking Fig. 7. "Dogtooth" sequence of moves the rules of the game and reading information about the next, predetermined move. This modification can significantly speed up finding of ships if they are located in the direction of the center. This modification № Number [7] Norwing, P. Artificial Intelligence: A Modern Approach. – Average UK: Glivice, 2014. – 1408 p. Algorithm of time (ms) [8] Riley, D. Abstraction and data structures. Introductory moves 1. Random events. No modifications. 52.1 23.7 course. – Cambridge, MA; London, UK: MIT Press, 2018. 2. Random events. Modification 1. 49.6 24.6 – 310 p. 3. Random events. Modification 2. 47 24.3 4. Random events. Modification 3. 55.2 27.1 5. Field analytics. No modifications. 77.9 14.8 6. Field analytics. Modification 1. 50.7 21 7. Field analytics. Modification 2. 51.7 21.1 8. Field analytics. Modification 3. 43.3 21.1 9. Analytics of ship positions. No 53.2 27.9 modifications. 10. Analytics of ship positions. 38.6 25.5 Modification 1. 11. Analytics of ship positions. 51.9 28.4 Modification 2. 12. Analytics of ship positions. 59.3 45.8 Modification 3. Table 1. Comparison of intelligent agents implementing various algorithms of "Naval Battle" scenario. 6. Conclusion The developed system allows to design scenarios with different conditions, as well as to set their own unique display and run an unlimited number of tournaments according to these scenarios. It can also be used as a learning system due to special scenario tasks in which the user needs to implement the algorithm and send the result to the server for verification. In addition to the considered scenario of "Naval Battle" type, the system was tested on scenarios such as "War of Viruses", "Snakes", as well as on educational tasks of matrix diagonal display and array sorting in order to demonstrate the work of the corresponding algorithms visually. Templates are also available for the developer to create their own scripts and test agents to them with the necessary recommendations. The distinctive features of the developed system in comparison with other platforms are its versatility and invariant property, both in the supported scenarios and in the methods of visualization of intelligent agents’ interaction. Also, the flexible system of visual display of scenarios allows to develop more effectively and debug algorithms in various fields of artificial intelligence. The system developed was used for artificial intelligence competition in Bryansk regional IT-festival, held under the guidance of the 29th international conference on computer graphics and machine vision GraphiCon 2019. 7. References [1] Chesani F., Galassi A., Mello P., Trisolini G. (2017) A Game-Based Competition as Instrument for Teaching Artificial Intelligence. In: Esposito F., Basili R., Ferilli S., Lisi F. (eds) AI*IA 2017 Advances in Artificial Intelligence. – AI*IA 2017. Lecture Notes in Computer Science, vol 10640. – Springer, Cham. [2] F. Lu, K. Yamamoto, L. H. Nomura, S. Mizuno, Y. Lee and R. Thawonmas. Fighting game artificial intelligence competition platform. – 2013 IEEE 2nd Global Conference on Consumer Electronics (GCCE), Tokyo, 2013, pp. 320- 323. [3] Ants AI Challenge. – URL: http://ants.aichallenge.org. [4] Russian AI Cup – artificial intelligence programming contest. – URL: http://russianaicup.ru. [5] Ai Cup – artificial intelligence programming contest. – URL: https://aicups.ru/. [6] Tim Jones, М. AI Application Programming. М.: DMK Press, 2018. – 312 p.