Fun AI you've used before
I'm working on a game now that doesn't require pathing, complicated algorithms, or high-level thinking for the AI. The game revolves around fantasy melee combat against monsters as in "Zelda," "Secret of Mana," "Diablo" or any number of other games over the years. However, I'm running into a problem where my AI just isn't compelling. Monsters wander randomly until they see you, they look at you and pause (reaction time) for a few hundred milliseconds and then chase/attack until dead.
I am hoping to draw upon your experiences to draft some ideas for more compelling behavior. Is there anything you've used that just makes the enemies in your game come to life? Maybe you had a very limited set of animations to work with, but were able to put together something that just shed personality all over the place? Maybe you accidentally created some cool emergent behavior and love using it in every game you make nowadays?
Care to share your experiences? : D
And first, some ideas to help seed a discussion:
1) When a monster sees the PC, it will turn to face him, but refrain from charging. Perhaps it will attempt to circle the PC while keeping its distance? This monster will wait for an opportunity -- say, during one of the PC's spell or weapon cool down periods -- and then rush in to strike.
2) A certain type of small goblin will flee when the Player Character turns to face it. However, groups of them will attempt to move behind the PC and launch ranged attacks at his back.
3) Skeleton warriors see that there is a healer type monster in the area. They then prefer movements that place them physically between the PC and their healer.
I like using simple state based systems and low-level emergent behaviour routines, since they're easy to code up and to tweak and they can lead to interesting behaviour.
For example, here's an outline of the A.I. for "The Fish" in a simple game I made called "Pierre and the Fish" (link at the bottom of the screen). The game involves you in a submarine trying to avoid getting eaten by a great big fish. It's been a while since I've looked at the code, but I'm pretty sure the A.I. for the Fish went a bit like this:
From that simple set of rules, you get a lot of the gameplay (there's a collecting part as well that gets you points). Because of the Fish's attack pattern and the fact that your sub has to move forward, you have to do feints with the sub, swimming in one direction and then turning at the last moment.
For example, here's an outline of the A.I. for "The Fish" in a simple game I made called "Pierre and the Fish" (link at the bottom of the screen). The game involves you in a submarine trying to avoid getting eaten by a great big fish. It's been a while since I've looked at the code, but I'm pretty sure the A.I. for the Fish went a bit like this:
- The Fish itself has simple physical properties; velocity and angular turning rate
- If the Fish is in front of the sub, it goes into a "slow down" mode where it uses a neutral facial expression, levels off to swim horizontally and slows down to a speed slower than the sub
- If the Fish gets behind the sub, it enters an "attack" mode where it starts grinning evilly, accelerating and starts turning until it is swimming directly towards the sub
- If the Fish gets very close to the sub it will start a bite animation, which will eat the sub if it is within a contact distance (and thus game over)
- The Fish's turning speed increases gradually as the game goes on, making it harder to avoid
From that simple set of rules, you get a lot of the gameplay (there's a collecting part as well that gets you points). Because of the Fish's attack pattern and the fact that your sub has to move forward, you have to do feints with the sub, swimming in one direction and then turning at the last moment.
Quote: Original post by Foxostro
I am hoping to draw upon your experiences to draft some ideas for more compelling behavior. Is there anything you've used that just makes the enemies in your game come to life?
I didn't get to implement it, but I thought about implementing an ant colony optimization algorithm to monster behavior.
The idea was to have a huge number of predefined behaviors and apply them at random to each kind of monster the first time the player found them. Then, I'd use the damage dealt, time survived, other monster health healed (each monster would have his own criteria), to select which behavior worked better for each monster and for a particular player.
For example, after a while playing as an archer, the melee monsters should evolve to "go with a healer" behavior. When heading a melee character, the same melee monsters could evolve to "bring an archer" and against a tank "don't attack without a buff spell" or "hit and run".
Quote: Original post by Foxostro
Is there anything you've used that just makes the enemies in your game come to life?
I ended up using the algorithm for an application that organized a truck fleet for the gathering and disposal of cow corpses. Fortunately no cow has come to life yet (that I've been informed of, they may have considered it a non computer related bug).
Quote: Original post by Trapper Zoid
I like using simple state based systems and low-level emergent behaviour routines, since they're easy to code up and to tweak and they can lead to interesting behaviour.
I downloaded Pierre and the Fish and I like what you did with it. The game play is very simple, and quite fun!
I am going to start looking into "engineering" some emergent behavior for interactions between AI agents, though I suspect this will require more experimentation than anything else.
Quote: Zanshibumi
The idea was to have a huge number of predefined behaviors and apply them at random to each kind of monster the first time the player found them. Then, I'd use the damage dealt, time survived, other monster health healed (each monster would have his own criteria), to select which behavior worked better for each monster and for a particular player.
Using this technique, the first few minutes will be lost trying to adapt to the player's game play style. The problem is that I must entertain the player from the very first second of game play or s/he gets bored and moves on to download another game from our site ( which is problem enough with my 20mb installer size :p ) I suppose I could start the system off with some good, fun default settings, but if that's the case, then I might as well not bother IMO
I've been tweaking my game for the last few days and I think I have improved gameplay a good bit. I have it to the point now where my brother actually enjoyed himself when we went through the game together in multiplayer mode.
I said a few days ago that I was going to experiment with emergent behavior, but this didn't go as well as expected. What I did come up with was interesting, so I thought I would post what I learned and spark some discussion on the matter.
Random fun fact:
It is already advantageous in my game to have enemy spell casters attack enemy melee attackers for you. You do this by having the melee attacker chase after you and, if you time right, walk directly into the path of the spell caster's fireball :) If this act of friendly fire caused said melee attacker to go into a wild fury and chase after the spell caster, well that would be great fun!
"Vocalization of state" seems to be a very important factor when determining how much "intelligence" players will attribute to the enemies. Adding a 200-300 hundred millisecond delay between updating the AI state machine causes a noticeable "reaction time," which does make enemies feel less artificial. Also, I can make enemies seem to consider whether or not they want to attack the player by making them pause for a moment, and look at the PC before attacking or fleeing. If the duration of this pause was related to the enemy's health or the player's strength, then this behavior might seem to be reluctance or fear to approach the player.
In Fallout, you'll notice that "intelligent" enemies will often have display speech text during combat. If this text can shed some light onto the current state of the AI, then player perceptions of AI intelligence are greatly improved. Even simple labels like "Run away!" or "Regroup!" or "I'll kill you!!" reveal a lot about the intentions of the AI.
I've been told that having the enemies exploit the player's weaknesses like this is considered cheating, or at least un-fun.
Too complicated. It is more than enough to have the goblins follow a few simple directives:
* When alone and you see the player, flee
* When alone and you see a goblin, follow it
* When accompanied by goblin allies and you see the player, attack
This is also too complicated. If the healer can make some sort of request for backup or assistance (The book AI Game Programming Wisdom describes a generic trigger-based system that you can easily exploit to this effect, though my game uses its own system.) then the healer can summon nearby warriors to swarm around him. This is more than enough to make it abundantly clear that the warriors are protecting their healer and doesn't even require the warriors or the healer to have to recognize what type of critter each other is, specifically.
I said a few days ago that I was going to experiment with emergent behavior, but this didn't go as well as expected. What I did come up with was interesting, so I thought I would post what I learned and spark some discussion on the matter.
Random fun fact:
It is already advantageous in my game to have enemy spell casters attack enemy melee attackers for you. You do this by having the melee attacker chase after you and, if you time right, walk directly into the path of the spell caster's fireball :) If this act of friendly fire caused said melee attacker to go into a wild fury and chase after the spell caster, well that would be great fun!
"Vocalization of state" seems to be a very important factor when determining how much "intelligence" players will attribute to the enemies. Adding a 200-300 hundred millisecond delay between updating the AI state machine causes a noticeable "reaction time," which does make enemies feel less artificial. Also, I can make enemies seem to consider whether or not they want to attack the player by making them pause for a moment, and look at the PC before attacking or fleeing. If the duration of this pause was related to the enemy's health or the player's strength, then this behavior might seem to be reluctance or fear to approach the player.
In Fallout, you'll notice that "intelligent" enemies will often have display speech text during combat. If this text can shed some light onto the current state of the AI, then player perceptions of AI intelligence are greatly improved. Even simple labels like "Run away!" or "Regroup!" or "I'll kill you!!" reveal a lot about the intentions of the AI.
Quote: Originally posted by meWhen a monster sees the PC, it will turn to face him, but refrain from charging. Perhaps it will attempt to circle the PC while keeping its distance? This monster will wait for an opportunity -- say, during one of the PC's spell or weapon cool down periods -- and then rush in to strike.
I've been told that having the enemies exploit the player's weaknesses like this is considered cheating, or at least un-fun.
Quote: Originally posted by meA certain type of small goblin will flee when the Player Character turns to face it. However, groups of them will attempt to move behind the PC and launch ranged attacks at his back.
Too complicated. It is more than enough to have the goblins follow a few simple directives:
* When alone and you see the player, flee
* When alone and you see a goblin, follow it
* When accompanied by goblin allies and you see the player, attack
Quote: Originally posted by meSkeleton warriors see that there is a healer type monster in the area. They then prefer movements that place them physically between the PC and their healer.
This is also too complicated. If the healer can make some sort of request for backup or assistance (The book AI Game Programming Wisdom describes a generic trigger-based system that you can easily exploit to this effect, though my game uses its own system.) then the healer can summon nearby warriors to swarm around him. This is more than enough to make it abundantly clear that the warriors are protecting their healer and doesn't even require the warriors or the healer to have to recognize what type of critter each other is, specifically.
Remember that you can also randomly choose between different behaviors, or randomly set "personality" attributes that influence the behaviors chosen. A goblin might have a small chance to suddenly become brave and charge at the hero on his own, or some goblins might be braver than others. An enemy that attacks when the player is vulnerable in certain ways could mix things up a bit. Just make sure the player has some way to deal with this enemy, and don't overuse it. The enemy could have a weakness of its own for the player to exploit.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement