# Leveraging Large Language Models to Support Authoring Gamified Programming Exercises +
## 1 Introduction  
The rising demand for skilled programmers reflects the pivotal role of programming in various areas of the contemporary world [1]. However, the formidable challenge of learning programming is an obstacle to meeting this demand. The integration of automated assessment tools has shown promise in providing swift feedback to students as they experiment with their code, facilitating a more efficient learning process [2]. In tandem, gamificationhas become a powerful strategy to enhance motivation and engagement, intensifying students' efforts to master programming concepts [3]. Together, these approaches form the backbone of the Framework for Gamified Programming Education (FGPE) ecosystem [4]. The practical usefulness of the FGPE relies on the availability of gamified programming exercises covering diverse topics.  
In the context of this work, we define a gamified programming exercise as an exercise aimed at testing the student's ability to solve a specified problem, with the use of any common or peculiar programming language feature or features, embedded in a narrative scenario (considered as a gamification element, following, e.g., [5; 6; 7]), in which solving the exercise is part of a wider challenge. On the technical level, a gamified programming exercise is a programming exercise enhanced with an additional layer of metadata, defining, e.g., the conditions for accessing the exercise and the rewards for solving it, conforming to a standardized format (e.g., GEdIL [8]), making it possible to use the exercise within a gamified interactive learning environment, such as the FGPE PLE [4].  
Although there are open-licensed collections of these exercises [9], more are needed to let students practice the same techniques in different contexts or to provide each student with exercises different from their peers. Creating new gamified exercises remains a significant challenge for educators, teachers, and trainers [4].  
This paper, an extended version of our late-breaking work presented at the 25 th International Conference on Artificial Intelligence in Education (AIED 2024) [10], addresses this challenge by introducing GAMAI, an artificial intelligence (AI)-powered exercise gamifier integrated into the Framework for Gamified Programming Education (FGPE) ecosystem. GAMAI leverages OpenAI API [11] to streamline the process of creating gamified programming exercises. Through GAMAI, teachers can employ a storytelling approach to articulate the gamified scenario. The system automatically enhances natural language text with essential sentences required by OpenAI API to contextualize the prompt. Once the gamified scenario has been generated, GAMAI further automates the production of specification files that can be easily edited within FGPE AuthorKit [4]. This innovative approach aims to alleviate the burden on educators, facilitating the seamless creation and integration of gamified programming exercises into educational curricula. The novel contribution of this paper is the processing approach to text prompt augmentation. The proposed algorithm decorates the teachers' gamified storytelling, to enable an automatic gamified programming exercise playground.  
The rest of this paper is organized as follows: Section 2 gives an overview of using AI for the automatic generation of programming exercises; Section 3 describes the Framework for Gamified Programming Education ecosystem targeted by GAMAI, how GAMAI was designed and implemented, and how it operates; a qualitative evaluation of the exercises generated with GAMAI is reported in Section 4; finally, the paper content is summarized in the final Section 5, with concluding remarks and an outline of the next steps planned for future research.