Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 02:49:07 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Examples of Memorable AI
Pages: [1] 2
Print
Author Topic: Examples of Memorable AI  (Read 1888 times)
RujiK
Level 2
**



View Profile
« on: November 20, 2015, 09:22:15 AM »

While studying good AI from other games, I realized I learn just as much from bad AI. "I gotta make sure my AI does or doesn't do that!" Can both be powerful lessons.

An example of odd AI:
To max out my armor skill in Skyrim (You level up by being injured) I found a bandit and let her beat me for a good 10 minutes while casting heal. It was obvious I was toying with her since I could heal faster than she could damage me but she never gave up and even yelled taunts for the entire duration. "I've fought mudcrabs stronger than you!!"

Anyone with a brain would have realized I was too powerful and tried to run away, but I'm guessing Skyrim's "Flee" command, is only called if the unit's health is low.


Could I get more examples of any kind of Memorable AI? AI can be from any game genre, it's quite helpful to me. Thanks!
« Last Edit: November 24, 2015, 06:04:12 AM by RujiK » Logged

oahda
Level 10
*****



View Profile
« Reply #1 on: November 20, 2015, 09:49:20 AM »

The one in Wind Waker (and subsequent games based on the same engine such as Twilight Princess) is fundamentally good but sort of wastes its potential. I actually never knew it was as advanced as it is until it was shown to me this year or so, because it only really shows when you allow the enemies some time, in which case you can clearly see that they learn and remember from each thing you throw at them, but I never realised this because you can just hack and slash like crazy and they'll be down in no time. The AI is good if you actually examine it, but it's too slow to really show during normal gameplay. So that's wasted potential, which I think is an angle worth mentioning.
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #2 on: November 20, 2015, 10:37:40 AM »

This sounds pretty futile. Skyrim is very open ended, and the AI is outclassed by the scope of things that could happen. If you are of the mindset that each example of failure in Skyrim is a lesson to be learnt from, you could fix the AI for days without running out of examples. Case-based analysis only gets you so far. Sure, you can make a stupid AI appear pretty slick *eventually*, but the effort required is not really on the indie side of the spectrum. If Bethesda cannot do it (awful AI reputation notwithstanding), what makes you think you can?

Anyway, as you know, smart AI takes a back seat to gameplay. It's quite possible they deliberately decided that monsters don't flee when outclassed, as that would be less fun. You might as well question the design descision that allowed you to level by standing still and taking hits from a weak enemy.
Logged
RujiK
Level 2
**



View Profile
« Reply #3 on: November 20, 2015, 11:33:26 AM »

@Prinsessa
Actually, I played and finished twilight princess and have no idea what you are talking about. I'll have to look into some youtube videos of the AI I never saw.

This sounds pretty futile. ... Case-based analysis only gets you so far.
I am disappointed you seem to find a legitimate topic so irritating...  Sad

"If Bethesda cannot do it, why can you?" is a loaded question. I have no doubt Bethesda COULD have done it, it's just that they didn't. (I don't care about the WHY yet, I am only focusing on AI right now. But that may be a concern later.)

Case-based analysis may not be your cup of tea, but it's very helpful/entertaining to me.

If you are of the mindset that each example of failure in Skyrim is a lesson to be learnt from, you could fix the AI for days without running out of examples.
Is not every failure (AI or not) a lesson to be learned? If I compile a list of things to double check with my AI, I don't see the negative side. (And it's fun too.)
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #4 on: November 20, 2015, 02:33:24 PM »

Where I can find those zelda AI video SHOW PROOF PLEASE!
Logged

oahda
Level 10
*****



View Profile
« Reply #5 on: November 20, 2015, 02:39:13 PM »

I don't have a video. :c Saw it in ACTION here on the sofa at home, gf playing and showing me. If you have the games you can try it out. In WW you can try like moblins and darknuts and in TP we tried it on the big guards right at the end in Hyrule Castle. Start easy, shooting one arrow that it won't deflect, and it then learns about arrows and starts deflecting them and so on.
Logged

qMopey
Level 6
*


View Profile WWW
« Reply #6 on: November 20, 2015, 03:16:14 PM »

I hope this isn't too off-topic. Boris's comments gave me an idea since the topic of generalization came up. For the case of fleeing in Skyrim, creating some kind of "scared" threshold wouldn't be too hard with a neural network. If one takes the time to create a good training set of data the net could generalize for lots of cases in-game.

For example, lets say we want AI to be scared of the player if: 1) AI has little HP, 2) player damages the AI quickly, 3) player takes little to no damage from the AI. Creating inputs to the net for (1) would be pretty trivial. Inputs for (2) could be inputting a rolling average of damage per second for the last X seconds. More complicated or simpler alternatives for (2) could be used. For (3) input could be something like the max hit the player took out of the last 5 or so hits. These are just examples.

Difficulty here would be in creating a good training set, and this could take a while. It would possibly consist of the author carefully simulating (trying out) various scenarios that involve the three categories, and deciding on a subjective basis on what the "scary value" is for each scenario. This would have to happen once per scenario.

The net will now look like this for mapping the inputs to the output (bear with the silly ascii art, I felt inspired  Shrug ):

Code:
1) -> \
2) ->   -> scaryness
3) -> /

Where scaryness would be between 0 and 1. Then the AIs can each have their own internal "braveness" value in the range of 0-1. If braveness is ever lower than scaryness of the situation, the AI should flee from the player. Thinking about it, the max scaryness value could be held, and current scaryness computed each frame. The max scaryness could decay over time. This makes the AI stay scared for some time once something scary happens, but gets over it over some time.

Pros:
- Wide variety of things can be made to influence scaryness, like what the player is wearing, how fast the player can run, how many NPCs they've killed in the past, how long the fight between the AI and the player lasts, etc.
- There are net libraries available for use
- Implementing a net could be a really valuable use of time since it covers a range of difficult topics
- Running the net in real-time is a very efficient operation

Cons:
- Making good training data can take some intuition and be pretty difficult (i.e. trial and error, experience)
- Similar to the above point, designing good net inputs can take some time to get right, and require some intuition about neural nets
- Changing the training data or inputs to the net requires recompiling the training set and re-training the net
« Last Edit: November 20, 2015, 03:32:28 PM by qMopey » Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #7 on: November 20, 2015, 03:33:30 PM »

I guess I was a little negative. Consider me chastened.

Skyrim is basically a haven for these sorts of bugs, and thanks to the mod system you can find descriptions of all the ones important enough people have made a fix. E.g. this mod address exactly the issue you've raised, amongst others.
Logged
RujiK
Level 2
**



View Profile
« Reply #8 on: November 23, 2015, 05:27:25 AM »

@Princessa
I couldn't find a video of the super Zelda AI either and I don't have a console to test it... Maybe you could make a video and become the next youtube sensation or something.

@BorisTheBrave
Thanks for the link! That's almost like a giant list of AI improvments/changes! Great things to add to my checklist. (That mod must have been loads of work.)

@qMopey
Not too off-topic! I think I may have made the topic too specific anyway. (Probably should have just been Memorable AI or something.) A Neural network? Wow, that is hardcore. By any chance have you implemented a Neural network in anything? From my brief understanding they are very hard to work with and not ideal for most AI. I currently have a FSM implemented but plan on changing or at least dabbling with some form of a behavior tree.
Logged

ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #9 on: November 23, 2015, 06:47:48 AM »

I have both wind waker and twilight princess, so maybe I'll try toying around with them tonight or something.
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #10 on: November 23, 2015, 07:51:35 AM »

Neural network is overkill what you want is an utility system (possibly nested utility concept)
Logged

muki
Level 2
**



View Profile
« Reply #11 on: November 23, 2015, 08:16:39 AM »

In Fallout, your AI companions have no hesitation using a nuke at melee range when that's all that's available to them. Smarter AI would have forced them to use fists, even if they have no chance. Still better than blowing themselves up.
Logged
oahda
Level 10
*****



View Profile
« Reply #12 on: November 23, 2015, 10:01:50 AM »

Well, if they "have no chance" anyway...
Logged

muki
Level 2
**



View Profile
« Reply #13 on: November 23, 2015, 10:07:04 AM »

Well, if they "have no chance" anyway...

"melee nuke" also means you have no chance either, if you're in the neighborhood.  Cheesy
Logged
qMopey
Level 6
*


View Profile WWW
« Reply #14 on: November 23, 2015, 10:32:50 AM »

@qMopey
Not too off-topic! I think I may have made the topic too specific anyway. (Probably should have just been Memorable AI or something.) A Neural network? Wow, that is hardcore. By any chance have you implemented a Neural network in anything? From my brief understanding they are very hard to work with and not ideal for most AI. I currently have a FSM implemented but plan on changing or at least dabbling with some form of a behavior tree.

Yeah I've used them before and wrote my own net library. They are very easy to use if you have one already trained, and pretty much is a black box function call (an efficient black box, too). For example, this is what it looks like to run my net in-game:

Code:
float input[ 4 ];
float output[ 2 ];
CollectInput( input ); // game function
net->Apply( input, output );
UseOutput( output ); // game function

The hard part is training, and that's only hard because collecting good training data is hard. Like most things in computer science, if you keep your scope down things can become much easier. If you scope down your net's responsibilities, training can become easy.

FSM is a great solution if you know which cases you need, and know that these cases are good enough to convince the player. A net would be a great solution if it's not too hard to gather training data, and generalization is pretty important for convincing the player. You can think of a net sort of like a FSM, but this net takes some inputs and tells you which state you're in on-the-fly. Sometimes the inputs can be very non-intuitive or difficult to relate to the output, but the net finds a relation for you during training. If you make the FSM you have to write code to explicitly handle your relation of inputs to states, and there is *no* generalization.

So it's the generalization that makes the net attractive. The net can learn based off of the experiences in the training data, and when run in your game also gives the right answers to situations that are similar, but not the same. You can think of this like basic extrapolation.

In memory during run-time you just give the net some floats, and it outputs some floats. Inside there's a bunch of plane equations (dot products). So we can think of a net as a non-linear transformation matrix, as in y = Ax + b. y is your output, x is your input, A is the net's internal matrix, and b is an auxiliary vector inside the net. Training the net solves for A and b given x and y pairs.

Hope that makes sense Smiley Like I said there are net libraries available for training and running the net in your game. It's not that scary of a topic and can accurately solve some difficult problems, albeit neural nets are quite misunderstood nonetheless (which is why I'm posting).

Edit:
If someone wants to read a little more there's a good article in game programming gems about neural networks. It uses a net to solve an in-game AI related problem. In a tanks game where an AI tank shoots at the player over a little hill given a randomized wind vector, the net solves for a pretty accurate angle of shot in order to hit the player.
« Last Edit: November 23, 2015, 10:48:18 AM by qMopey » Logged
oahda
Level 10
*****



View Profile
« Reply #15 on: November 23, 2015, 02:12:07 PM »

But when you've trained it and go on to put into your game, does it keep learning as you work on the game, and would it keep learning individually and permanently in perhaps different ways for different players on their respective machines later, or do you freeze it in a particular state after training it so that it always works the same everywhere after that?
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #16 on: November 23, 2015, 02:54:27 PM »

It's how you decide, however online learning can learn stuff you didn't anticipate and break, se generally off line learning (close brain) are used when they meet a good state. Neural network ar'ent the only learning mechanics though, q-learning and id3 tree (molyneux's black and white) too can be good alternative.

https://https://en.wikipedia.org/wiki/ID3_algorithmen.wikipedia.org/wiki/Q-learning
https://en.wikipedia.org/wiki/ID3_algorithm

But seriously utility is fine 95% of time, it's what Rainworld use to have lifelike agents (feed by other technique too).

Logged

DazeHill
Level 0
*


View Profile
« Reply #17 on: November 23, 2015, 05:43:43 PM »

Made an AI not that long ago for Toto Temple Deluxe.

There was one case where the bots bashed their head against the hard destructible blocks, not optimizing their path, it looked a bit like this:


If you want to see this image in context, here is the article talking about the AI:
http://juicybeast.com/2015/10/baby-steps-to-an-artificial-intelligence/
« Last Edit: November 23, 2015, 06:05:26 PM by DazeHill » Logged
RujiK
Level 2
**



View Profile
« Reply #18 on: November 24, 2015, 06:01:13 AM »

(I slightly changed the topic. It was a little too narrow.)

@Dazehill That is actually pretty similar to my pathfinding, but I use straight grid instead of nodes (Map is really big) and raycast like you do.

@ProgramGamer Make the video! I believe in you. I will guarantee you 1 whole like if you do.

@qMopey Thanks for all the info, I have a very limited knowledge of neural networks but you have inspired me to take a deeper look. I probably won't use it for my current project as it would essentially take a complete rewrite of what I already have, but I definitely learned something!

@Jimym GIMBERT A utility system probably sounds the easiest to implement based on the code I already have. Thanks for the tips.
Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #19 on: November 24, 2015, 08:06:34 AM »

Most utility system directly score action to take, but you can score "concept" instead and use that for other type of decidion logic (behavior tree is recommended other fsm) It will notably help fight oscillation (and keep simple because implementing stuff like inertia and stuff can be complex and unwieldy, when you can just have different appraisal in a simple fsm or behavior tree).

For example, you can group utility evaluation by nested "concept" even using the same input, "safeness" can be evaluated from "comparing" the entity hp vs the opponent ("danger") and the number of ally , then feed a "blackboard" (a structure that hold the selected concepts) which a high level resume of the situation.

Decoupling the perception and the action allow you more flexibility and better debugging.

look there for introduction
http://gdcvault.com/play/1012410/Improving-AI-Decision-Modeling-Through
http://gdcvault.com/play/1015683/Embracing-the-Dark-Art-of

NN is an uncontrollable black box, most of the time you should stay away from it for game. NN can be express as an unknown utility system.

edit:

However for a situation like the OP you would need some sort of history to model time. Maybe cumulated damage given to a target vs the hp max, the character can reason on the delta between max and the damage he has already done and maybe have "expectancy" of time to kill that score down the wilingness to keep attacking the same way.
« Last Edit: November 24, 2015, 09:39:40 AM by Jimym GIMBERT » Logged

Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic