Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / !BEST A.I. TECHNIQUE EVER!

Author
Message
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 19th Nov 2002 22:39
A.I.

To some people the word is evil...to others its creation and manipulation is impossible...for me...EASY!

I always look at source code such as the ones included in DarkBASIC and wonder why do they have to be so complex for only a few objects...the A.I. in those games would be very hard to manipulate when you want to create a huge game such as Zelda...in Zelda you must constanlty creat monsters and destroy them and so on...which is why I tested my theory of Game Design A.I.

Functions

My theory which has proven positive gave me great power that would otherwise be not only complex but nearly impossible... Let me take you through the steps that I used...We only need a MINIMUM of two functions...on to creat a monster and another for A.I.

Create_Object_Goblin(n,x,y,z)

This function shall create a goblin n and will be positions at x,y,z (put 0,0,0 if you don't want to position it now). In it you shall append all animation data...set default values if any (in arrays for example you can store HP or something) and set its default properties (wireframe, animation speed, ect.). My example:


Function Make_Goblin(n,x,y,z)
Load Object "Idle.x",n
Append Object "Crouch.x",n,100
Append Object "Walk.x",n,200
Append Object "Attack.x",n,300
Append Object "Die.x",n,400
Scale Object n,200,200,200
Yrotate Object n,180
Fix Object Pivot n
Position Object n,x,y,z
Set Object Speed n,25
Set Object Interpolation n,25
Endfunction

you can add more paremeters in order to store non-default data if you wish.

AI(n,x)

This simple function is the "meat" of the game...the most important piece you'll ever use. n would be the object number you wish to "AI" at the moment and y is the AI you want (goblin, bug flying around a flower, lil stupid dog that runs away from you, please not AI will not configure your animation data). For example:


Function AI(n,x)
If x=1
mX#=Object Position X(n)
mY#=Object Position Y(n)
mZ#=Object Position Z(n)
bX#=Object Position X(101)
bY#=Object Position Y(101)
bZ#=Object Position Z(101)
If Sqrt((mX# - bX#)^2 + (mY#+25 - bY#)^2 + (mZ# - bZ#)^2) 100
oX#= Object Angle X(n)
oY#= Object Angle Y(n)
oZ#= Object Angle Z(n)
Point Object n,bX#,bY#,bZ#
Rotate Object n,oX#,Object Angle Y(n),oZ#
Move Object n,5
pX#= Object Position X(n)
pZ#= Object Position Z(n)
Position Object n,Object Position X(n),Get Ground Height(1,pX#,pZ#),Object Position z(n)
If Object Frame(n)200
If Object Frame(n)300
If Object Frame(n)
If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 19th Nov 2002 22:43
The forum messed my code up...wawawawaWA! and I wrote alot more...it cut me off...

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 19th Nov 2002 22:45
A.I.

To some people the word is evil...to others its creation and manipulation is impossible...for me...EASY!

I always look at source code such as the ones included in DarkBASIC and wonder why do they have to be so complex for only a few objects...the A.I. in those games would be very hard to manipulate when you want to create a huge game such as Zelda...in Zelda you must constanlty creat monsters and destroy them and so on...which is why I tested my theory of Game Design A.I.

Functions

My theory which has proven positive gave me great power that would otherwise be not only complex but nearly impossible... Let me take you through the steps that I used...We only need a MINIMUM of two functions...on to creat a monster and another for A.I.

Create_Object_Goblin(n,x,y,z)

This function shall create a goblin n and will be positions at x,y,z (put 0,0,0 if you don't want to position it now). In it you shall append all animation data...set default values if any (in arrays for example you can store HP or something) and set its default properties (wireframe, animation speed, ect.). My example:


Function Make_Goblin(n,x,y,z)
Load Object "Idle.x",n
Append Object "Crouch.x",n,100
Append Object "Walk.x",n,200
Append Object "Attack.x",n,300
Append Object "Die.x",n,400
Scale Object n,200,200,200
Yrotate Object n,180
Fix Object Pivot n
Position Object n,x,y,z
Set Object Speed n,25
Set Object Interpolation n,25
Endfunction

you can add more paremeters in order to store non-default data if you wish.

AI(n,x)

This simple function is the "meat" of the game...the most important piece you'll ever use. n would be the object number you wish to "AI" at the moment and y is the AI you want (goblin, bug flying around a flower, lil stupid dog that runs away from you, please not AI will not configure your animation data).

There may be some let-backs though...

For example: since there are no global arrays or variables you can't expect to use an array or variable outside of the function to work inside the function...I'm not sure but you can probably use MEMBLOCKS... I'm not sure if their global though...I sure hope so.

Any questions, comments, suggestions, or ideas about my new AI system?

If you want a free source code example then post your emails and I'll get back to you...

Thanx for reading

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 19th Nov 2002 22:48
* where I put y I meant x...

using the A.I. function you need to do something like


If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
QuothTheRaven
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 20th Nov 2002 14:47
...what about...object collision?
CD On CD
21
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United States
Posted: 20th Nov 2002 18:42
TGWDNGHN:

though it may be some time before i'm ready for it, i'd be interested in seeing the source (i learn much more by seeing)

sendto: cdoncd@cdoncd.com

thanx a bunch

United We (Still) Stand
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 20th Nov 2002 22:42
My technique will handle all...including object collision...But I msut say that I realized something very disapointing...since Functions ONLY use local variables,arrays, memblocks, ect That you should make my AI function a label instead... just change the n value (or whatever value you use...the object you wish to AI)...


If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 20th Nov 2002 22:46
oh yea...almsot forgot...Cd on Cd... I'm going to send you my latest code AFTER I see if it works as a subroutine rather than a function...you see...my Make Monster command works...cause you really don't need global variables but in this case...useing my technique of course, ANYTHING THAT INVOLVES A VARIABLE OUT SIDE OF A FUNCTION OR ANYTHING THAT ONLY USES LOCAL VARIABLES (only) SHOULD BE A SUB-ROUTINE.
anything else? (I'll keep you "infoed" on my proggress )

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 21st Nov 2002 01:09
why dont u consider global arrays that work through functions in multiple instances

TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 21st Nov 2002 01:39
how do you make them global? I already spent all the work making it a subroutine! (but i still have the function files )

I have a MAJOR PROB in y example that I'm going to distrbute...

The goblin (object 1) is supposed to die whenever it gets hit by a bullet (objects 101-110)...but it only responds to collisions iwth object 101...I did a for loop like this...
For z=101 to 110

the memblock thing...AIP is object 1....the goblin...the memblock 1,AIP tells me if its dead or not...the Memblock 1,2 tell me which bullet killed it...for testing purposes of course...but it turns out ONLY object 101 can kill it...why?!

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Nov 2002 05:39
dim myarray(1)
myarray(1) = 456789


do
display()
sync
loop


function display()
print myarray(1)
endfunction

TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 24th Nov 2002 23:25
> thanks for showing me useless info that I told you in my posts that I knew how to do! now try answering my Q!

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 24th Nov 2002 23:46
Arrays that are declared outside functions are always global. That's what indi's example shows.

Ogres have layers.
Bighead
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location:
Posted: 24th Nov 2002 23:53
Why don't you try to check separately a collision with one of the other bullets, say, nr. 105? So, if this bullet hits the gobbling and kill him then the problem is in the for/next loop conditions.

If not, then display the content of the "Memblock Byte 1,2" on the screen at the end of the if statement? That way you can see the value stored by the "Write Memblock Byte 1,2,z" when a collision happens.

Then, when any of the objects (>101) hits the gobblin you can verify whether the z value was well written to the memblock or not. If not, then the problem is in another part of the whole script.
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 25th Nov 2002 03:21
Puffy
21
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United States
Posted: 25th Nov 2002 08:30
" > thanks for showing me useless info that I told you in my posts that I knew how to do! now try answering my Q! "
at least indi helped you >=( dont get pissy...

AMD Athlon XP 2100+ OC to 3Ghz/1.5gigs ram/128mb ti4200/120gigs hd/19" monitor/Sound Blaster Audigy Platinum EX/2.5mbs Sat Con... I joined in!
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 27th Nov 2002 04:07
sorry 'bout that...I always type like that so get used to it...but it is logicasl that if th For-Loop is the prob to do them individualy...or perhaps a do-loop that I cvan break out if...thanks 'yall...I'll keep you'll updated...

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
Puffy
21
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United States
Posted: 27th Nov 2002 11:37
at least what i do... i dont know if you do this... ill skim over a few of em... read the last one posted... and reply based on that... maybe he skipped part of it...

AMD Athlon XP 2100+ OC to 3Ghz/1.5gigs ram/128mb ti4200/120gigs hd/19" monitor/Sound Blaster Audigy Platinum EX/3072kbs Sat Con... I joined in!
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 27th Nov 2002 18:37
lol...I just type ruff, thats all...but I like the idea of them seperate...it might fix the prob...

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
CD On CD
21
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United States
Posted: 27th Nov 2002 19:17
TGWDNGHN:

did we ever get this as a final?
you were gonna email it to me,,,remember?

thanx

United We (Still) Stand
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 27th Nov 2002 19:54
I know...I'll e-mail it to you once I fix the prob as I said in a post long ago in a galaxy far far away...
I'm almost done with it so hold on yo ur horses! THNX for waiting patiently

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
TGWDNGHN
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 30th Nov 2002 04:07
Bad news...the If and Do-Loop didn;t fix the prob with collisions...I really need to see wtf is going on...

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!

Login to post a reply

Server time is: 2024-04-19 00:25:30
Your offset time is: 2024-04-19 00:25:30