Algorithmic adventures: Did you know AI has been making games fun for you since the ‘80s?


The other day, I was wandering around the narrow, twisting alleyways of Oxford city playing Pokemon Go when a woman suddenly appeared out of nowhere and asked me, “Do you want to attend a free lecture about AI (artificial intelligence)?”

She gestured manically towards a door hidden in the ancient brickwork, presumably leading to a lecture hall and not a secret room where I’d get robbed.

“No thanks,” I said. “I’m searching for shiny Skorupis.” We parted ways, having successfully confused one another.

I know academics love talking about their research, but that was weird even by Oxford standards.

I blame the current trend where every company, entrepreneur, and social media influencer talks about AI like it’s the hottest new tech since, erm, the blockchain?

AI has been marketed as this “newly discovered” panacea that can solve all of humanity’s problems, a magical future technology that has finally been made a reality.

But you know what? None of this is really new to me, because as gamers, we’ve been playing with some form of AI, at least since the days of Pong.

I think there’s some benefit to demystifying AI and actually looking at how this new old tech has consistently been used in video games in a very practical and grounded manner.

So if you’d follow me through this completely innocent hidden door, I can start my lecture by talking about a game that uses an advanced AI system, a game called...

Pac-Man

Pac-Man (originally Puck Man) is an arcade game where you play a yellow circle living in a maze that goes wakka wakka, gobbles up pellets, and runs away from ghosts.

'The Impossible Fortress' is a tribute to old schoool games such as Pac-Man.'The Impossible Fortress' is a tribute to old schoool games such as Pac-Man.

You didn’t expect me to be talking about a game from 1980, did you? That’s what you get for following strange people through strange doors!

But seriously, this game really implements AI – after all, what do you think drives the ghosts to chase Pac-Man around the maze?

There are three parts to the ghosts’ AI, and the first tries to answer an ostensibly simple question that’s way more complicated than it should be: how do I get from Point A to Point B?

Consider this: when I want to go to my local supermarket, preferably in the shortest route possible, I need to make a number of decisions. Do I go past the library or cut through the shopping mall? At the T-junction, do I turn left or right?

Similarly, the ghosts need to make similar decisions to move towards Pac-Man because, ironically, despite being ghosts, they can’t phase through walls. When they reach a crossroads, do they turn left, right, or move forward? Which route takes them closer to the player?

This problem of finding the shortest route from A to B is a very common one that machines need to solve, whether they are enemies and NPCs (non-player characters) in a game or autonomous cars driving down actual streets. The process of finding these routes is called “pathfinding”.

I’m not sure which pathfinding algorithm Pac-Man’s ghosts use, but if you’re interested in the nitty-gritty of how video game characters move throughout their worlds, do read up on Dijkstra’s algorithm or the A* algorithm. This is one way to view AI: simply as complex problem-solving programs.

(By the way, if some AI company tries to sell you the fact that it has the “best algorithms” to solve world hunger, find love or whatever, know that an algorithm is just a bunch of instructions. An apple pie recipe is arguably an algorithm for turning apples into pies.)

Ghosts in the machine

The second part of the ghosts’ AI is the specific “NPC behaviour” – or, in other words, how were the ghosts programmed to interact with the human player? How are they designed to act in the game world so as to give the player a challenge without being unfair?

Blinky ghost in Pac-ManBlinky ghost in Pac-Man

There are four ghosts: Blinky (red), Pinky (pink), Inky (blue) and Clyde (orange), with each one behaving differently.

Blinky, for example, is programmed to find the shortest route to the player’s current position (essentially, this means the red ghost chases Pac-Man). Pinky, meanwhile, is programmed to move to a position that’s four “tiles” ahead in the player’s current direction (this means that the pink ghost tries to “intercept” Pac-Man).

Combined, these ghosts act as if they’re working as a team, performing pincer movements to ambush the player and cutting off escapes.

This can make players think that the computer is more clever than it actually is, giving algorithmic or mathematical processes an illusion of, hmm, let’s call it simulated smartness.

The Pac-Man game screen.The Pac-Man game screen.

This form of dynamic decision-making is what gamers usually think of when they think about “AI in games”: the ability for the computer to simulate the behaviour of thinking beings. In other words, we can view AI as virtual “people”.

At the time of writing, there’s no such thing as actually intelligent machines – nobody has created an Artificial General Intelligence (AGI) that thinks like an actual human. Or even a moderately smart orangutan.

But as video games have shown, existing AI can be very good at making you think they’re smarter than they are.

Game director

OK, since we’re using technical terms now, let’s throw in a new one: Finite State Machines (FSM). An FSM is just one way of imagining data, where each “thing” exists in specific states that change given specific input.

For example, Shaun the Human has two states: Hungry and Full. In my Hungry state, if you input a cheeseburger (via the mouth, please), my state will change to Full.

sketch-20231118-the-star-ai-in-games-pt4sketch-20231118-the-star-ai-in-games-pt4

