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.

Author
Message
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 29th Sep 2003 11:45
I know everybody needs it, so I'll ask for it. I'm really in need of some AI code and I know some people can do it. I'd like to make a sort of strategy game like commandos, x-com or syndicate. I need some basic code and some suggestions on other methods if possible please.

Thanks in advance for any help at all.

"It's amazin' what you can do with a computer and access to t'internet"
Kentaree
23
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 29th Sep 2003 20:30
Uhm, sorry for saying this, but you can't just ask for AI. AI is a broad area, and for games you usually only need a very small part of it. I'd suggest for anyone whose going to do AI to map out EXACTLY in plain English what you want the particular character/object to do.

For example, lets use the relatively simple example of an object chasing another object. The chasing object would have to:

Look at the other object.
Move towards the other object.
If there's an obstacle in the way, calculate the fastest route around it.

This is just a very simple example, but it will still make programming AI a lot easier to pull off.

Cheers,
Kentaree

I would be unstoppable if I could just get started...
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 29th Sep 2003 21:40
Yep sorry for being brief but I was rushed with that post.

What I need is some pathfinding code that, if the point clicked is visible to the chosen character (ie they can move directly to it without obstruction) then they move in a straight line there. But by suggestions I mean what if something suddenly crosses his path on the way?

I need the enemies to be able to move around quickly and straight to where they are going - chances are that enemies wont need to pathfind over long distances, only players. Cananyone suggest methods of doing it, and other implementations eg waypoint setting (a la C&C)?

"It's amazin' what you can do with a computer and access to t'internet"
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Sep 2003 23:26
For line-of-sight, I would map all unmovable objects onto a grid and then use a line drawing algorithm to trace the line between two positions (not drawing it of course ) - Either use a simple floating-point line routine or bresenhams line algorithm

For pathfinding, I'd again keep everything mapped onto a grid and use the code I've already done to do an A* search - the code is in the Codebase
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 29th Sep 2003 23:36
Thanks IanM, will check that out, cheers.

"It's amazin' what you can do with a computer and access to t'internet"
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 30th Sep 2003 05:18
Kentaree definitely hit the nail on the head with AI. Break it down into the smallest step possible and eventually you have simple enough problems to solve one by one.

Another example might be, you want your enemy to move into cover so you cant shoot at him. Sounds complex, but all you really need to do is:
(1) Identify objects close to the enemy (i.e. rocks, walls, barrels etc)
(2) Starting with the closest, trace a line from the players position to each objects position.
(3) Continue along this line until you have past the object. This position will be covered from the players line of site.
(4) move the enemy towards this position.

Then obviously you can break those down, so for (4) for example:
(1) Rotate enemy by turn speed towards position.
(2) When facing, move enemy by movement speed.
(3) Repeat 2 until at position.

Break it all down and down and down until you have a large array of very simple steps, and you're done. You'll also develope generic functions, so once you've made a function that turns and object to face a point and move to it, you can use that function for chasing enemies, moving into cover, moving to a way point, moving to an object etc etc etc.

Anyways, just wanted to reaffirm the whole "break it down" principle. Keep up the work.

Insiiiiiiiiiiiiiiiiiiiiiiiide!
MicroMan
22
Years of Service
User Offline
Joined: 19th Aug 2003
Location: Stockholm, Sweden
Posted: 30th Sep 2003 05:45
You have an absolutely marvelous site for AI in "AI Depot", which you can visit here:

[href]
http://www.ai-depot.com
[/href]

Some of the articles I've found helpful are:

Pathfinding:
[href]
http://ai-depot.com/Tutorial/PathFinding.html
[/href]
Decision trees
[href]
http://ai-depot.com/Tutorial/DecisionTrees.html
[/href]
Finite State Machins
[href]
http://ai-depot.com/FiniteStateMachines/
[/href]

Perhaps we could hint to Rich that there should be a seperate forum for Game AI, considering it's vital importance in game creation? Games aren't just coding and/or graphics. It's about thinking about AI too.

-----
They SAID that given enough time a million monkeys with typewriters could recreate the collected works of William Shakespeare... Internet sure proved them wrong.
-----
MicroMan
22
Years of Service
User Offline
Joined: 19th Aug 2003
Location: Stockholm, Sweden
Posted: 30th Sep 2003 05:46
Further, I think game AI is actually MORE important to game creation than having the latest shaders and the most elaborate graphics.

