Lost universe of Programing
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Lost universe of Programing

USERNAME :- Forum Post:-114
 
HomePortalGalleryLatest imagesRegisterLog in

 

 Artificial Intelligence using basic geometry

Go down 
AuthorMessage
Er Amit Tripathi

Er Amit Tripathi


Male
Number of posts : 37
Age : 38
Location : Lucknow
Job/hobbies : Software Engeener
What U like To do ? : I Rocks With Computer System.
Registration date : 2008-01-09

Artificial Intelligence using basic geometry Empty
PostSubject: Artificial Intelligence using basic geometry   Artificial Intelligence using basic geometry I_icon_minitime5/8/2008, 1:44 am

Welcome, Artificial Intelligence can be implemented in many different ways but today I will be covering an form of AI that will allow you to calculate distances between sets of objects that can be useful for whether or not an NPC is given permission to shoot an enemy or the player.
The geometry we will be covering is mostly consisted of Analytic geometry following the basic principles of the Cartesian coordinate system. We will modify the 2D Distance Geometrical Distance formula to calculate the distances of 3D Objects later on in the tutorial...
Our first step will be to write our basic C++ code. Then our next step will be to implement the formulas into our code and then calculate the distances and preform the set routines. Please note: I am not covering ways to retrieve the X,Y,Z values of your game objects so that is up to you.
First , to understand the code itself let us take an look at the geometrical 2D Distance formula...
load link to view 2D Formula Image http://upload.wikimedia.org/math/7/0/f/70f21f8d56472663b4a3daf55117b78c.png
Translation:
distance = DeltaX2 - DeltaX1 sqrd + DeltaY2 - DeltaY1 sqrd SQRT
If you read the formula, you should understand the code I wrote with no problem at all.
Demonstration Code: (* Full Source *)
#include
#include
long calculate_2D(long x1,long x2, long y1, long y2);
long sqrd(value);
using namespace std;
int main()
{
cout<<"Calculating the displacements of: X1=3.5,X2=6.7,Y1=9.8,Y2=1.4"<
Back to top Go down
http://www.aspx.forumotion.com
 
Artificial Intelligence using basic geometry
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Lost universe of Programing :: --=| SOURCE CODE |=-- :: C/C++ SOURCE CODE-
Jump to: