Programming AI

A forum to store posts deemed exceptionally wise and useful
Post Reply
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Programming AI

Post by roxaz »

This might be very useful for you :)

Link removed by moderator

examples from the book (sources abd binaries):
www.wordware.com/files/ai




**Moderator Edit**
Unless you have permission from Wordware Publishing, Inc you can't distribute the entire book.
franklyn
Posts: 36
Joined: Thu Mar 15, 2007 7:03 pm

Post by franklyn »

isnt that illegal ?
jam
Posts: 409
Joined: Fri Nov 04, 2005 3:52 am

Post by jam »

A few sample chapters are available over on the author's website.

http://www.ai-junkie.com/books/toc_pgaibe.html
system-independent, adj.:
Works equally poorly on all systems.
-- unknown
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

i just wanted to help :roll:
franklyn
Posts: 36
Joined: Thu Mar 15, 2007 7:03 pm

Post by franklyn »

hehe. well we definitely appreciate it.
are you working on ai atm ?
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post by dejai »

Hmm, where could I "purchase" this novel...

JJ But really were is or what is this thread about??
Programming Blog: http://www.uberwolf.com
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

dejai wrote:Hmm, where could I "purchase" this novel...

JJ But really were is or what is this thread about??
You can buy it with the link in the first post. Its right at the bottom of the page.
Frodenius
Posts: 64
Joined: Sun Aug 29, 2004 11:24 am
Location: Germany/Frankfurt
Contact:

Post by Frodenius »

hey roxaz if you wouldnt mind you could knowingly commit a crime and pm me your link, im a poor student and interested in ai game programming... i could eventually accept this crucial lapse with a heavy heart.. ;)
worst programming style ever seen...
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

You don't need the book Frodenius. Come on AI is just common sense in my opinion. Besides there are millions of articles for you on gamedev.net about A*, etc etc.
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

Yes there are even A* libraries such as this one http://www.grinninglizard.com/MicroPather/index.htm to help you along as well.

AI is really a bunch of decision making if statements.

For example if you want a monster that runs at your character and explodes your AI is something like this:

Code: Select all

if(monster->isAlive())
   if(moster->canSeePlayer())
   {
      if(player->getPosition.X() < monster->getPosition.X())
         monster->moveXNegative();
     else
        monster->moveXPositive();
     if(player->getPosition.Z() < monster->getPosition.Z())
         monster->moveZNegative();
     else
        monster->moveZPositive();
     if(monster->getPosition.X() - player->getPosition.X() < 10 || 
          monster->getPosition.X() - player->getPosition.X()  > -10)
          if(monster->getPosition.Z() - player->getPosition.Z() < 10 || 
             monster->getPosition.Z() - player->getPosition.Z()  > -10)
             if(monster->getPosition.Y() - player->getPosition.Y() < 10 || 
                monster->getPosition.Y() - player->getPosition.Y()  > -10)
                monster->explode();
   }
Its simple, like writing out a thought process.
Katsankat
Posts: 178
Joined: Sun Mar 12, 2006 4:15 am
Contact:

Post by Katsankat »

The word terrorist would fit well, instead of monster.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

I would recommend you to leave it monster ...else somebody may come with idea of spreading war against terrorism to your code. You dont want to se Toronto be bombed by F15s and Tomahawks, do you? :wink:
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Post by kornwaretm »

sorry i'm indonesian
this code rotate each actor to face their closest target, but stil got some trouble, may be because i haven't read all about matrixes

Code: Select all

void runAi(actor* head){		
			float jarak,dX,dZ,sudutTarget,sudutSekarang;
			core::vector3df pos1,pos2,rot;
			int attack;
			float tambahan;	
			bool attackAble =false ;

			if(Live>0){
				if((target==NULL)||(target->Live<1)){
					pickTarget(head);
					resetControl();
					//printf("id : %d cari musuh %d\n",id,&target);
				}else{
					pos1	= node->getPosition();
					pos2	= target->node->getPosition();
					dX		= pos2.X-pos1.X;
					dZ		= pos2.Z-pos1.Z;
					if(pos2.Z>pos1.Z){
						dZ	*= -1;
						dX	*= -1;
						tambahan = 180;
					}else{
						tambahan = 0;
					}
					jarak			= sqrt(dX*dX+dZ*dZ);					
					rot				= node->getRotation();
					sudutSekarang	= rot.Y;
					sudutTarget		= atan(dX/dZ);
					sudutTarget		= sudutTarget*180/3.14;	
					
					if(sudutSekarang+10 < sudutTarget+tambahan){
						input->turn = 3;
						attackAble=false;
					}else if(sudutSekarang-10 > sudutTarget+tambahan){
						input->turn = -3;
						attackAble=false;
					}else{
						attackAble=true;

					}

					if(jarak>20){
						input->accelerate=2;
					}else if((jarak<=20)&&(jarak>10)){
						input->accelerate = 1;					
					}else{
						input->accelerate=0;
						if(attackAble){
							input->turn = 0;
							if(target->Live>0){
								input->speedAttack = true;							
							}else{
								input->speedAttack = false;								
							}
						}
					}
				}
			}
		}
i assume even if the ai to control the it self it throug a class thal i call the input class.
Post Reply