Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 12, No. 2, 2024 37 Research on the Development of Intelligent Game Dialogue System and Game Experience Based on ChatGPT Weitao Li Fujian Agriculture and Forestry University, Fuzhou, 350002, China Abstract: This study discusses the development of intelligent game dialogue system based on ChatGPT and its influence on game experience. By integrating ChatGPT technology, a highly intelligent game dialogue system is developed to enhance the interactivity and immersion of the game. User research and experimental data show that the system can significantly enhance the game experience of players, including improving immersion, interactivity and story richness. Compared with the traditional game dialogue system, ChatGPT-based system shows higher flexibility and naturalness, and can dynamically generate responses according to players' input, thus creating personalized and diversified game experiences. The response time is kept at a low level, with an average of about 0.03 seconds, which is far below the player's perceived delay threshold, which ensures the fluency of the conversation and provides the player with a near real-time interactive experience. However, the study also reveals the problems of misunderstanding and inaccurate response that may exist in the system in some cases, which provides a direction for the subsequent system optimization. Overall, this study confirmed the great potential and practical value of the intelligent game dialogue system based on ChatGPT in improving the game experience. Keywords: ChatGPT; Intelligent Game Dialogue System; Game Experience; Interactivity; Immersion. 1. Introduction With the rapid development of science and technology, artificial intelligence technology has been widely used in various fields, and the game industry is no exception. As an important part of game interaction, intelligent dialogue system plays a vital role in improving game experience [1]. The traditional game dialogue system is often based on preset scripts and rules, lacking flexibility and realism, and it is difficult to meet the needs of modern players for high interactivity and immersion. Therefore, how to innovate the game dialogue system to improve the game experience of players has become an urgent problem in the field of game development. In recent years, the breakthrough of natural language processing (NLP) technology provides new possibilities for the development of intelligent game dialogue system. In particular, the emergence of large-scale language models such as ChatGPT, with its powerful language understanding and generation ability, provides strong support for creating a more natural and intelligent game dialogue system. ChatGPT technology can simulate human language habits and generate rich and varied dialogue content, which is expected to greatly enhance the interactivity of the game and the immersion of players [2-3]. The purpose of this study is to explore the development and implementation of intelligent game dialogue system based on ChatGPT technology, and evaluate its influence on game experience through empirical research. By introducing advanced NLP technology into game design, it breaks the limitation of traditional dialogue system and brings more vivid and real game experience to players. This is not only an attempt of technological innovation, but also an important exploration of game interaction. Through this research, we can provide new ideas and methods for the development of intelligent game dialogue system and promote the continuous progress of the game industry. 2. Development of Intelligent Game Dialogue System 2.1. Technical Framework of System Development Figure 1. Technical framework 38 In the system development stage, a technical framework is constructed (Figure 1), which mainly includes the following parts: data preprocessing layer, model training layer, dialogue management layer, game logic interface layer and user interface layer. The data preprocessing layer is responsible for cleaning and formatting a large number of text data used to train ChatGPT model to ensure its quality and applicability. The model training layer uses the cleaned data to train the ChatGPT model, and improves the language understanding and generation ability of the model by adjusting model parameters and optimizing algorithms [4]. Dialogue management layer: manages the dialogue process between players and NPC, including the initiation, response and end of the dialogue. The game logic interface layer realizes the interaction between the dialogue system and the game logic, and ensures that the dialogue can trigger the corresponding game events. The user interface layer is responsible for presenting the dialogue content to the player in an intuitive way and receiving the input from the player. 2.2. Understanding and Generation of Natural Language We mainly rely on ChatGPT model in understanding and generating natural language. The model has been trained by a large number of text data, and has strong language processing ability. When players input dialogues in the game, the ChatGPT model will analyze these inputs and generate corresponding natural language responses [5]. In order to ensure that the generated response is consistent with the game situation, the context modeling is also combined with the current state of the game and the historical behavior of the player. Some code implementations of NLP model API to process and generate natural language responses are as follows: # Player input player_input = "Where can I pick up the task?" # Prepare data requested by API payload = { "text": player_input, # Other possible parameters, such as temperature, length and repeated punishment, are added according to the requirements of the model API. } headers = { 'Content-Type': 'application/json', # If the API requires authentication, add an Authorization header # 'Authorization': 'Bearer YOUR_API_KEY' } # Send request to NLP model API response = requests.post(NLP_MODEL_API_URL, headers=headers, data=json.dumps(payload)) # Processing response if response.status_code == 200: response_data = response.json() generated_text = response_data.get("text", "") # Assume that the API response contains the "text" key as the generated text print(f"Response generated by NLP model: {generated_text}") else: print(f"Request failed, status code: {response.status_code}") print(response.text) First, define the URL of a hypothetical NLP model API (NLP _ model _ API _ URL). Then create a dictionary (payload) containing the player's input, and send a POST request to the NLP model API through the requests library. If the request successfully prints out the response text generated by the model; If it fails, print out the status code and response content for debugging. In order to improve the diversity and authenticity of the dialogue, various strategies are adopted to optimize the output of ChatGPT model. Randomness and diversity factors are introduced to avoid the model always producing the same response [6]. In addition, the output of the model is post- processed to ensure that it meets the grammar and style requirements of the game. 2.3. Integration with Other Parts of the Game When integrating ChatGPT model into other parts of the game, we mainly focus on two aspects: game logic and graphical interface. For game logic, ensure that the response generated by ChatGPT model can trigger the corresponding game events and actions. If a player asks an NPC about a task, the response generated by ChatGPT model may trigger a task- related prompt or event. In the aspect of graphical interface, the output of ChatGPT model is combined with the UI elements of the game to provide an intuitive interactive experience [7-8]. When ChatGPT model generates dialogue, it will display corresponding text bubbles or dialog boxes on the game interface. In addition, a variety of interactive options are provided for players, such as selecting dialogue branches and viewing task logs, so as to enrich the interactivity of the game. The following part of the code shows how to integrate a NLP-based dialogue system into the game engine (Unity): public void StartDialog() { //An event or animation that triggers the start of a conversation. } public void EndDialog() { // An event or animation that triggers the end of a conversation. } public void ReceivePlayerInput(string input) { playerInput = input; StartCoroutine(SendInputToNlpApi()); } private IEnumerator SendInputToNlpApi() { WWWForm form = new WWWForm(); form.AddField("text", playerInput); 39 using (UnityWebRequest webRequest = UnityWebRequest.Post(NlpApiUrl, form)) { yield return webRequest.SendWebRequest(); if (webRequest.result == UnityWebRequest.Result.Success) { string response = webRequest.downloadHandler.text; // Parsing the response of NLP API to obtain the generated dialogue text string dialogText = ParseNlpResponse(response); // Update the game interface or trigger related game logic UpdateGameDialog(dialogText); } else { Debug.LogError("Error: " + webRequest.error); } } } private string ParseNlpResponse(string response) { // Parse JSON or other format data returned by NLP API and extract dialogue text private void UpdateGameDialog(string dialogText) { // Update the dialogue text on the game interface, or trigger related game logic Debug.Log("NPC: " + dialogText); // Add more game logic, such as updating task status, triggering scenarios, etc } } In Unity, you can attach this script to an empty game object, receive the player's input through the UI system of Unity, and then call the ReceivePlayerInput method. When the NLP API returns a response, the UpdateGameDialog method will be called to update the UI or trigger the game logic. 2.4. Technical Challenges and Solutions Some technical challenges have been encountered in the development process. The training and optimization of ChatGPT model need a lot of computing resources. In order to solve this problem, distributed training technology is adopted, and high-performance GPU cluster is used to accelerate the training process [9-10]. It is a difficult problem to ensure that the response generated by ChatGPT model matches the game situation. In order to solve this problem, context modeling technology is introduced, and the output of the model is constrained by combining the state and historical information of the game. In addition, manual review and correction methods are adopted to ensure the quality and accuracy of the response generated by the model. Finally, integration with other parts of the game also brings certain challenges. In order to solve this problem, we worked closely with the game development team to design a suitable interface and data exchange format. At the same time, a lot of testing and debugging work has been done to ensure the stability and compatibility of the system. Through the above development process and technical solutions, an intelligent game dialogue system based on ChatGPT is successfully created, which provides players with a more natural and intelligent interactive experience. 3. Experimental Results and Analysis In order to evaluate the actual effect of the intelligent dialogue system in the game, we conducted a user survey, invited 10 players to participate in the test, and conducted a questionnaire survey on the satisfaction, immersion and interactive experience of the intelligent dialogue system. The survey results are shown in Table 1. Table 1. Research results Player number Satisfaction (1-5) Immersion (1-5) Interactive experience (1-5) 1 4 4 5 2 5 4 4 3 4 5 4 4 3 3 4 5 5 4 5 6 4 5 3 7 4 4 4 8 5 4 5 9 3 3 4 10 4 5 4 In the satisfaction category, most players scored above 4 (out of 5), which shows that players are satisfied with the overall performance of the intelligent dialogue system. Only a few players gave a rating of 3 points, which may mean that these players still have expectations or some dissatisfaction with some aspects of the system. In the item of immersion, the score is also generally high, which shows that the intelligent dialogue system provides players with a better game experience and enables them to integrate into the game world more deeply. However, similar to satisfaction, a few players gave a lower score, which may be related to the fact that some design or functions of the system failed to fully meet their expectations. In the interactive experience, the distribution of scores is relatively uniform, ranging from 3 to 5. This shows that in terms of interactivity, intelligent dialogue system brings different experiences to different players. Some players may feel that the interactive way of the system is natural and smooth, while others may feel that there is room for improvement. This difference may be due to players' personal game habits, preferences and different demands for interactivity. The research results show that the actual effect of intelligent dialogue system in the game has been recognized by players as a whole, especially in satisfaction and immersion. However, there are still some individual differences and room for improvement in interactive experience. In order to further enhance the game experience of players, we can consider optimizing the interactive design of the system in the future to meet the needs and expectations of more players. At the same time, for players who give lower scores, their feedback can be further collected in order to improve the function and performance of the system. The response time curve of the intelligent game dialogue 40 system can be seen in Figure 2. This curve reflects the response speed of the system in different dialogue rounds or time points. On the whole, the response time is kept at a low level, with an average of about 0.03 seconds, far below the player's perceived delay threshold, which ensures the fluency of the conversation and provides the player with a near real- time interactive experience. Figure 2. Response time of intelligent game dialogue system The response time remained relatively stable during the whole conversation, and there was no significant fluctuation. This shows that the performance of the system is reliable, and the response speed will not be significantly reduced because of the increase of dialogue rounds. This stability is very important to keep the continuity of the game dialogue and the player's immersion. Although the response time fluctuates slightly, these fluctuations are within the acceptable range and will not have a negative impact on the user experience. This fluctuation may be due to the normal differences when the system processes dialogue input with different complexity and length. The response time of intelligent game dialogue system is very ideal, which can meet the expectations of players and provide a smooth and natural dialogue experience. This is of great significance for improving the quality of game experience and enhancing players' satisfaction and immersion. At the same time, it also shows the excellent performance of the intelligent game dialogue system based on ChatGPT in real-time interaction. 4. Conclusion ChatGPT technology is successfully integrated into the game dialogue system in the development of intelligent game dialogue system, and highly intelligent NPC interaction is realized. The system can generate a natural and smooth response according to the player's input, which greatly improves the playability and interest of the game. Compared with the traditional preset dialogue options, ChatGPT-based dialogue system has higher flexibility and adaptability, and can dynamically adjust the dialogue content according to the different choices and performances of players, thus creating a richer and more diverse game experience. Through user research and data analysis, it is found that the intelligent dialogue system has a significant positive impact on the game experience. Players generally report that the dialogue of intelligent NPC makes it easier for them to immerse themselves in the virtual world of the game, which enhances the sense of realism and substitution of the game. At the same time, the interactivity provided by the intelligent dialogue system also gives players more freedom and exploration space in the game, which enhances the overall attraction of the game. The response time is kept at a low level, with an average of about 0.03 seconds, which is far below the player's perceived delay threshold, which ensures the fluency of the conversation and provides the player with a near real-time interactive experience. The study also found some problems and challenges. Some players reported that in some cases, the responses of intelligent NPCs did not fully meet their expectations, and sometimes even misunderstood or answered irrelevant questions. This suggests that the algorithm needs to be further optimized in the subsequent development to improve the accuracy and consistency of the dialogue. The intelligent game dialogue system based on ChatGPT has obvious advantages and potential in improving the game experience. In the future, we will continue in-depth research and constantly improve the system functions to meet the diverse needs of players and promote the wide application and development of intelligent interactive technology in the game field. References [1] An, B. , Brown, D. , & Guerlain, S. (2019). The evaluation of a serious game to improve cross-cultural competence. IEEE Transactions on Learning Technologies, 12(3), 429-441. [2] Wei, X. , Lin, Y. , & Hu, Q. (2024). Dialogue generation model with hierarchical encoding and semantic segmentation of dialogue context. International Journal of Software Engineering and Knowledge Engineering, 34(03), 427-447. [3] Joshy, A. J. , & Hwang, J. T. (2021). Unifying monolithic architectures for large-scale system design optimization. AIAA Journal, 59(6), 1953-1963. [4] Aldabbas, H. , Bajahzar, A. , Alruily, M. , Qureshi, A. A. , Latif, R. M. A. , & Farhan, M. (2020). Google play content scraping and knowledge engineering using natural language processing techniques with the analysis of user reviews. Journal of Intelligent Systems, 30(1), 192-208. [5] Sitompul, O. S., Nababan, E. , Arisandi, D. , Aulia, I. , & Wijaya, H. (2021). Template-based natural language generation in interpreting laboratory blood test. IAENG International Journal of Computer Science, 48(1), 57-65. [6] Jiang, Q. , Wu, Z. , & Kang, J. (2022). Semantic key generation based on natural language. International Journal of Intelligent Systems, 37(7), 4041-4064. [7] Zhang, Y. K., Zhang, P. Y. , & Yan, Y. H. (2018). Data augmentation for language models via adversarial training. Zidonghua Xuebao/Acta Automatica Sinica, 44(5), 891-900. [8] Sugandhi, Kumar, P. , & Kaur, S. (2021). Indian sign language generation system. Computer, 54(3), 37-46. [9] Sebastian, G. , Tesoriero, R. , & Gallud, J. A. (2020). Automatic code generation for language-learning applications. IEEE Latin America Transactions, 18(8), 1433-1440. [10] Miranda Márcio Assis, Guilherme, R. M., Torres, M. N. H. , & Junho, S. M. A. (2018). Domain-specific language for automatic generation of uml models. Iet Software, 12(2), 129- 135.