Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: 1 [2]   Go Down

Author Topic: Artificial Intelligence  (Read 6833 times)

0 Members and 1 Guest are viewing this topic.
Re: Artificial Intelligence
« Reply #20 on: May 02, 2006, 02:38:21 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
AI usually chooses a coded set of instructions based on enviroment, player distance, etc - a lot of other factors coded by the programmer. These are called states. The main problem with AI is that the kinds of factors that would influence a normal human's decision making are infinite; the AI can't take other things into account.
Thank you for pointing what has already been stated out, Scooter. Please, we've already established this a while ago, if you're going to post in a thread, make sure it hasn't already been said... And my guess is that what you posted you learned from what you READ in this topic -_-

Also, yes, humans can do an infinite number of things, however, there are only SOME things that would be the right thing or the smart thing to do. If you notice your enemy limping away, trying to escape, and he has no cover, a human could do any number of things. The only SMART thing to do there would be to shoot him.
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: Artificial Intelligence
« Reply #21 on: May 03, 2006, 02:29:38 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1635
Quote
And my guess is that what you posted you learned from what you READ in this topic -_-
If I'd have read it in this topic, I wouldn't have posted it. I apparently didn't read through careful enough, so I'm sorry for posting what was already mentioned, but I know plenty about AI. I didn't just copy what others said. But I'd rather pull out before this turns into an argument.

Logged

aab

^ Evolved from a Hobbit
Re: Artificial Intelligence
« Reply #22 on: May 03, 2006, 04:59:49 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 992
...A closed subset of the infinite number of inputs (though in reality a game environment would have a finite number of meaningfull inputs, of which only some are usefull), and a closed set of outputs (Not just what would be the smartest thing) eg: virtual stupidity, an enemy thats been shot several times might not be in the right state to make a perfectly smart action, though sometimes they may be => random interaction (one of the more obvious components of creating ai that simulates the  far too complex to implement  biological variety in each of any species relative to the next ).
Logged




I ♥ Sol
.... I ♥ Sol ? wtf how long has that been there? >_> *rrrrrrrrar*
  • MySpace
Re: Artificial Intelligence
« Reply #23 on: May 03, 2006, 08:37:17 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Yes, the state of mind system would actually work pretty decently, and you could create varied NPCs (be they monsters, enemies, etc) by specifying different statistics (such as Tactics, morale, how easily frightened they are, etc.), and use those to determine behavior.
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: Artificial Intelligence
« Reply #24 on: May 07, 2006, 01:51:52 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 4588
I drew up a map of Halo 2 Elite AI... I was bored.

int Distance; //Mathematical Calculations
bool Checkpoint; //Checkpoint reached
int masterChief; //0 - Stand; 1 - Walk; 2 - Grenade; 3 - Jump;

if (Checkpoint) //Most elites start moving if the player reaches a checkpoint, then the AI kicks in.
{
if (Distance <=900) //Distance. I guessed :/
{
switch (masterChief) //Master Chief's status.
{
case 0: //Start/Continue shooting; DIR Checks. Don't move; break;
case 1: //Start/Continue shooting; DIR Checks. Follow; break;
case 2: //Random direction of rolling. The random value would have been pre-seeded...; break;
case 3: //Lift the gun, of course =); break;
default: //Walk to last known position of MC.
}
}
}

Of course, I didnt put Mathematical formulas, collision checking, and the pre-defined values (or changing values). That was all a guess. You get the idea, yea >_>. Ai that plain just doesnt work. It needs more brains! More human reflexes, etc.

Commenting on my incomplete guess above = death ;).
Logged
the a o d c

SwordsGateSCAS

Re: Artificial Intelligence
« Reply #25 on: May 19, 2006, 10:12:19 am »
is there any good exmples of enemys examples out there
personal i find it hard to make a enemy
i can make the enmey easy but to make
but to make it hard to guess what there about to do is hard
i guess you give them a hell lod of events then it could get harder to guess there movement
Logged
Re: Artificial Intelligence
« Reply #26 on: May 21, 2006, 03:28:09 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1141
I've just had an idea, for a more realistic AI.

Imagine the following code:

>If hears a sound behind
>Look back
>Watch for 5 seconds
>If sees something strange
>React
>Else
>Look back

However, if we have a variable "anger", the number of seconds to be waited may increase, or if we had a variable "rush", the number of seconds may be diminished. So if the enemy has to turn back many times, its anger may increase to make the AI change every time. And the same for all the other human feelings like "happiness", "frustration" or "fear".
Logged
Re: Artificial Intelligence
« Reply #27 on: May 21, 2006, 09:59:24 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 150
I thought I'd share the AI routines I've been working on for my game. A lot of the Diablo 2 AI routines have been dissassembled, so I tried to create an AI scripting system that could easily replicate all of the Diablo 2 routines. I also strived to create a system that would require as few commands as possible, since interpretting scripts in my game is about 100x slower than compiled code.

