 Lost universe of ProgramingUSERNAME :- Forum Post:-114     Lost universe of Programing :: --=| SOURCE CODE |=-- :: C/C++ SOURCE CODE Share

# Artificial Intelligence using basic geometry AuthorMessage  Number of posts : 37
Age : 33
Location : Lucknow
Job/hobbies : Software Engeener
What U like To do ? : I Rocks With Computer System.
Registration date : 2008-01-09  Subject: Artificial Intelligence using basic geometry 5/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 SQRTIf 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"<_________________""»-(¯`v´¯)-»"Er Amit Tripathi"»-(¯`v´¯)-»"     Artificial Intelligence using basic geometry Page 1 of 1
 Similar topics » Ten Basic Checkmates to Know
» Visual Basic Chess
» Israeli chess program check-mates the masters
» HashTable Calculate
» Marking red and green (basic in tuning a ctg book)

Permissions in this forum:You cannot reply to topics in this forum Jump to: Select a forum||--WRITE YOUR PROBLEM IN ANY TECHENOLOGY|----=| SOURCE CODE |=--|   |--C/C++ SOURCE CODE|   |--CODE FOR C# & ASP.NET|   |--CODE FOR JAVA|   |--DATA BASE MANAGEMENT|   |--VB 6.0 Code|   |--VB.NET CODE|   |--Java Script and Html|   |----=| TUTORIALS |=--|   |--TUTORIALS FOR MESSENGER|   |--JAVA|   |--ETHICAL HACKING & NETWORKING|   |--TOOL & TIPS|   |--MOBILE RELATED|   |----=|WINDOWS|=--    |--WINDOW VISTA Problem    |--WINDOW XP Problem    |--Software Discription