Mass Game Simulator: An Entertainment Application of Multiagent Control

This paper proposes and develops a simulator of multiagent mass games in which agents achieve formations displaying given grayscale images via distributed control. One potential application of mass games is entertainment for ordinary users. However, it is difficult for nonexpert users to understand the existing control methods for mass games, and the implementation requires considerable time and effort. The proposed mass game simulator developed to overcome these difficulties is provided as a MATLAB application. With this simulator, we can import a reference image, simulate a mass game for the reference image, confirm the simulation result, and save the result through simple mouse and keyboard inputs without the need for expert knowledge or programming effort. In addition, the application of the proposed simulator to entertainment and digital signage is discussed and evaluated. In particular, in the latter application, by playing an animation of the simulation results obtained using the simulator on digital signage, we can construct a novel type of signage whose contents are shown by the motion of individual dots corresponding to agents. These results indicate that control of multiagent systems can be used for nonengineering applications, which have not been considered in most existing studies.


I. INTRODUCTION A. MOTIVATION AND CONTRIBUTIONS
In the systems and control field, there has been considerable interest in the control of multiagent systems to allow multiple agents interconnected through a network to achieve a global objective using only local information.
The interest in multiagent systems is motivated by the swarm behavior of living things. For example, a flock of birds and a school of fish travel as groups by observing their neighbors for defense against predators and the protection of their territory [1]. Another motivation for studying multiagent systems is the variety of potential engineering applications, e.g., formation flying of aerial vehicles [2], [3], sensor networks [4], [5], and smart grids [6], [7]. Moreover, in recent years, the Internet of things (IoT), i.e., the growing set of devices connected to the Internet, has garnered considerable The associate editor coordinating the review of this manuscript and approving it for publication was Choon Ki Ahn . attention [8]. This scenario is also an application example of multiagent systems, where the devices correspond to agents.
In addition to such engineering applications, multiagent systems have the following potential advantages. First, the systems can perform tasks that cannot be achieved by single-agent systems. Examples include environmental monitoring [9] and cooperative transportation [10] using multiple agents, state estimation via data fusion [11], [12], and distributed optimization over networks [13]. Second, multiagent systems are robust against failures. Even if the performance of some agents degrades due to failures, the entire system can continue to operate [14].
In this work, we focus on formation control in multiagent systems to enable agents to achieve a desired formation in a distributed manner. Specifically, the problem considered here is to find distributed controllers for conducting mass games in which agents achieve formations displaying given grayscale images, as illustrated in Fig. 1. One potential application of mass games is entertainment, where we can observe agent formations displaying objects shown in pictures. Such an VOLUME 9, 2021 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ application is not considered in most existing studies on multiagent systems because these studies have been motivated by biological interest and engineering applications, as explained above. In addition, the behavior of agents in constructing formations with interesting appearances can attract the attention of ordinary users to multiagent control and can enhance their motivation in learning its theory. The mass game problem was originally proposed by Azuma et al. [15] (including the first author). They developed distributed controllers for conducting mass games by combining coverage control 1 [16] and halftone image processing 2 [17]. Subsequently, in [18], the authors considered an additional mass game problem in which there is a variable number of agents participating in the mass game, and they extended the controllers developed in [15] to this problem. However, the extension of mass games to entertainment applications for ordinary users faces two major problems. First, it is difficult for nonexpert users to understand the theory of mass games developed in [15], [18]. As mentioned above, the central idea underlying mass game controllers is the combination of coverage control and halftone image processing, i.e., techniques used in the fields of control theory and image processing, respectively. Few nonexpert users will be familiar with both of these distinct fields. Second, the implementation of the algorithm for simulating a mass game requires considerable time and effort. For example, it requires the computation of an integral of a function over a region, with the function and region being specified by the given grayscale image and the current configuration of agents, respectively. However, typical programming languages are not equipped with dedicated functions for such computation; thus, the computation must be implemented by each user.
Given these problems, this work was conducted to develop a mass game simulator (MGS), i.e., an application allowing nonexpert users to easily simulate a mass game without the 1 A distributed control technique used to place agents so that their density distribution becomes the desired one. 2 An image processing technique used to transform grayscale images into binary images while retaining as much of the visual quality of the original image as possible. In this process, the degree of gray coloring is expressed by the density distribution of black pixels. need for expert knowledge or programming effort. Our main contributions are summarized as follows.
(i) Based on the control method given in [15], we develop the MGS as a MATLAB application. The MGS can be used to simply simulate a mass game by means of mouse and keyboard operations. In addition to this basic functionality, we introduce a zoom function to confirm the detailed behavior of agents and a save function to save the simulation results as image and movie files. The former aids users in understanding the idea underlying the mass game controllers, and the latter broadens the application range of the MGS, as demonstrated later in this paper. (ii) We present two application examples of the MGS: an entertainment application for ordinary users and a digital signage application. In the former application, users can not only see the behavior of agents in constructing formations with interesting appearances but also know how to control the agents. In the latter application, by applying an animation of the simulation results obtained using the MGS to digital signage, we can construct a novel type of signage whose contents are shown by the motion of individual dots corresponding to agents. This approach is illustrated through an example of digital signage placed at the entrance of a room.
These results indicate that the control of multiagent systems is applicable to nonengineering fields, which have not been considered in most existing studies. (iii) In the digital signage application, we evaluate the quality of the contents displayed in the signage via comparison with an existing method [28] for the formation control of multiagent systems. The results demonstrate that the displayed contents generated by the MGS are better than those generated by the existing method in terms of both visual quality and time spent producing the desired formation. One may think that this paper simply implements the control method proposed in [15], but the choice of the algorithm to implement is important in the development of simulators. The results indicate that our choice is suitable for the digital signage application.

B. RELATED WORK
To stress the novelty of this paper, we discuss the differences between this work and related work from the perspective of theory (i.e., control methods of agents) and simulators. A summary of the following discussion is given in Table 1. Many researchers have studied the formation control of multiagent systems. For example, Sugihara and Suzuki [19] proposed heuristic distributed algorithms for forming geometric patterns, and Suzuki and Yamashita [20] characterized the class of achievable patterns in a theoretical manner. Fax and Murray [21] analyzed the stability of the formation dynamics of agents using graph theory and proposed a method for information exchange among agents. Ren and Sorensen [22] developed a distributed formation control method based on a combination of a leader-follower approach and a consensus algorithm. Montijano et al. [23] proposed a vision-based formation control method for agents in three-dimensional space under the assumption that there is no external positioning system to globally localize the agents. Yang et al. [24] proposed a control method to achieve V-shaped formations inspired by the flocking behavior of flying geese. Wang et al. [25] and Liu et al. [26] addressed robust formation control problems for multiagent systems subject to external disturbances. However, the control methods proposed in these works are not applicable to the mass game problem because these works focused primarily on simple formations specified by lines, e.g., circles, polygons, and V-shapes, and did not consider formations displaying grayscale images.
Concepts similar to mass games are discussed in [27], [28]. Alonso-Mora et al. [27] proposed a display in which mobile robots with controllable colors can be regarded as individual pixels and images and animations are shown via the positioning and motion of the robots. Wang and Rubenstein [28] developed a distributed control method to achieve formations that display letters and shapes given as images. However, it is difficult to apply the control methods proposed in these works to the mass game problem because the methods apply to either binary images or images with only a few colors, whereas it is necessary to represent the grayscale information (i.e., various degrees of gray coloring) of images in the mass game problem. This difference is manifest in the digital signage application in Section IV-B.
Meanwhile, various simulators have been developed. A typical example is vehicle driving simulators [29], [30]. Another example is robot simulators for a single robot [31] and multiple robots [32]- [35]. There are also simulators of satellite attitude dynamics [36], tourist urban routes [37], stand-alone photovoltaic systems [38], and real-time pricing in smart grids [39]. However, these simulators cannot replace our MGS because the MGS handles not only the control method for mass games but also images and animations, whereas the existing simulators do not.

C. NOTATION
The following notation is used throughout this paper. Let R and R + be the real number field and the set of positive real numbers, respectively. For the vectors x 1 , x 2 , . . . , x n ∈ R 2 and the set I : The cardinality of the set S is expressed as |S|. Next, consider the convex set Q ⊂ R 2 and the distinct vectors where · denotes the Euclidean norm of a vector. In addition, we use G(x) to represent the Delaunay graph for x 1 , x 2 , . . . , x n ; that is, G(x) is the undirected graph comprising the node and edge sets {1, 2, . . . , n} and

II. MULTIAGENT MASS GAMES
Before presenting the proposed MGS, we briefly summarize the existing results [15] on mass games.
A. MASS GAME PROBLEM Consider the multiagent system in two-dimensional space depicted in Fig. 2. The system comprises n agents and the local controllers implemented in them.
The model of agent i (i ∈ {1, 2, . . . , n}) is given bẏ where x i (t) ∈ R 2 and u i (t) ∈ R 2 denote the position and control input of agent i, respectively. This is a model of an omnidirectional mobile robot. We suppose that each agent operates in a distributed manner based on local information. The information available to each agent is specified as follows. Let x(t) ∈ R 2n be the positions of all agents, i.e., Assuming that for every t ∈ R + ∪ {0}, all agents exist in a given bounded convex set Q ⊂ R 2 , as shown in Fig. 2, we can represent the Voronoi cell for x i (t) (i ∈ {1, 2, . . . , n}) and the corresponding Delaunay graph by V i (x(t)) and G(x(t)), respectively. Using this notation, we assume that for every t ∈ R + ∪ {0}, each agent i can obtain information on (i) its own position x i (t) and (ii) the positions of the neighboring agents on the Delaunay graph G(x(t)).
The local controller for agent i is then described by where the controller structure, and N i (t) ⊂ {1, 2, . . . , n} is the index set of the neighboring agents on the Delaunay graph G(x(t)). This local controller is distributed in the sense that its inputs are restricted to the information described in (i) and (ii) above.
Notably, the subscript i is not attached to the function f ; this leads to the constraint that all local controllers must be common, which ensures the scalability of the overall system. For the multiagent system , we suppose that a reference grayscale image, which is displayed as a formation of the agents, as illustrated in Fig. 1, is given as the function ϕ : Q → [0, 1]. The function ϕ assigns the respective pixel values of the image to individual points q within the set Q introduced above, where we note that Q is the area used to produce the formation displaying the image. More precisely, ϕ(q) = 1, ϕ(q) = 0, or ϕ(q) ∈ (0, 1) indicate that the pixel at point q is white, black, or gray, respectively. By means of this notation, the mass game problem addressed in [15] can be defined as follows.
Problem 1: For the multiagent system , suppose that a reference grayscale image ϕ is given. Then, find distributed controllers (i.e., a common function f ) such that for every initial formation x(0) ∈ Q n , the final formation x(∞) displays the image ϕ, as illustrated in Fig. 1.
We make two remarks regarding Problem 1. First, it might be assumed that this problem can easily be solved by calculating the desired positions of all agents based on the reference image and then assigning each desired position to a corresponding local controller, but this is not true. In fact, it is impossible to satisfy the constraint that all local controllers are common because different information is given for each local controller. Second, the specification to be satisfied in Problem 1 is based on the visual quality of the agent formation. A typical approach for multiagent control is to describe specifications using mathematical functions and then design local controllers to optimize these functions (see, e.g., [1]). However, since the visual quality of the agent formation depends on human perception and gaps exist between the true and perceived feelings of humans [40], quantifying the specification with a mathematical function is generally difficult. These two facts make the problem challenging.