Each script can accept up to 8 parameters (par1 ~ par8).

Skeleton: When an enemy comes into vision range of this AI, it has a chance to approach the enemy in increments of 5 steps until it is within melee range. If in melee range, it has a chance to attack.
Code: [Select]
SKEL:
lbl TOP
delay par2
tEnemy 0 0
if target = 0 TOP
if distance > 2 APPROACH
chance par3 TOP //chance to attack
chance par4 ATTACK1
melee2
goto TOP
lbl ATTACK1
melee1
goto TOP
lbl APPROACH
chance par1 TOP
approach 5
goto TOP

Zombie: This AI wanders randomly until it comes into sight of an enemy. If par1 succeeds, the zombie will approach the enemy unit. Once it reaches melee range, it will always attack.
Code: [Select]
ZOMB:
lbl TOP
delay par2
tEnemy 0 0
if target = 0 WANDER
if distance > 2 APPROACH
chance par4 ATTACK1
melee2
goto TOP
lbl ATTACK1
melee1
goto TOP
lbl APPROACH
chance par1 TOP
approach 5
goto TOP
lbl WANDER
wander 3
goto TOP

Bighead: as long as this AI's HP is above the threshold defined by par1 it will approach the target (unless par3 rolls succesfully, in this case the AI will shoot a missle rather than approaching), once the target comes within melee range the AI will always attack. However, when the HP is below the threshold, the AI will run away from melee range and barrage the arget from a safe distance.
Code: [Select]
BIGH:
lbl TOP:
delay 3
tEnemy 0 0
if target = 0 TOP
if hp < par1 LOWHEALTH
if distance > 5 MISSLEATTACKHEALTHY
melee1
goto TOP
lbl MISSLEATTACKHEALTHY
chance par3 APPROACH
ranged1
goto TOP
lbl LOWHEALTH
if distance < 5 RUNAWAY
goto MISSLEATTACKINJURED
lbl RUNAWAY
flee 5
goto TOP
lbl MISSLEATTACKINJURED
chance par4 TOP
ranged1
goto TOP
lbl APPROACH
approach 5
goto TOP

This system is wonderful because by modifying the input parameters, different AI's can easily be simulated: a Skeleton with a high par1 will take long delays between each action, making it easy, whereas a skeleton with a low par1 will rush quickly towards a player and waste no time between attacks.

