Programming AI
Programming AI
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.
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.
A few sample chapters are available over on the author's website.
http://www.ai-junkie.com/books/toc_pgaibe.html
http://www.ai-junkie.com/books/toc_pgaibe.html
system-independent, adj.:
Works equally poorly on all systems.
-- unknown
Works equally poorly on all systems.
-- unknown
Hmm, where could I "purchase" this novel...
JJ But really were is or what is this thread about??
JJ But really were is or what is this thread about??
Programming Blog: http://www.uberwolf.com
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:
Its simple, like writing out a thought process.
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();
}
-
- Competition winner
- Posts: 189
- Joined: Tue Oct 16, 2007 3:53 am
- Location: Indonesia
- Contact:
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
i assume even if the ai to control the it self it throug a class thal i call the input class.
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;
}
}
}
}
}
}