B. DISTRIBUTED CONTROLLERS FOR MASS GAMES
The idea proposed in [15] to solve Problem 1 involves representing the reference (grayscale) image as a density distribution of the agents. Specifically, we regard each agent as a black pixel and place more agents at locations within the space Q corresponding to the darker parts of the reference image. This idea is inspired by halftone image processing (see footnote 2 in Section I-A); thus, the grayscale information of the reference image is represented.
Based on this idea, Azuma et al. [15] proposed the following solution to Problem 1: where k ∈ R + is the controller gain and c(V i (x(t))) ∈ Q is the weighted centroid of the Voronoi cell V i (x(t)), i.e., In (5), φ : Q → R + ∪ {0} is the weighting function defined as where κ ∈ R + is a parameter determining the contrast of the image of the resulting formation. The local controller given by (3)- (5), which is called the coverage controller [16], enables the placement of more agents at locations within space Q with higher values of the weighting function φ. Furthermore, according to the definition of ϕ, φ(q) in (6) takes higher values at points q corresponding to the darker parts of the reference image. Therefore, the local controllers given by (3)-(6) steer the agents such that more agents are placed at locations within Q corresponding to the darker parts of the reference image. This process yields a density distribution of agents that reflects the grayscale information of the reference image. The abovementioned mass game controllers are illustrated through an example. Consider the multiagent system with n := 3000 and Q := [0, 100] 2 . The reference image ϕ shown in Fig. 3(a) is given in [41] as one of the standard images in the image processing field. This is an eight-bit grayscale image, i.e., ϕ(q) ∈ {0, 1/255, 2/255, . . . , 1}. We apply the local controllers constructed by (3)-(6), where k := 0.5 and κ := 10. Figs. 3(b)-(d) show the time series of the resulting formation, where the black dots indicate agents and the initial formation (i.e., Fig. 3(b)) is randomly chosen based on a uniform probability distribution on Q n . The formation converges to that displaying the reference image over time. Moreover, in the final formation shown in Fig. 3(d), the grayscale information of the reference image is represented by the spatial variations in the agent density.
Remark 1: The local controller given by (3)-(6) can be intuitively explained as follows. On the basis of (2)-(4), the local controller steers agent i to the weighted centroid c(V i (x(t))) of the Voronoi cell V i (x(t)). The weighted centroid c(V i (x(t))) is a location within V i (x(t)) specified as a darker point of the corresponding part of the reference image according to the definition of ϕ, (5), and (6). Thus, the local controller steers agent i to that location.
Remark 2: Although the positions [x j (t)] j∈N i (t) of neighboring agents do not appear directly on the right-hand side of (4), the local controllers given by (3)-(6) are distributed. This is because the weighted centroid c(V i (x(t))) (i.e., the Voronoi cell V i (x(t))) can be calculated based on only the positions of agent i and its neighbors on the Delaunay graph G(x(t)) [16].

C. ISSUES TO BE ADDRESSED
As explained in Section I-A, one potential application of mass games is entertainment, but the following issues must be resolved to facilitate such an application. First, it is difficult for nonexpert users to understand the abovementioned theory of mass games. Understanding mass game theory requires knowledge of, for example, halftone image processing, coverage control, Voronoi cells, and Delaunay graphs. However, this knowledge comes from distinct fieldsspecifically, image processing, control theory, and computational geometry-thus, relatively few nonexpert users will be familiar with all of the required knowledge. Second, the implementation of the abovementioned method takes considerable time and effort. For instance, for (4)-(6), it is necessary to compute the weighted centroid c(V i (x(t))) of the Voronoi cell V i (x(t)) for the weighting function φ determined by the reference image ϕ. However, as conventional programming languages such as MATLAB are not equipped with dedicated functions to compute the integral of a given function over a Voronoi cell, this calculation must be implemented by each user.

III. DEVELOPMENT OF MGS
To overcome these issues, we developed the MGS that allows the simulation of mass games without the need for expert knowledge or programming effort. This section introduces the MGS.

A. MGS
An overview of the MGS is shown in Fig. 4. The MGS was developed using the MATLAB App Designer, i.e., a development environment in MATLAB used to create applications, which can be downloaded as a MATLAB application installer from the website [42]. Running the MGS requires MATLAB version R2019a or later and no toolboxes.

Remark 3:
We can generalize the initial formation setting by allowing users to determine the initial position of each agent. However, such a generalization substantially increases the effort required by users because the number n of agents is at least 1000. Hence, to reduce user effort, we simplified the settings in the Initial Formation menu as ''Random'' and ''Same as before.'' Remark 4: Although the MGS assumes square reference images, the method described in Section II can be applied to rectangular reference images because they satisfy the condition that the space Q corresponding to the reference image is a convex set. The assumption of square reference images is imposed to simplify the development of the MGS and to increase its reliability. In fact, there are various sizes of rectangular images depending on their aspect ratio, which makes the implementation of the Reference Image, Formation, and Zoom windows difficult and causes bugs.

B. USAGE
The usage of the MGS is explained as follows, in which (a)-(o) correspond to the labels in Fig. 4.
Step 1 Import a file of the reference image using the Load Image button (b). The imported image is shown in the Reference Image window (j).
Step 2 If necessary, move the area displayed in the Reference Image window (j) using the Displayed Area spinners (m) so that the desired reference image is shown in the window.
Step 3 Set the number n of agents, the gain k, and parameter κ using spinners (e)-(g).
Step 4 Set the initial formation x(0) using the Initial Formation menu (h), in which ''Same as before'' is available only after the mass game has been simulated at least once.
Step 5 Click the Simulation button (c) to begin the mass game simulation. The progress of the simulation is shown on the Simulation/Animation Progress bar (o). Once the simulation is complete, go to Step 6.
Step 6 If necessary, turn the Zoom switch (i) ''On'' (see item (i) in Section III-A for the details of the Zoom switch).
Step 7 The Time slider (n) can be moved to display the resulting formation at the specified time in the Formation window (k).
Step 8 By clicking the Animation button (d), an animation of the simulation result is shown in the Formation window (k). The progress of the animation is shown on the Simulation/Animation Progress bar (o). No operation should be performed until the animation ends.
Step 9 If necessary, the simulation result can be saved as an image and/or movie file using the Save menu (a) (see item (a) in Section III-A for details on saving files). The following points regarding the use of the MGS should be noted. First, we can select a color image in Step 1 even though the method described in Section II assumes grayscale reference images. When a color image is selected in Step 1, it is automatically converted into its grayscale version. Second, Step 1 can be skipped when performing a simulation for a previously used reference image (or its variations obtained using the Displayed Area spinners) and different values of n, k, and κ.

C. ILLUSTRATIVE EXAMPLE
An illustrative example of the MGS in operation is provided in Fig. 5, where n := 2500, k := 1.5, κ := 15, and the steps correspond to those in Section III-B. Using MGS, we can simulate the mass game for a selected reference image, confirm the simulation result, and save it by means of simple mouse and keyboard operations (see also a demonstration video of the MGS provided as supplementary material). In addition, examples for changing the simulation settings using the Number of Agents and Contrast Parameter spinners are provided in Fig. 6, in which (a) and (b) correspond to cases of increasing n and κ, respectively. Compared to Fig. 5(d), the image of the resulting formation in Fig. 6(a) is darker and that in Fig. 6(b) has higher contrast. These results demonstrate that the spinners allow us to change the simulation settings.
Remark 5: While the MGS is provided as a MATLAB application, it is possible to develop a similar application using another programming language if it can handle not only numerical computations but also images and animations, as seen in this subsection.

IV. APPLICATIONS
This section presents two application examples of the MGS. These applications have not been discussed in most existing studies on multiagent control.