In the future, I'll also have AI's that will respond differently to mages and ranged targets (the tEnemy command has two inputs, which determine the desired targetting type (whether it is more likely to attack ranged, melee, magic, most hated enemy, most damaging, support class, etc),  and the targetting bias (how likely is it to ignore its preferred targetting type). This provides for a more varied style of play than you might find in World of Warcraft: perhaps there's an enemy that actively hunts down your healers before turning on the damage classes...?

Not that my game has anything like a healer class. But still. =P
Logged

aab

^ Evolved from a Hobbit
Re: Artificial Intelligence
« Reply #28 on: May 21, 2006, 11:40:34 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 992
nice and simple: As it should be.
What do you think about (for more complex enemies) an ai system where the enemy has a script for each state, and each state can change what state it will be used during the next update, based on setting a condition (of course). State scripts themselves would call function scripts that are shared and accessible by many ai types.
There wouldnt be as much seeking throughout the single script, though there'd be more scripts  to handle.
The state to choose would obviously be the target update through an array of course ... No switching statements.
There would of course be command to immediately exit a script.
The thing with that however is how to handle the 'shared' scripts efficiently. The bytecode translator could make a seperate context record (storing the required shared scripts to use) to be associated with that script: Entering areaX, go through the context codes for all enemy types within areaX, and load the used shared scripts (called from an array, accessed by mapping the index that the ai script refers to each shared script by to the currently loaded shared scripts integer index). But that would be messy when dealing with a large dynamic world spawning enemies like yours Fish.
What to do lol...
Keeping all the shared scripts in memory would be lazy, and calling them at enemy spawn would be terrible. The world could be divided into sections with suitable transition borders, and each sector has a record of the scripts expected to be loaded while the player is in it....
Anyone any better ideas?
Logged




I ♥ Sol
.... I ♥ Sol ? wtf how long has that been there? >_> *rrrrrrrrar*
  • MySpace
Re: Artificial Intelligence
« Reply #29 on: May 22, 2006, 06:29:15 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 150
Oh, no, it wouldn't be complicated at all! Here's what I would do to simulate the ability to call scripts at runtime, like your suggestion:

My script system already mimics a simple CPU, with two math registers (A and B), the status register (F), and the program counter (PC). If you want one AI to be able to call another AI, you would have to treat each different AI state routine just as a normal compiler would treat different routines in a program. Thus, you would need to add a stack, and a stack pointer (SP). Whenever you call another AI state///routine, you would simply push the current PC value onto the stack, and then set the PC to the beginning of the new state (a jump command).

The following syntax will be different from the one I've already posted, to make it more readable.
Code: [Select]
SKEL_IDLE:
lbl TOP
tEnemy 0 0
if target <> 0
call SKEL_ATTACK
end if
goto TOP

SKEL_ATTACK:
if distance > 3
approach 5
else
melee1
end if
return
Would compile into something like this:
Code: [Select]
//entry point for SKEL_IDLE: instruction # 0
//since this is the base routine, there is no need to save registers.
//lbl TOP, instruction # 0
00: tEnemy 0 0
03: move A target //set register A = target
06: compare A 0 //the simulated cpu compares target and 0, and stores the result of the compare in the status register
09: jump_equals 21 //use the reverse of the operation as the compare. If the compare operator equals 0, then skip the next lines.
11: set A PC //set A = PC
14: add A 5 //add 5 to A, so that the value of the stored PC will skip the store instruction and the set instruction.
        //Otherwise, when we pop the PC from the stack, it will enter a loop and never exit.
        //The amount of instructions in a push + set instruction = 5
17: push PC //save the PC to the stack
19: jump 24 //move to the next routine
21: set PC 0 //goto TOP

//entrypoint for SKEL_ATTACK: instruction # 24
24: push A //save A, as we will use it in this routine
26: move A distance //copy distance into A
28: compare A 3
31: jump_lessthan 37 //if A is less than 3, jump to  melee attack
33: approach 5 //else ignore the jump and simply approach a maximum of five steps
35: jump 38 //now jump to the end of the routine
37: melee1
38: pop A //restore A
40: RET //return to the calling sub (i.e. pop PC)

Thus, by simply adding all the scripts together into a megaprogram and popping and pushing the PC, just like a real program acts, we can move between different AI states, without maintaining a list of AIs, or using select case statements!

Of course, as long as you're adding a stack and stack pointer, you might as well give the AI some memory to work with... nothing fancy, just 16 or 32 words worth of scratch memory to store previous targets and whatnot. But every time you add a new feature to the scripting system, the script interpretter slows down a bit. Thus, I want to keep my AI interpretter as simple and FAST as possible. Meanwhile, my Interface scripting system has enough features to implement checkers (which I've already done, although I'm not sure how to go about programming an AI for the checkers, so you can only play with yourself... =D).

What do you think, aab? Did I cover your question? =)
« Last Edit: May 22, 2006, 06:33:12 am by FarFromHomeFish »
Logged

aab

^ Evolved from a Hobbit
Re: Artificial Intelligence
« Reply #30 on: May 23, 2006, 05:42:28 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 992
Yeah, pretty much.
As long as ai can call their own scripts, they can share, and allow larger ai's to be spilt into seperate files (or virtually if theres an inclusion feature)
And as long as the states can be nicely written in seperation as you have shown, it gives a finite state impression, which was the origin of my posts ideas (an implementation which is easily mapped from design, such that it can be made, explained, modified and documented easily).
Logged




I ♥ Sol
.... I ♥ Sol ? wtf how long has that been there? >_> *rrrrrrrrar*
  • MySpace
Re: Artificial Intelligence
« Reply #31 on: June 02, 2006, 01:27:19 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 2890
I've been working on a bit of a "conversation program" in BlitzMAX recently. Yes, I got a bit lonely and wanted my computer to talk to me :'(... I currently got up to an appropriate greeting, asking and remembering the user's name, a bit of talking and replying, just a ton of responses linked up to many more :P. It was pretty intelligent. I couldn't teach it anything, but I might still have the thing's source on my PC, if I didn't accidentally delete it :(.
Logged
Re: Artificial Intelligence
« Reply #32 on: June 02, 2006, 08:41:55 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1141
I've been working on a bit of a "conversation program" in BlitzMAX recently. Yes, I got a bit lonely and wanted my computer to talk to me :'(... I currently got up to an appropriate greeting, asking and remembering the user's name, a bit of talking and replying, just a ton of responses linked up to many more :P. It was pretty intelligent. I couldn't teach it anything, but I might still have the thing's source on my PC, if I didn't accidentally delete it :(.
I've tried it once, but the result was a program that memorizes word-by-word everything you tell him... The most perfect way to do it would be the program to make a syntatic analysis of everything you type, so that it can understand what you say and associate them to new facts. The problem is that the English language has a complex syntax and makes such a program even more difficult to program.
Logged
Pages: 1 [2]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.242 seconds with 64 queries.