{'fraction_non_alphanumeric': 0.031719287964251705, 'fraction_numerical': 0.016628818401582302, 'mean_word_length': 4.8516930990141445, 'pattern_counts': {'":': 0, '<': 0, '<?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}}
MCS: An In-battle Commentary System for MOBA Games

This paper introduces a generative system for in-battle real-time commentary in mobile MOBA games. Event commentary is important for battles in MOBA games, which is applicable to a wide range of scenarios like live streaming, e-sports commentary and combat information analysis. The system takes real-time match statistics and events as input, and an effective transform method is designed to convert match statistics and utterances into consistent encoding space. This paper presents the general framework and implementation details of the proposed system, and provides experimental results on large-scale real-world match data.


Introduction
In recent years, MOBA (Multiplayer Online Battle Arena) games have been popular all over the world. As a popular mobile MOBA game, Honor of Kings has a DAU of over 100 million, and has become an official sport in the 2022 Hangzhou Asian Games. In MOBA games, several players are divided into two teams and carry out a battle against each other. AI reseach in MOBA games has received many attention (Ye et al., 2020(Ye et al., , 2022. Real-time commentary plays an important role in live streaming of e-sports competitions, assists the audience in the comprehension of game situation and events, expanding the presence of MOBA games. In-battle commentary aims at generating coherent and informative natural language descriptions based on game situation, match statistics and player behaviour, as illustrated in Figure 1. Similar systems have already been widely applied in realworld applications such as automated news broadcast, television sports commentary, online video description, etc (Chen and Mooney, 2008;Wiseman et al., 2017;Nie et al., 2018;Puduppully et al., 2019;Kale and Rastogi, 2020). In this paper, we focus on the scenario of live e-sports commentary  in mobile MOBA games and introduce MCS: an in-battle commentary generation system 12 .
Automatic commentary is grounded in in-battle match statistics and events, regarded as a data-totext generation task. Recently, many large-scale language models have been proposed and promoted the advance in natural language generation (Radford et al., 2018;Devlin et al., 2019;Radford et al., 2019). These pre-trained language models are also beneficial for data-to-text tasks (Kale and Rastogi, 2020), in this work, we employ OpenAI's GPT-2 model as the basic generator, and build a neural pipelined approach for commentary generation.
Although recent works have shown promising results regarding live comment generation (Chen and Mooney, 2008;Wiseman et al., 2017;Novikova et al., 2017;Dušek et al., 2018;Ma et al., 2019;, there are still many challenges for constructing a commentary generation model for MOBA games: (1) Previous studies incorporated static data like final scores, while live e-sports commentary uses changing match statistics as the game goes on. Current statistics as well as history statistics are both vital for text generation. For example, the narrowing of advantages may cause anxiety, while overturn from deficit can be  a morale booster. Therefore, the problem of commentary generation employing dynamic structured data needs to be tackled.
(2) Neural network based text generators are claimed to be unreliable in the consistency and accuracy of generated texts. However, commentary generation is highly correlated with in-battle data, which requires high conformity in the generated sentence and input data. In many approaches, retrieval methods are used instead of generative methods. How to solve the problem of generative methods and improve reliability remains challenging.
The proposed MCS has the following advantages: (1) We apply GPT-2 model into data-to-text task, and design a hero selection loss to focus on the target hero behaviour for commentary.
(2) Previous studies on sports commentary generation incorporated only static data like final scores, while the proposed MCS uses dynamic match statistics during generation, as current and history statistics are both vital for e-sports commentary. (3) Commentary is highly correlated with in-battle data, which requires high conformity in the generated sentence and input data. A restricted token decoding method is employed to improve generation reliability.

System Framework
We first introduce the general framework of the proposed MCS system. The system consists of three modules in a pipeline, as presented in Figure 2. Taking in-battle statistics as input, the system produces a descriptive sentence based on current and history data.

Initial commentary generation
The first module focuses on generating initial texts: in this stage, several candidate sentences are gen-  erated in an end-to-end manner, used as inputs for further polishing. All statistics of the ten heros as well as critical events are included in network input. The critical event is defined by a triplet including event type, active hero, and passive hero. For instance, single killing is a typical event that occurs frequently in MOBA games, in which the active hero is the hero kills someone, and the passive hero is the killed one. Figure 3 shows two examples of events. Beside all hero statistics, critical events are also included in network input as most commentaries focus on the heros involved in these events.

Restricted token decoding
The second module performs restricted decoding based on the initial text generator. Restricted generation can increase the reliability of neural lan-equips kills, deaths, assists, golds (a) Data panel in game.   guage generation (Elder et al., 2020;Dathathri et al., 2020). Inspired by retrieval text generation, we construct event-specific corpus from the collected dataset, which is used in the token decoding process. With this approach employed, the generated sentences are expected to be controlled within a reasonable range around the corresponding event.

Fine-grained ranking
The final module conducts fine-grained ranking on sentences generated through the previous two modules. A pairwise scoring model is constructed following textual matching methods, to avoid topic shift and destruction of text fluency, the scoring model is trained against topic irrelevant commentaries and faulty sentences. After ranking, the commentary achieving the highest score serves as final output of the MCS system.

System Implementation
In this section, the implementation details of the proposed three modules are provided. In general, the network architecture are constructed following the pipeline of language models. As described in Figure 4, features are serialized and fed as the inputs, the network predicts a target hero ID and generates a comment as the outputs.

Initial commentary generation
For the initial commentary generator, the network input is composed of critical events and match statistics of the ten heros. A triplet including event type and two hero IDs is used to represent the event, as described in Section 2.1. For match statistics, the data entries used in the proposed MCS includes Hero ID, Kills, Deaths, Assists, etc, as presented in Figure 4. Since the statistics are changing over time and the changes are important in indicating hero status and highlight events, we also include variations of the above data entries in network input. For example, a hero with high kills and gold usually means that it can cause high damage in battle. If the kills of a hero rise rapidly in a short time, it is likely that the hero has outstanding performance and human commentators will comment on it.
To adapt the structured data to a sequential input of the network, we design a method to transform hero attributes into decimal digits. For each hero, a unique identifier is assigned and placed at the beginning of its data sequence, followed by a token indicating whether the hero is alive or not. The other indicators are discretized by dividing into segments, Figure 5 illustrates an example of data serialization. Kills, Deaths, Assists and the variations are encoded by 600 digits, 100 for each, as they are usually less than 100 in a single match. In extreme cases where the indicators exceed 100, the real digits are replaced by 100 to avoid confusion. In a single match, the Gold of each hero usually varies from 0 to 40000, it is discretized by dividing into 20 segments, 2000 golds for one segment. The variation of Gold is encoded in a similar way, each segment represents 90 golds per minute, and the maximum variation is set to 4500 golds per minute.
At the end of the sequence, we use two extra tokens to represent the ranking of Gold and KDA of the correspoding hero among all 10 heros. The data sequence of all 10 heros are connected by a special token "[SEP]", and another special token "[EOD]" is added after the last data block to separate text from data sequence.
In general, the network architecture is illustrated in Figure 6. Previous studies have proven that pretrained language models can improve data-to-text generation (Peng et al., 2020;Kale and Rastogi, 2020), we use Open-AI's GPT-2 model to build the basic text generator. The GPT-2 model used in this work was pre-trained using Chinese copora LCCC (Large-scale Cleaned Chinese Conversation . In addition to standard language model loss, we design a hero selection loss to focus on the match data of the target hero, which is helpful to increase generation consistency.

Restricted token decoding
In this stage, the collected dataset is divided into event-specific groups by a triplet retrieval key. The retrieval key is composed of event type, active hero ID, and passive hero ID. During generation, the triplet retrieval key can be extracted from in-battle statistics, and the corresponding event-specific corpus can be retrieved. In retrieval text generation approaches, a selection strategy is designed to choose a proper sentence from the corpus as the final result. In the proposed MCS system, we employ the eventspecific corpus to restrict the sentences generated by neural networks.
The Plug and Play Language Model (PPLM) (Dathathri et al., 2020) module is employed to control the token decoding process, restricting the generated texts around the corresponding event. Basically, the restriction is accomplished by updating the last hidden layer features h t : where |corpus| represents the size of a eventspecific corpus and w i denotes a word in the corpus. After a few iterations of updating, the hidden features are softly adjusted towards decoding the words in the event-specific corpus.

Fine-grained ranking
The final stage performs a ranking on the generated candidate sentences. We build a pairwise ranking network on top of the GPT-2 generator. Taking two sentences as input, the GPT-2 outputs two encoding vectors respectively. These encodings are then fed into the ranking network, and a score is derived which indicates the relative order of the two sentences. After all candidate sentences are processed, the best sentence is regarded as the final commentary.

Materials and Results
The structured data and commentary history of 30 million matches in professional leagues and live broadcasts of Honor of Kings were collected and used to train and evaluate the proposed system. Perplexity is used to evaluate the fluency of generated sentences, ROUGE-1, ROUGE-2 and ROUGE-L are used to measure the distance between generated sentences and ground truth. We also calculate the generation validity by human evaluation. The experimental results are presented in Table 1. Quantitatively, the system achieves an averaged perplexity of 1.27. Comparing the generated sentences with those written by human commentators among the collected data, the ROUGE-1, ROUGE-2 and ROUGE-L scores are 0.1921, 0.0111 and 0.1903 for the initial commentary generation, respectively. Combined with target hero prediction and restricted token decoding, the metrics improved to 0.2025, 0.0140 and 0.2001. The final ROUGE scores are 0.2028, 0.0144 and 0.2006 employing fine-grained ranking. Besides statistical indicators, we also carried out human evaluation of the system, and the generated commentaries achieve a validity of 0.91. This means that the system has the potential to be used in real-world applications. Our system is compared with two mainstream generation approaches: the RNN-based Seq2Seq (Sutskever et al., 2014) and the transformer-based standard GPT-2 (Radford et al., 2019), and outperforms both of them.  Figure 6: Architecture of the generation network. The network is based on GPT-2 model. The beginning of network outputs accomplish target hero selection, the remaining represents the generated tokens. "Event" denotes the triplet of critical event, "R1" -"R5" represents the data of the 5 heros on the red side, "B1" -"B5" represents the data of the 5 heros on the blue side. Figure 7 shows two cases of the generated commentaries.

Commentary: 这个大可惜呀。
The ULT misses, what a great pity! (a) The ULT of Ganjiang Moye misses, a few moments later, he is killed by Mozi.

Commentary: 这是真的太细节。
The player's control is full of precise details.

Conclusion
We propose MCS, a model for in-battle real-time commentary generation in MOBA games. MO-BA is a type of games popular all over the world, commentary plays an important role in game comprehension for audience. The proposed MCS is designed with the ability of analyzing real-time match statistics and generating coherent descriptive contents. It has a wide range of applications such as e-sports commentary, combat information analysis, etc, and has the potential to promote game development and improve match environment.