A. ENTERTAINMENT
We start by introducing an example of a method in which beginners can use the MGS for entertainment. As a first step, based on the usage explained in Section III-B, we run the VOLUME 9, 2021 MGS once with the Zoom switch set to ''Off.'' Then, by turning the Zoom switch ''On'' and inspecting the Zoom window, we can confirm that the agents move to darker areas of the window, i.e., the locations with higher values of the weighting function φ, as shown in Fig. 7. This exercise is helpful in understanding the underlying idea of mass game controllers that is described in Section II-B. This process also helps us to focus not only on the appearance of the formation but also on how to control the agents. Introducing the Zoom switch and window provides these advantages. Subsequently, we can create our own formations by changing the reference image and the simulation settings (i.e., the values of n, k, and κ). For example, by tuning n and κ, we can create an optimal formation in terms of subjective visual quality for a specific reference image.

B. DIGITAL SIGNAGE
Digital signage, which provides information using display devices, has been widely used in recent years. It can be found in, for example, transportation systems, stadiums, and corporate buildings. Here, we consider the application of the MGS to digital signage. Specifically, we create an animation of the mass game using the MGS and play it on digital signage. By choosing a reference image containing appropriate information, we can construct a novel type of signage where the information is represented by the motion of individual dots corresponding to agents.
As an example, we created an animation for the application to digital signage placed at the entrance of the authors' room (room number 2517). We performed simulations for two reference images based on another standard image using MGS, as shown in Fig. 8, where n := 2500, k := 1, κ := 10, and ''Same as before'' was chosen from the Initial Formation menu in Fig. 8(b) to combine the resulting two animations. Fig. 9 shows a photo of playing the combination of the resulting two animations on digital signage using a DSM-32L7X display (MITSUBISHI ELECTRIC Corporation). Fig. 10 shows snapshots of the displayed contents, in which the first animation was switched to the second animation at approximately t = 10 s. As the dots move, the displayed contents change smoothly as a random formation  → a woman → both a woman and the room number. The corresponding video is provided as supplementary material. The introduction of the Save menu and the Initial Formation menu allows such an application.
We then evaluated the quality of the displayed contents via comparison with an existing method [28] for the formation control of multiagent systems. We created an animation of a simulation result by applying the existing method to the reference image in Fig. 8(b). Here, to apply the existing method, the reference (grayscale) image was binarized using a threshold, and the desired positions of the respective agents were set as the locations of the individual black pixels in the resulting binary image. The threshold of the binarization was FIGURE 11. Snapshots of the displayed contents produced by an existing method [28] (the brightness of the images has been adjusted to improve their visibility). set such that the number of black pixels in the resulting binary image was approximately 2500, i.e., the number of agents in the preceding example; as a result, n := 2891 was obtained. We ran the resulting animation on digital signage in a manner similar to that in the preceding example; snapshots of the displayed contents are shown in Fig. 11. Compared to Fig. 10, it is difficult to obtain the information on the reference image (in particular, the left half) from the formation because the grayscale information of the reference image is lost as a result of the binarization. In contrast, the method we employ (i.e., the method described in Section II) represents the grayscale information as a density distribution of agents without binarization, thereby producing a formation whose appearance is closer to the reference image. Furthermore, the time spent producing the desired formation is longer than that for Fig. 10 because the method proposed in [28] randomly assigns each desired position to a corresponding agent at the beginning of the process without taking the distances between the agent positions and the desired positions into account, whereas the method we employ steers each agent to a favorable position close to the current position in a distributed manner.

V. CONCLUSION
In this work, we proposed and developed a simulator of multiagent mass games for practical use. The proposed simulator can be operated through simple mouse and keyboard inputs without the need for expert knowledge or programming effort. The simulator also includes zoom and save functions to extend its application range. Using these functions, we applied the proposed simulator to entertainment and digital signage. In the digital signage application, we demonstrated that the displayed contents generated by the proposed simulator are better than those generated by an existing method in terms of both visual quality and time spent producing the desired formation. The results presented in this paper will lead to new applications of the control of multiagent systems.
Several directions for future research exist. One example is to make the proposed simulator available to non-MATLAB users. Another example is to incorporate the framework of another type of mass game, given in [18], into the proposed simulator. We also plan to develop other applications for the proposed simulator.