# AI in Games
Published: 2024-07-15
URL: https://codehs.com/blog/2024-07-15-ai-in-games-546056f84449

AI is revolutionizing aspects of the gaming industry and making games more realistic and lifelike

Imagine video game characters who don’t just follow pre-programmed routines, but react and adapt to your choices. This is the power of artificial intelligence (AI) in gaming. AI breathes life into non-playable characters (NPCs) by giving them the ability to make decisions, strategize, and even learn from their encounters with the player. It’s like giving NPCs a virtual mind, making the game world feel more immersive and the challenges more dynamic.

AI has been used in games for many years, and a notable example is the [chess match](https://aibusiness.com/ml/25-years-ago-today-how-deep-blue-vs-kasparov-changed-ai-forever#close-modal) between chess champion Garry Kasparov and IBM AI-powered computer Deep Blue in 1997. During this grueling 9-day game, Garry competed against Deep Blue, eventually conceding and passing on the victory to the computer.

Since the computer’s win, AI has revolutionized other aspects of the gaming industry, making games more realistic and lifelike. Generative AI has also been utilized to create game assets like background scenery or updating new game levels.

![undefined](https://prod.superblogcdn.com/site_cuid_cm264m3an0084qegvyd7aetst/images/0auobpv0z6aogpzzi-1728980956711-compressed.0*AUObpv0Z6aOgpZzi)_Pacman_(1980). Namco.

Although they don’t use generative or modern AI, the four ghosts in Namco’s _Pacman_ are each programmed to simulate intelligent behaviors. The game’s designer, Toru Iwatani, wanted each ghost to behave differently. To do this, each ghost calculates a different target, relative to Pacman’s position and other rules ghosts must follow. This programmed artificial intelligence relies on the state of the ghosts and the player’s choices throughout the game.

As generative AI systems improve, it’s likely that non-player characters will simulate more realistic behaviors, like adjusting movements and behaviors by learning and predicting player behaviors.

To get students to apply computational thinking skills, teachers can use programmed AI behaviors in video games to analyze the flow of code. This simple exercise can be done with any programming language or simply pseudocode. Let’s take a look at this gameplay from Nintendo’s _Super Mario Bros._

![undefined](https://prod.superblogcdn.com/site_cuid_cm264m3an0084qegvyd7aetst/images/0x6bwzutl2iznoesj-1728980963676-compressed.0*X6bwZUtL2IZNoEsJ)

The Goombas, or mushroom-shaped enemy characters, move from side-to-side until they collide with a pipe or object. There are some if-statements in there too, but let’s try and break down the programmed AI behaviors of these enemies in pseudocode.

![undefined](https://prod.superblogcdn.com/site_cuid_cm264m3an0084qegvyd7aetst/images/1dsr3g1kthntsqaz26smzg-1728980975774-compressed.png)

Using programmed AI behaviors, students can break down the movements and actions of NPCs using computational thinking skills like decomposition, algorithmic thinking, pattern recognition, and abstraction. Look for some basic gameplay video clips online, single out one or two NPCs, and guide students through breaking down the AI behaviors in pseudocode or a flowchart.

CodeHS offers a full suite of AI resources, including updated [AI courses](https://codehs.com/curriculum/catalog?tag=Artificial%20Intelligence), [new projects](https://codehs.com/app/project_catalog?tag=AI&grade=all) in the CodeHS Project Catalog, and [professional development workshops and courses](https://codehs.com/learnmore?c=AIinGames) focused on deepening understanding of AI. Check out this project to help students explore [AI in Games](https://codehs.com/app/curriculum/projects/proj-ai-in-games)!

* * *

_Interested in learning more about how to unleash the power of AI in your school or district? Request more information_ [_here_](https://codehs.com/learnmore?c=AIinGames) _or reach out to_ [_hello@codehs.com_](mailto:hello@codehs.com) _._

By [CodeHS](https://medium.com/@codehs) on [July 15, 2024](https://medium.com/p/546056f84449).


---
This blog is powered by Superblog. Visit https://superblog.ai to know more.
---

