K ui L ei X i: a C hinese Open-Ended Text Adventure Game (2021)

Abstract: There is a long history of research related to automated story generation, dating back as far as the 1970s. Recently, the rapid development of pre-trained language models has spurred great progresses in this field. Equipped with GPT-2 and the latest GPT-3, AI Dungeon has been seen as a famous example of the powerful text generation capabilities of large-scale pre-trained language models, and a possibility for future games. However, as a game, AI Dungeon lacks incentives to players and relies entirely on players to explore on their own. This makes players’ enthusiasm decline rapidly. In this paper, we present an open-ended text adventure game in Chinese, named as KuiLeiXi . In KuiLeiXi , players need to interact with the AI until the pre-determined plot goals are reached. By introducing the plot goals, players have a stronger incentive to explore ways to reach plot goals, while the AI’s abilities are not abused to generate harmful contents. This limited freedom allows this game to be integrated as a part of a romance simulation mobile game, Yu Jian Love . Since KuiLeiXi was launched, it has received a lot of positive feedbacks from more than 100,000 players. A demo video is available at https://youtu.be/DyYZhxMRrkk .

## introduction the past few years have seen a significant improvement in the capabilities of neural networks for text generation @xcite @xcite . large-scale pre-trained language models with tens of billions of parameters are capable of producing human-like text. this capability has spawned a range of revolutionary applications @xcite @xcite . ai dungeon is a typical example of them. it is an open-ended text adventure game, where players are allowed to create their own adventures in any way they like. the original ai dungeon is based on gpt-2 large, fintuned on a dataset of text adventures collected online foot_0 . since the launch of its colab version, ai dungeon has gained a lot of attention on social networks. however, from the point of view of game developers, ai dungeon suffers from several problems, hindering it from becoming mainstream gaming. the first problem is that it relies entirely on players to explore on their own. the lack of incentives may lead to a rapid decline of players' enthusiasm. the second problem is the boundaryless nature of generated contents. every game is associated with a certain series of world settings where the stories take place. to integrate ai dungeon-like technology in a game, considerable adaptation works are necessary. on the other hand, in the absence of necessary guidance and restraints, players tend to abuse ai dungeon to create malicious or offensive contents foot_1 . in areas with more conservative values, it is of high risk to launch an ai dungeon-like feature in a commercial product. considering the problems described above, we extended the original ai dungeon so that it could be accommodated in a commercial game. when playing ai dungeon, depending on the player's choice of different topics, the ai will generate a story beginning, and then the player is free to explore the development of the story. unlike ai dungeon, in our game, players need to play a fixed character of their choice and interact with the ai to develop the story according to the pre-defined story background until they reach the specified plot goal to obtain the mission rewards. multiple plot goals are contained in a story script. by elaborately design the plot goals, the difficulty of game and the freedom of players to create could be manipulated. the game supports multiplayer, scripts are created both by the game developers and by the players themselves. because in the gaming process, the player seems to be maninulating the puppet of the character, we figuratively call this game kuileixi, which refers to the puppetry in the song dynasty. deploying a neural text generation model for many players is quite expensive. so we adopted a range of methods to reduce the cost, including layer drop and knowledge distillation. in addition, we implemented a highly optimized transformer in cuda for inference. after applying these methods, the inference speed of the model is increased by 10 times, the throughput is increased by 20 times, greatly reducing the deployment cost. kuileixi has been launched as a part of yu jian love. yu jian love is a mobile romance simulation game where players can role play as a girl that lives in the era of northern song dynasty and develop romantic relationship with different handsome male characters. since launched, it received a lot of positive feedbacks from players and industry. we hope kuileixi could inspire fellow game developers and nlp researchers to bring more nlp capabilities into games and make game content more dynamic and personalized. ## architecture in this section, we will describe the implementation and optimization of kuileixi in detail. as seen in figure 1 , the system consists of three components: input processor, story generator and candidates ranker. as both the story generator and candidates ranker are based on our inhouse pre-trained language model, we will firstly describe the pre-training details. then we will present the implementation details of the three components in order. finally, we will introduce the optimization details for deployment. ## demonstration in this section, we demonstrate how to play kuileixi. first, we demonstrate how to start a game. after entering the game, if there is no ready game for joining, you can click the create stage button to start a new game. you then need to pick a story script from the candidates, as demonstrated in figure 3a . the scripts are both created by game developers and players. scripts submitted by players will be voted by all players and the winners become playable. after picking the script, you need to choose the character you want to play, as demonstrated in figure 3b . the playable characters in each script are different. wait for other players joining your game until the number of players exceeds the minimum player limit. then you could either start the game or wait for other players joining as additional characters or audience. after the game starts, all players can see the story background as well as the first plot goal. players will play in order. the order is randomly decided at the start of the game and does not change during the game. when it is your turn to play, you can choose to write a dialogue with your character or describe a narration. figure 4a shows the situation at the beginning of the game. overall, you need to consider the development of the current story, the persona of the character you play and the plot goal. after completing the input, the ai will generate the corresponding story to unfold based on the input, so on and so forth until the current plot goal is reached. once the current plot goal is reached, the ai will show a pre-written storyline, as well as a new plot goal, as seen in the figure 5a . usually a script has multiple plot goals. when the final plot goal is reached, players win and are rewarded with game props. the whole process of playing will be saved in the database, and players can share it with their friends or make it public on social networks. ## conclusion in this paper, we demonstrate kuileixi, an openended text adventure game in chinese. in order for it to be released as part of a commercial game, we have made many innovations based on ai dungeon. we believe that the current advances in nlp technology can not only reduce the cost of game content development to a certain extent, but also make the game world more dynamic and personalized. we hope our work will be of interest to fellow game developers and nlp researchers. in future work, we will further explore the generation of game quests and ambient dialogues with up-to-date nlp techniques.