-----
They SAID that given enough time a million monkeys with typewriters could recreate the collected works of William Shakespeare... Internet sure proved them wrong.
-----
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Sep 2003 09:46
*GASP* Wash your mouth out!
MicroMan
22
Years of Service
User Offline
Joined: 19th Aug 2003
Location: Stockholm, Sweden
Posted: 30th Sep 2003 10:11
Never! *gurgling out soap in the washbasin*

Well, there IS a lot of focus on mere graphics in here.

I have this image that people come here weeping when they can't implement the latest whopping, pixel shader routine after studying the subject for six hours, after buying DBP (their first programming language) the day before.



Me? Ironic? Nooo....

-----
They SAID that given enough time a million monkeys with typewriters could recreate the collected works of William Shakespeare... Internet sure proved them wrong.
-----
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 30th Sep 2003 11:36
Yep, thats true. What good are the graphics if theres no game?

Anyway, thanks for all the links and help everybody.

"It's amazin' what you can do with a computer and access to t'internet"
Guyon
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location: United States
Posted: 30th Sep 2003 16:24
I had a Football (not soccer) game for my Amiga ages ago that was only X's and O's, on a simple field with a fixed overhead view. The game play was awesome, and did some things that I still so not see in todays advanced 3D games. I really miss it.
Graphics are really cool but game play is what counts.
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 30th Sep 2003 20:44
Ah yes, one of my ALL TIME FAVORITES GRIDIRON
was like you describe Guyon except with colored dots,
one team black one team gold.

A version of that one is on my todo list.
With those glorious graphics maintained
2 player networked of course.

