Imperfect A.i.
#101
Posted 20 November 2009 - 02:13 AM
#102
Posted 06 January 2010 - 04:39 PM
#103
Posted 08 January 2010 - 07:35 PM
For example, if an enemy NPC had 3 choices of target, based on what it could see, it would have to look at its' target, and attempt to judge the health, speed perpendicular to itself (cross-referenced with its' own accuracy), etc. and add them up according to how valuable each piece of data is, so speed would be fairly important, as it governs wether or not the target is physically hittable. After adding up the values, it would need to compare the data with that of the other two targets; whichever target had the highest score would be the most logical to fire at.
#104
Posted 10 January 2010 - 12:06 AM
For example before shooting you'd pick a random number, if the random number is less than the difficulty level, the AI will shoot. This also provides levels of difficulty. The AI would be programmed with a "perfect game", and the difficulty would determine how close they play to the perfect game.
A difficulty of 0.1 means the AI would almost never perform a perfect choice, but a difficulty of 0.9 would mean it almost always performs the perfect choice.
In a turn based game (say, chess) the difficulty level could be a choice between using perfect chess AI, or moving a random piece to a random location.
I used this kind of approach in my last competition game (which I never really finished, but it's certainly playable) http://www.yoyogames...es/66112-zeta-1
#105
Posted 10 January 2010 - 11:35 AM
I just put in a random number before each major "decision" that an AI needs to do.
For example before shooting you'd pick a random number, if the random number is less than the difficulty level, the AI will shoot. This also provides levels of difficulty. The AI would be programmed with a "perfect game", and the difficulty would determine how close they play to the perfect game.
A difficulty of 0.1 means the AI would almost never perform a perfect choice, but a difficulty of 0.9 would mean it almost always performs the perfect choice.
In a turn based game (say, chess) the difficulty level could be a choice between using perfect chess AI, or moving a random piece to a random location.
I used this kind of approach in my last competition game (which I never really finished, but it's certainly playable) http://www.yoyogames...es/66112-zeta-1
If what I believe you're trying to say is correct, then an AI might do illogical things, like targetting a footsoldier with an RPG rather than a tank - in real life, a person wanted to fight a group of people, they might think:
"Right; who should I hit first?"
"That guy looks pretty big; I think I should take him first."
"But wait, that other guy is pretty badly injured. That'll give me an advantage, and he looks pretty easy to take out."
"Damn, that other guy has a knife. I'll have to stay clear of him."
#106
Posted 28 January 2010 - 08:40 AM
I want to object to this statement. Using this might work, but it clearly takes the illusion away, the AI won't feel realistic if it does random things - there's some mistakes NOBODY would do, and allowing anything possible to be done by the computer would allow it to make them. You know, things that makes you stare at the screen (or, sometimes, your IRL opponent) and laugh at the memory years after. What a real chess program does is that it looks a certain number of turns forward, judges all the possible outcomes from all of them (or more precisely, some of them, I guess the ones that is more valuable), and selects the move that leads to the best. On lower levels it judges a smaller distance into time, perhaps just one turn forward, compared to perhaps ten turns forwards on the highest level.In a turn based game (say, chess) the difficulty level could be a choice between using perfect chess AI, or moving a random piece to a random location.
Just gazing one turn forward, as many amateur players do, makes the computer more prone to miss plans with e.g. a tower offering, and thus more prone to trick into traps. The way of judging more and more situations ahead of time makes the computer (i mean AI, sorry) act more realistic, it seems like it's better at discovering plans before they are brought to action. Of course, pulling very unexpected moves, or moves that doesn't directly improve your "score" (which is also determined of where your units are standing) would disrupt the AI's plan, and it would try to find the best way out of the newly arisen situation instead of it's original plan. That's what happened during the famous chess matches against Deep Blue, I've heard.
#107
Posted 28 January 2010 - 05:31 PM
Remember folks, it is possible to select numbers completely at random, and yet still avoid getting results that are illogical. Perhaps it's overkill to bring the subject up again, but since it seems we're still stuck on the point, maybe I'd better...
Consider the following 2 examples of number-generation:
1) You wish to determine how well the player scores in a competition. The player's score is determined by performance, on a scale of 1-10. But, what does the computer opponent score? Surely, not a random number from 1-10. That would be far too inconsistent, and it would be impossible to add levels of difficulty to your game, since any opponent could, at any time, score a 1...or score a 10...or anything in between.
2) You wish to create a shooting game in which the computer opponent attempts to hit you. You realize that it's too hard if the AI simply calculates the exact optimal firing angle and hits you every time, so you add randomness to it. But, you can't just aim in a random direction, or even in a specific direction +-90 degrees. That would look terrible, because your opponent would be randomly shooting all over the place, not even appearing to be trying to hit you.
The solution, in both cases, is to choose a random number that has a calculated average value. So, for example, you could choose a score from one to ten, with an average of 8. Now, every number chosen will be totally random...but on the whole of things, the average of all of the randomly chosen numbers will be 8. Furthermore, almost all numbers chosen will fall relatively near 8. The numbers are still chosen randomly, but it is extremely improbable that low numbers would occur. It's just like in an actual sporting competition--it's technically possible for an athlete to get a low score, but since the athletes are all very skilled, it's unlikely that the scores will be low.
And of course, with aiming a gun, same thing. You could choose a random number for the angle to shoot, that averages the exact angle to the target. That way, it's usually not exactly on-target, but is almost always pretty close to it.
I'd posted about this at one point, long, long ago
http://gmc.yoyogames...&...t&p=1457194
#108
Posted 28 January 2010 - 11:43 PM
I want to object to this statement. Using this might work, but it clearly takes the illusion away, the AI won't feel realistic if it does random things - there's some mistakes NOBODY would do, and allowing anything possible to be done by the computer would allow it to make them. You know, things that makes you stare at the screen (or, sometimes, your IRL opponent) and laugh at the memory years after. What a real chess program does is that it looks a certain number of turns forward, judges all the possible outcomes from all of them (or more precisely, some of them, I guess the ones that is more valuable), and selects the move that leads to the best. On lower levels it judges a smaller distance into time, perhaps just one turn forward, compared to perhaps ten turns forwards on the highest level.
The problem here, is that you could end up with perfectly flawed AI. Imagine, say Chess that only looks ahead 3 spaces. Once the player works this out, they can simply plan 4 turns ahead, and would be able to defeat the AI every time. Repeat games against the AI would be no challenge. You still want the AI to be able to pick strong moves on low difficulty so that the player learns from them.
Yes, you do have to take some care in not making obviously stupid moves, for example, say you were making a fighting game. You don't want the AI to block when nobody is attacking. However, when the player attacks the AI, that's when the random number would kick in. A higher difficulty would almost always block, a lower difficulty would block less. In the chess example, I guess you could, move a piece the recommended 1 look ahead or 10 moves ahead depending on the random number. But the point is, you'd be picking between optimal, and stupid AI. This means the AI, even on lower difficulty settings, can still prove a challenge.
#109
Posted 30 January 2010 - 07:46 AM
Yes, you do have to take some care in not making obviously stupid moves, for example, say you were making a fighting game. You don't want the AI to block when nobody is attacking. However, when the player attacks the AI, that's when the random number would kick in. A higher difficulty would almost always block, a lower difficulty would block less.
You could put a short delay on when the AI realises it needs to block. This would change the concerntration level of the AI.
#110
Posted 01 February 2010 - 08:12 AM
I don't think there's a single human being that could evaluate all possible (or rather, all plausible) moves in chess for 4 turns forward, it's simply so complex. You might devise a plan for the next four turns, which efficently makes the computer one step behind, but you've still got the potential to oversee things, like move a bishop to get a good position to launch a two-piece assault, then the computer notices that your queen is suddenly possible to knock out after D4 is turned empty.The problem here, is that you could end up with perfectly flawed AI. Imagine, say Chess that only looks ahead 3 spaces. Once the player works this out, they can simply plan 4 turns ahead, and would be able to defeat the AI every time. Repeat games against the AI would be no challenge. You still want the AI to be able to pick strong moves on low difficulty so that the player learns from them.
The AI will not oversee things like that, since it evaluates a lot of possible positions for these 3 turns.
OK, we're discussing flawed AI, and and AI that cannot overlook things might not be the best suited. But, how about, giving the [turn-based game] AI orders to overlook a certain number of plausible moves, chosen randomly, each turn, before selecting the move to take? The easier level it has, the more moves it overlooks, and it will only overlook moves when no move really sticks out (each possible position on the board is ranked depending on the available units of each player, their position, and a few things like that, and by not "sticking out", I mean that no position has a score that's a lot higher than the others, like for instance the position after destroying the opponent's queen would have). So, if there's a very good move, the AI won't miss it, but it might select things that's not really the best thing to do when there's a few possible moves that's near equivalent.
Of course, chess is relatively easy to make AIs for playing, since the outcome in chess matches are in most cases decided on what player has the most units left in his troop, and the "heavy ones" like the Rook is more useful than the "light ones" that can, for instance, go just one step forward (pawn). A game like go is far more complex, and I think most "video game specific" turn based board games (tactics RPG) would require more complex AI (of course, most TRPGs doesn't have 16+16=32 units to keep track on).
Hmm... as for picking between optimal and stupid AI, the hard thing is really to balance where too less "optimality" makes the AI too stupid. I think that kind of AI, having an ultimate, but strained AI, is so common because you don't really need to pour much effort into it. After all there's multiplayer modes in most games, and people tend to prefer that one (it will, compared to the story, never really run dry), and of course: game developpers usually have very sharp deadlines, for instance 25th december, making easy solutions the common choice.
-------------
Hope this furthered the discussion, I consider myself an "intermediate".
#111
Posted 24 February 2010 - 03:11 PM
#112
Posted 19 March 2010 - 01:13 AM
For example i hade a 2D sidescroll shooter using the mouse.
You see all the monsters, so you move the mouse to their position and start clicking like hell. But then appears the surprise that you get damaged by a nearby enemy behind you, "thats more critical" you should think, then kill inmediatly that guy, i think that way in shooters so i tried to make my allies like that
My allies each one had an extra object "aim", so at their aim position they shoot. They "see" whats arround each one aim, so if theres an enemy near that position instantly aims there and hit, but when theres no enemy, aim just move vaguely in front of the direction they are heading... and when damaged than inmediatly re analyze positions of enemies to avoid touching them.
Also you can think in Fuzzy Logics, the formal form.
For example, you dont reach an enemy with your sword more than 32 pixels.
The enemy is constantly moving.
Where should you atack?
In a 1 variable (input) 2 range (output) Fuzzy Logic System, you could arrange for example
Variable: Position
Output: Not atack, atack
From 32 to 0 of distance you could think "yeah, surely atack"
From (example) 64 to inf you should think "why?"
But in the middle of 64 to 32 theres a chance of the enemy to get closer, or a way to hit him later.
So define:
Output:
1-Not atack from 32 to Inf
2- Atack from 0 to 64
So theres both, atack and not atack, between 32 and 64.
treat them as 0 to 1, and at 0.7 make this desition:
if random(1)>0.7 { atack }
And there you have randomness and failure probability, for example... atacking at 60 of distance, to away from the enemy... it has a chance of 1/16 to be performed.
Of course thats a simple example, you should also see the speed of the objective and use it.
For example, instead of looking at distance to objective, compare a variable with both compounds:
compare_var=point_distance(x,y,objective.x,objecti
ve.y)+objective.hspeed*atack_delay
(atack_delay should be aprox the time to perform the sword atack, so the enemy will be in the right place at the right moment)
#113
Posted 19 March 2010 - 01:54 AM
Part 2 some brave soul plays this AI. The AI ranks his performance. Then makes a small mutation and you play again. If he performs better, he marks the mutation as good, keeps it and makes a new one. If he performs not as good, he undoes it and does a different mutation. After many plays the AI is getting better and better.
If this were possible it could be used to make an AI get better at fighting the players style so the game would get harder on its own and force you to look for new styles. Or it might be use as a tool for a builder to find good strings for certain situations.
Assuming its all plausible it might make a pretty cool AI.
#114
Posted 19 March 2010 - 07:29 AM
#115
Posted 19 March 2010 - 07:32 PM
When it rates it's performance if it goes over some number it still doesn't keep it, in order to keep the AI from getting to good too fast (which I don't think it could)
#116
Posted 21 March 2010 - 06:36 PM
You make an action with N number of variables. The result will be stored with those N variables, in a table for example.
Each new experience will be stored.
When a desicion is going to be done, the AI will use those information to evaluate.
The force of a previous experience on a new one will depend on the "distance" between both.
For example with just x and y
You go to 50,50 and you get hurt. This could be archived like 50-50-(-10) <-bad
So you go to 100,240 and you get healed. so... 100-240-(+5) <-good
So in a new experience, in x,y you need to evaluate (this is a basic form)
sum of ( 1/Distance(x,y to array_x[i],array_y[i])*array_val[i] )
So if you were going to 55,55(near hurt). In the evaluation you get: 1/(-70.71)+1/(982.34)=-0.014+.001= -.013 (x1000 = 130neg -> bad idea)
(well, try with diferent ways so avoid pretty small numbers)
If you are going to 200,200(far) you got: 1/(-2121)+1/(538) = (-0.47+1.858)/1000 = 0.000811 (x1000= 0.811-> non significant)
going to 80,250(near heal) you got: 1/(-2022)+1/(22.36) = (-0.49+44.7)/1000 -> 44.21-> good idea
Also need to consider time value, i mean... for example that "heal" could be food, but maybe it was just an apple, the second time there will not be an apple. So also multiply for a factor to count this, like forgoting... depending on number of experiences, or devaluating depending on time of that experience)
Edited by CalixJumi, 25 March 2010 - 05:13 AM.
#117
Posted 23 March 2010 - 11:33 AM
#118
Posted 13 July 2010 - 11:45 PM
#119
Posted 23 July 2010 - 06:43 PM
The AI is presented with a good and a bad food. It will choose which food to eat based on it's AI type.
Type 0
These are 'conventional' AI. They can see everything, and make flawless calculations every time. Exactly what we don't want.
With the food scenario, this AI would eat the good food. It would always eat the good food.
Type I
These AI are exactly the same as type 0, just their behaviour is determined using random factors.
With the food scenario, this AI would eat the good or the bad food, based upon an abritary random variable.
Type II
These AI are learning AI. They seem curious about the world around them , and make decisions based on the fates of others and themselves
With the food scenario, this AI would see if it recognised the food, and make the decision based on the previous knowledge.
Type III
This AI is inottave (how do you spell it) and comes up with solutions to problems based on the fates of others and themselves.
With the food scenario, this AI would find a way to test the food before eating it.
Edited by holomanga, 23 July 2010 - 06:50 PM.
#120
Posted 21 August 2010 - 06:28 AM
but there could be another type.
Type 0
These are 'conventional' AI. They can see everything, and make flawless calculations every time. Exactly what we don't want.
With the food scenario, this AI would eat the good food. It would always eat the good food.
Type I
These AI are exactly the same as type 0, just their behaviour is determined using random factors.
With the food scenario, this AI would eat the good or the bad food, based upon an abritary random variable.
Type II
These AI are learning AI. They seem curious about the world around them , and make decisions based on the fates of others and themselves
With the food scenario, this AI would see if it recognised the food, and make the decision based on the previous knowledge.
Type III
This AI is inottave (how do you spell it) and comes up with solutions to problems based on the fates of others and themselves.
With the food scenario, this AI would find a way to test the food before eating it.
Type IV
This one is interestingly enough, a bit like a teenager. if all of the other AI are eating the bad food, then peer pressure comes into play, and our new AI would only eat bad food, regardless of its own fate. this one is simply a follower of the AI around it. once the other AI start to eat the good food, our type IV would continue to eat the bad food for a while, until it realises that everyone is eating good food.
another is Type V
like type IV, except it would rate which AI seems smarter and follow that one. e.g. if there was a Type 0 and a Type I AI, the Type V AI would follow Type 0, because they were eating more good food on average.
maybe this could work.
Edited by serverplatform, 21 August 2010 - 06:29 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











