# AI in LCAPS:
###### tags: `Startup`
### Using AI to speed up the developement cycle:
- Better documentation(Clear and concise APIs, with meaningful names..)
- Lowering the cost of exploration (Testing simple things before deciding on the best solution, imaging wroting hundreds lines of code and deciding they were not worth it)
- Streamlining the game development process through automation.
- rocedural content generation (Art, Maps, characters, levels, challenges...)
### Using AI in the game:
#### AI use cases:
1. **Personalized User Experience:** AI algorithms analyze individual gaming habits to create customized in-game content, challenges, and rewards tailored to each player's preferences.
2. **Intelligent NPCs:** Machine learning and AI techniques, such as LLMs and reinforcement learning, make non-playable characters (NPCs) more intelligent and realistic, enhancing the overall gaming experience.
3. **Eliminates Predictability in Game Design:** AI in game development prevents games from becoming predictable and monotonous, especially for kids, by introducing new elements and stories to keep the gameplay fresh and engaging.
4. **Predictive and Game Analytics:** Game analytics utilizes data analysis to understand player behavior and preferences, helping developers create profiles and make informed decisions about game design and updates.
5. **Stabilizing In-Game Complexity:** AI optimization techniques help balance the level of complexity in game mechanics and challenges, ensuring a satisfying gameplay experience without overwhelming players.
6. **NLP for Chatbots and Virtual Assistants:** AI-powered chatbots and virtual assistants, like DAKA, assist children with various tasks and provide support throughout the game using natural language processing (NLP) capabilities.
#### AI algorithmes:
1. **Personalized User Experience:** To create personalized gaming experiences, the game developers can use collaborative filtering algorithms like **item-based collaborative filtering** or **matrix factorization**. These algorithms analyze the gaming habits and preferences of individual players and recommend tailored content, challenges, and rewards based on similar patterns from other players.
2. **Intelligent NPCs:** To make non-playable characters (NPCs) more intelligent and realistic, **reinforcement learning** algorithms can be employed. These algorithms allow NPCs to learn and adapt based on their interactions with the player and the game environment. They can use techniques such as Q-learning or Deep Q-Networks to optimize NPC behavior and decision-making.
3. **Eliminates Predictability in Game Design:** To introduce novelty and unpredictability in game design, **generative adversarial networks (GANs)** can be utilized. GANs can generate new content, such as levels, environments, or storylines, by learning from existing game data and creating variations that offer fresh experiences to players.
4. **Predictive and Game Analytics:** For gathering, measuring, analyzing, and interpreting player data, various machine learning algorithms can be employed. These include **classification algorithms** like decision trees or random forests to categorize player behavior, **clustering algorithms** like k-means to group players with similar preferences, and **regression algorithms** like linear regression or support vector regression to predict player preferences or in-game performance.
5. **Stabilizing In-Game Complexity:** To optimize game mechanics and balance in-game complexity, **evolutionary algorithms** can be utilized. These algorithms simulate natural evolution processes to iteratively improve the game mechanics by finding an optimal balance between challenge and player satisfaction. Techniques such as genetic algorithms or particle swarm optimization can be employed.
6. **NLP for Chatbots and Virtual Assistants:** For natural language processing tasks, such as chatbot interactions or virtual assistant functionality such as **GPT (Generative Pre-trained Transformer)** can be used. These models enable the chatbots or virtual assistants to understand and generate human-like responses, providing helpful and engaging interactions with players.
### Examples:
| Features | Example |
| ----------------- |:----------------------- |
| Negotiating the price | [:link:][Price] |
| Interactive AI Characters | [:link:][AI speech] |
| NPC Dialog | [:link:][NPC dialog] |
| Player behavior | [:link:][Behavior] |
| Personalized lesson plans | [:link:][Teachers] |
| LLM-driven NPCs | [:link:][LLM npc] |
| LLM prompt game | [:link:][LLM prompt game] |
| LLM-driven NPCs | [:link:][LLM npc] |
[Price]: https://www.mobygames.com/game/200860/turkish-carpet-salesman/promo/group-124749/image-964023/
[AI speech]: https://youtu.be/DnF4WzM5LPU?start=100&end=142
[NPC dialog]: https://youtu.be/akceKOLtytw?start=103&end=171
[Behavior]: https://deliverypdf.ssrn.com/delivery.php?ID=044090101066108119066066081012088088034056090036079024023026125111066006108030084075060056032028047044115027107026002082110119112075028080092087027125101024015108110026011016025031120096086094081028030074004086024094108103079026103001029005070102014084&EXT=pdf&INDEX=TRUE
[Teachers]: https://people.csail.mit.edu/gombolay/Publications/Gombolay_TCIAIG_2017.pdf
[LLM npc]: https://www.youtube.com/watch?v=xkn0H_iWDEQ
[LLM prompt game]: https://github.com/fladdict/llm_games
{%youtube akceKOLtytw %}
{%youtube DnF4WzM5LPU %}
{%youtube xkn0H_iWDEQ %}
###### `Note(Anass) : Read later`
> https://ieeexplore.ieee.org/document/5430109/similar#similar
> https://onlinelibrary.wiley.com/doi/abs/10.1111/ijsa.12363
> https://deliverypdf.ssrn.com/delivery.php?ID=044090101066108119066066081012088088034056090036079024023026125111066006108030084075060056032028047044115027107026002082110119112075028080092087027125101024015108110026011016025031120096086094081028030074004086024094108103079026103001029005070102014084&EXT=pdf&INDEX=TRUE
###### `Note(Anass) : Test later`
Notes:
- Silly tavern can be an example of a game that incorporates LLMs with backends such as koboldcpp.
- 7B models, referring to large language models with billions of parameters, are capable of handling these interactions and can be fine-tuned for such tasks on consumer hardware using qlora.
- The suggestion is to put the LLM on rails, meaning to provide fixed prompts and actions for the LLM to take, allowing the player to engage in conversations with the character. This approach creates a more immersive experience similar to a normal RPG game but enhanced by the interaction with the AI-controlled character.
- The game employs the GPT-3.5-turbo language model, utilizing a JSON representation to exchange the game state between the game engine and the language model. In version 0.2, the management of the context window is being improved by introducing a "memory" management prompt. Furthermore, in the upcoming version 0.3, the game state will be stored within the game engine, ensuring better handling and consistency during interactions with the language model.