The more you see, the more you know.
The more you know, the more you see.
Guyon
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location: United States
Posted: 4th Oct 2003 07:54
Gridiron! That is it heartbone!!
I would love to see that remade. I especially like passing. You drew a rubber band line to the target spot to throw and hoped your receiver got there in time. It felt just like real passing. I have never had that feeling with any other football game.
Aramil
22
Years of Service
User Offline
Joined: 27th Oct 2003
Location: Wherever my feet take me
Posted: 2nd Nov 2003 18:20
Hmmm...You know that part you said about rotating towards an object? HOW THE **** DO YOU DO THAT? It's seems impossible! I can't even do that. I've ran quite a few tests, and I still can't figure out how to do that. Do you think you could supply me with some example code? Thanks.
Kentaree
23
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 2nd Nov 2003 18:24
Atanfull(object position x(1) - object position x(2), object position z(1) - object position z(2) ) iirc (and I probably dont, but its something along them lines.

I would be unstoppable if I could just get started...
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 2nd Nov 2003 18:25
Quote: "*GASP* Wash your mouth out!"


LOL.

Anyway, as far as AI goes, the most I've done is completely simple. I made a sidescroller a while ago and it involved a guy walking back and forth. If you touched him, you'd die (actually I never got to program that because I got bored with the whole project, lol).

Team EOD :: Programmer/Storyboard Assistant
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 2nd Nov 2003 19:31
this thread was almost a month old!!! damn Id forgot about this. Anyway, im still in need of pathfinding code, if anybody has any...

ZEDWARE website coming soon... //END TRANSMISSION//
Mussi
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 2nd Nov 2003 19:40
well I recommend you make your own cuz it would be to complicated to understand the code of others and implent it in your game. I think IanM had some basic pathfinding code

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb ddr sdram
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 3rd Nov 2003 10:38
I planned to, I think Ive got IanM's code on my hard drive somewhere... just I need to find a better way of implementing, maybe changing from grid a* to point-based a*...

ZEDWARE website coming soon... //END TRANSMISSION//
waffle
23
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 3rd Nov 2003 13:39
I did a ballon game once that used basic pathfinding.

setup stuff....
M = Moving object
MX,MY,MZ = Moving objects position
TX,TY,TZ = target position
RFD = rotate object direction flag
RQ = rotated quantity

1 - assume M can move directly to T. The simplest option.

Point Object M,TX,MY,TZ `MY to keep the object from leaning
`store this information as M0

MX0=Object position x(M) ......
MR0=Object Angle y(M) ......which way are we pointing

2 - See if we can actually go the way we are facing

Move Object M,10

3 - Check for collision
If Collision reset object position to M0
Move object M,-10
Set a rotation flag
For now, just assume we decide to rotate right
if RFD=0 then RFD=1
RQ=RQ+RFD*10 .... rotate 10 degrees is desired direction
point object M,TX,MY,TZ
MR = object angle y(M)+RQ
rotate object M,0,MR,0
go back to step 2 and try moving again
else
no colision occured. chech the rotation flags
if RFD
Undo the collision rotation
RQ=RQ-RFD*10
MR=Object angle y(M)+RQ
rotate object M,0,MR,0
if RQ=0 then RFD=0
endif

endif

that should give you the basics of path finding without resorting to the use of waypoints trees. Although, this method can be extended to waypoints as a list of TX,TY,TZ locations. This methos works, is simple, but has 1 major flaw....
It does not know how large the object is that its trying to go around. In my balloon game this was not important as it was usually a mountain or lake. But, if moving room to room in a maze a creature could get lost using this method. Or a creature could get stuck if trapped between objects (trees clustered too close or not close enough). Basically, this method will have a critter track around the collision boundary of your object and resume original heading upon reaching the far side of the object.

internet gaming group
Neophyte
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 3rd Nov 2003 13:40
@MOONSHiNE

"I planned to, I think Ive got IanM's code on my hard drive somewhere..."

Just to save you the trouble.
http://darkbasicpro.thegamecreators.com/?m=codebase_view&i=56984d6fa64dd67ceb1e01c8d835c957

"just I need to find a better way of implementing, maybe changing from grid a* to point-based a*..."

I'm afraid that isn't possible. A* is based on the assumption that you will be using a gird. If you want point to point based navigation your only bet is way points.

This was posted a while back. It may be of some use to you.
http://darkbasicpro.thegamecreators.com/?m=forum_view&t=13211&b=6
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 3rd Nov 2003 16:10
OK, just to explain, by point based pathfinding I meant the type of A* that uses a non-grid arrangement of points, rather than a square grid. EG points could be at 3 corners of a triangle, then at 10 points round a building, then the A* works out which to move to. Gotta go to graphics now, Ill explain better later.

ZEDWARE website coming soon... //END TRANSMISSION//
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 3rd Nov 2003 20:03
OK, back now. So to understand what Im after check the link below, go to the third item down, "Non-grid pathfinding", and look at the first bit, polygonal maps:

http://theory.stanford.edu/~amitp/GameProgramming/MapRepresentations.html#S6

ZEDWARE website coming soon... //END TRANSMISSION//
Neophyte
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 4th Nov 2003 06:07
@MOONSHiNE

"OK, back now. So to understand what Im after check the link below, go to the third item down, "Non-grid pathfinding", and look at the first bit, polygonal maps:"

I see. That just looks like way points(aka "navigation points"). Check the code in the botttom link that I posted above. I haven't used it yet so I'm not sure if its any good, but it appears to be what you want.
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 4th Nov 2003 10:42
OK cheers, but I need DBPro before I can compile it. I was supposed to get it about a month ago but my dad forgot to order it.

ZEDWARE website coming soon... //END TRANSMISSION//
Neophyte
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 4th Nov 2003 12:28
@MOONSHiNE

"OK cheers, but I need DBPro before I can compile it. I was supposed to get it about a month ago but my dad forgot to order it. "

Bummer.
Jess T
Retired Moderator
22
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 4th Nov 2003 13:21
Download the trial version fromt his very site, it's only 10Meg...

Here: http://darkbasicpro.thegamecreators.com/?gf=alienware

It's right down the bottom...

That's what I'm using untill i get DBPro for Xmas...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
M00NSHiNE
22
Years of Service
User Offline
Joined: 4th Aug 2003
Location: England, UK
Posted: 4th Nov 2003 14:56
@Neophyte- Dont I know it. My mum keeps dropping hints though

@JessTicular- Thanks for that, I cant download it now coz Im at college so Ill see if I can get it when I get home. Id already previously run the trial before the Alienware one came out, hope theres no conflicts.

ZEDWARE website coming soon... //END TRANSMISSION//
Aramil
22
Years of Service
User Offline
Joined: 27th Oct 2003
Location: Wherever my feet take me
Posted: 5th Nov 2003 01:05
Could someone please provide me with some code that will make an object ROTATE towards another?
zircher
23
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 5th Nov 2003 03:31
I'm short on time, but here's some (untested) code for a trig-phobic way of doing it.
--
TAZ

Login to post a reply

Server time is: 2026-07-26 20:14:51
Your offset time is: 2026-07-26 20:14:51