KatFS Cave Spiders - Simple But Effective AI Design
Hello everyone! It's been a while since my last devlog, but development on the game has been going steadily. Initially, I intended for my next devlog to be about future expectations for the project, but that will have to wait. Today, I want to present the newest enemy type that has been implemented, and share some of my experiences and realizations regarding AI design that came from the process.
First, meet the cave spiders! These critters are pathetic by themselves, but they will travel in swarms and attempt to overwhelm their targets. Fortunately, they can be scared away with fire, which Kalia (the game's protagonist) can wield effortlessly!
Pretty neat, huh? But enough showcasing, let's talk about AI. Most specifically, the difference between AI that is smart and AI that seems smart. For that, we can compare the cave spider AI to the skeleton or zombie AI in KatFS (don't worry, I'll explain the differences if you're not familiar with the game yet!)The first major challenge with their AI was pathfinding. Unity does provide a navmesh/pathfinding solution, but it's designed for 3D games, so a sort of "official hack" has to be used for it to work in 2D. But it works in the end, and the game has zombies and skeletons that are able to navigate through dungeons and around obstacles. Nice. Back then, I made the assumption that all AI scripts in the game would be making use of this form of navigation, and thus included a reference to the navigator component in the base AI script. Because no matter what enemies I planned to add in the future, all of them could use clever navigation, right?
Enter the cave spider. No navigator component whatsoever, just vibes-based movement.
The cave spiders are Boids - "bird-oid objects". You might be familiar with them already, but if you're not, that's a simulation model for flocking behavior first described in 87. So pretty old by computer science standards. You can read more on the technical details here if you'd like. Unlike the navmesh, destination-based movement of the other AIs, the spiders have no particular destination, instead being steered by each other (and certain points of interest). They can easily get lost in a maze, they're unable to navigate around obstacles other than by brute force, they could easily lose the player if not for their speed... And yet they have the best enemy AI in the game thus far (at least in my honest dev opinion)!
The skeletons are smarter, are able to follow the player, patrol areas in squads, attack as a group, by all means they're much smarter than the spiders. And yet the spiders not only have been more fun to watch and play against, but their behavior also seems more impressive. What gives?
That's when I realized something about AI that I assume most ambitious but naive game designers don't. Making AI that is smart is a lot of effort for not a lot of return - but making simple AI that just seems smart has a much better return on investment. AI that tries to be "clever" will often have shortcomings that show between the cracks, resulting in an uncanny valley effect. Maybe the people developing firmware for actual, real life robots have to worry about it, but as game designers, our work is mostly about the smoke and mirrors. Plus, your game still has to run on as many potatoes as you can make it, so there's no reason to double down on a bleeding edge AI implementation.
The challenge now becomes figuring out how to create that impression, which is more of a design challenge than a technical one. A good starting point is setting reasonable expectations for the capabilities of your AI agents. I don't think anyone would expect advanced problem solving skills from cave spiders. Even humans can be imperfect in certain scenarios. So don't overengineer your AI if there's not a reasonable expectation for it.
Another trick is to increase the number of stimuli that your AI can interact with, even if the interactions themselves are pretty basic. The spiders' avoidance of fire is a very basic implementation, but it adds depth and personality to their behavior. They know they are vulnerable to fire, and thus will run away from it no matter what. A lesser example is how the spiders react to collisions - they will simply "reflect" off the collision, which gives them a semblance of obstacle avoidance without actually using a navmesh or pathfinder. A future plan for upcoming enemy types is to also add "action spots" in the world to which AI can navigate to and play certain animations, giving the impression that they're aware of the world they're in even though these spots will be placed by hand on relevant spots.
Embrace emergent behavior - you don't have to micromanage your AI's states and behaviors, sometimes it's best to just let them loose and see if it makes for fun gameplay. Micromanaged AI can also become predictable, and that can be undesirable (not always though!).
And following from that last point - design for fun! The main problem you're solving is how to provide an engaging experience for the player. For some games, that means in-depth AI. For others, simple but effective routines will do. Sometimes even a deliberately dumb AI can make for the most fun experience. Test your AI in game, with playtesters if possible, curate their behaviors to provide for engaging gameplay, and you're golden.
Growing up as a gamer, it was common to see this obsession with "realism" (I even partook in some of it myself), and you still see people nitpicking games over it. But our goal as game designers is not to simulate reality, but to curate an engaging experience. Working on this spider AI made me want to rethink my approach to the already built AI in KatFS. And I might end up making them just a little bit dumber.
Get Kalia and The Fire Staff Pre-Alpha
Kalia and The Fire Staff Pre-Alpha
A fiery top-down dungeon crawling adventure.
Status | Prototype |
Author | gdn001 |
Genre | Action |
Tags | 2D, demon, Dungeon Crawler, Exploration, Female Protagonist, fire, kalia, katfs, Top-Down |
Languages | English |
More posts
- KatFS Alpha Devlog #5 (November 2024)11 days ago
- KatFS Alpha Devlog #4 (October 2024)45 days ago
- KatFS Alpha Devlog #3 (September 2024)75 days ago
- KatFS Alpha Devlog #2 (August 2024)Aug 29, 2024
- KatFS Alpha: The New Balance PhilosophyAug 16, 2024
- KatFS Alpha Devlog #1 (July 2024)Jul 31, 2024
- Kalia and the Cutscenes (and some more stuff)Jul 13, 2024
- Kalia and the NarrativeMay 20, 2024
- Kalia and the Move to AlphaApr 10, 2024
- KatFS Pre-Alpha v0.3.2 is out!Mar 14, 2024
Leave a comment
Log in with itch.io to leave a comment.