This will be relevant when we talk about the third part of the ghost’s AI, which has everything to do with the dynamic difficulty of the game and, by extension, the overall player experience of actually playing the game.

The ghosts in Pac-Man have three states: in the default Chase state, every ghost will try to chase or intercept the player.

But every once in a while, the ghosts will temporarily enter the Scatter state, where they’ll stop hunting the player.

Finally, in the Frightened state, every ghost flees from the player, who has just eaten one of those big “energiser” pellets.

How long the Chase, Scatter, and Frightened states last has a direct impact on how difficult the game feels.

Have frequent Chase states, and players will feel the pressure of being hunted by the ghosts.

Conversely, longer Scatter or Frightened states will give players more time to breathe.

Obviously, the game’s AI makes sure that later levels have far less forgiving Scatter and Frightened timers.

For a more modern example, Left 4 Dead’s “game director” AI is famous for calibrating the difficulty of the game depending on how well players are doing.

If the players are mowing down the undead hordes with ease, then the AI will throw in more zombies to ramp up the tension.

Conversely, if the last fight left the players with too many injuries, then the AI spawns more health packs so players can recover.

This is another way of viewing AI: as a system that intelligently reacts to player input, acting as a game director or Dungeon Master whose job it is to make the game challenging enough to be fun but not so difficult as to be impossible.

How well the computer actually does this job can be scientifically measured by how often a screaming player chucks their controller out the window.

Resource maker

OK, let’s move away from Pac-Man for now, because I need to actually talk about modern and future AI advancements in games. (Do search for the “Pac-Man Dossier” article or GMTK’s Pac-Man video if you want to learn more about the yellow pellet-eater.)

If you look around the Internet – or at least the random weird ads that keep popping up on my X/Twitter timeline – you’ll often find AI enthusiasts talking about how ChatGPT is the greatest thing ever, as it can write your emails, finish your homework, or make stock predictions. (That last one is a terrible idea, BTW.) Or they’d hype up the “artistic prowess” of Midjourney.

The marketing makes it sound like the newest way to view AI is as “personal assistants” or “worker-servants”, but honestly, I think that’s a bit inaccurate.

For example, ChatGPT is “just” a large language model, which is basically autocorrect/text prediction but scaled up.

Rather, I think a more accurate way to view it, at least in terms of game development, is: AI as content generators, or resource makers.

My personal feelings about AI-generated content can best be summarised as “eeehhh...”.

As an artist and a writer, I baulk at the idea of game studios using AI-derived technology as an excuse to not hire actual human illustrators, script writers, voice actors, or what have you.

That said, I do recognise that AI-generated content has a specific place in some video games.

Randomly-generated maps, for example, have been around for ages. They’ll never have the intelligent design or personality of hand-crafted maps, but randomly generated maps are nonetheless fantastic in games like roguelikes, where replayability matters much more than artisanally assembled experiences.

Smaller studios that can’t actually afford artists could also use Midjourney or something similar to generate placeholders or starting points for their art assets, though eventually they’d need to get a proper art director if they want to get away from a potentially stereotypical or unrealistic aesthetic.

So will game studios embrace this aspect of modern AI tech to make more amazing games in the future, where compelling stories and expansive worlds can be generated on the fly?

I don’t know, but I do hope that game devs will use this hot marketable tech with much more caution and common sense than that time when everybody kept trying to build games “on the blockchain”, because NFTs were the hot marketable tech back then.

Simulated smartness

I imagine that at some point in the far, distant future, AI will actually be as advanced as they’re being marketed as right now.

AGIs will solve all our problems and answer all our questions, and I’ll have a robot buddy like R2-D2. (Except with a nicer butt.)

For now, however, I think it’s important to first understand what AI can actually achieve and appreciate what they do without thinking it’s actually magic.

As video games have shown us, even really old examples of simulated smartness can bring us so much joy and fun challenges.

I suppose the only question AI can never answer is what was really behind that door hidden in that Oxford alleyway. Was there really a lecture hall back there? A room to trap and rob the gullible? Or perhaps... Narnia? I guess I’ll never know.

Pac-Man (1980)

Developer/Publisher: Namco/Midway

Platforms: Arcade (not Apple Arcade, an actual arcade – kids, ask your parents)

Release date: July 1980 (Japan)

Follow us on our official WhatsApp channel for breaking news alerts and key updates!
   

Next In Tech News

KKR raises tender offer price for Fuji Soft acquisition
Putin will look into YouTube disruptions, Kremlin says
Singapore clears South Korean Hanwha's buyout of Dyna-Mac
Samsung Electronics plans $7.2 billion buyback after share price plunges
Man who stole and laundered roughly US$1bil in bitcoin is sentenced to 5 years in prison
Stiff business: Berlin startup will freeze your corpse for monthly fee
White supremacist, Nazi content spread on Steam game service
After Trump’s victory, US election falsehoods shift left
Review fatigue? Consumers are less likely to share feedback after a purchase
AI weather models have shown promise this hurricane season

Others Also Read