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.

Dark Physics & Dark A.I. & Dark Dynamix / Dark AI - Grid based Movement

Author
Message
Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 22nd Oct 2007 19:12 Edited at: 22nd Oct 2007 19:13
Hey there, I've been trying to implement grid based movement into this little project I've been working on. I can program this myself using some Astar algorithms but I'd rather not because I am extremely lazy so I was wondering if there is a way to do it through Dark AI.

I think the way to do it is to force an AI subject to only move through waypoints, I've been playing around with batvinks excellent ai example but it doesn't work the way I want it to as the AI seems to ignore all the waypoints sometimes and head to its final destination in a straight line.

eg.



A isn't the desired result, B is ideal. So if there is a solution then share your ideas here If there was a way to force an AI unit to only pass through waypoints then that would be good

Cheers

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Oct 2007 00:24
You can do exactly what you want. I don't have DBP on this machine, but I can explain it.

In the update to DarkAI, Paul added an extra feature at my request. This feature is what allowed me to do the linear paths. You can set a "look ahead" value on some of the commands, which means it can only look so many units ahead for the next waypoint. It will build the full path, made up of small jumps between waypoints.

So in your example, let's say the waypoints are 10 units apart. If you set the "look ahead" to 11, it will force it to include every waypoint it has to travel through. If you set the "look ahead" to 15, it would allow it to travel diagonally across the grid, because it can also "see" the far corner of the current square.

I hope that makes sense. If I find the commands, I will post them!

Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 23rd Oct 2007 01:17
Thats exactly what I am looking for, cheers 8) Those commands would be great if you could find em

Cheers
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Oct 2007 14:25
The key is the command AI make path between points. It now has an extra parameter, which sets the "look ahead". I always set it to one grid square * 1.1, to get horizontal/vertical movement. I think grid square * 1.5 will allow diagonal movement too (Distance to far corner = 1.42 * grid size).

You need the AI update, but I don't know if the help file explains the new parameter.

Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 23rd Oct 2007 16:07
Thats what I am using now, it doesn't seem to work See attached for a rough example.

I have a funny feeling I'm doing something wrong. But no matter how much I play around with the waypoint visibility parametres it seems to ignore all the waypoints and head via the direct route.

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Oct 2007 17:14
OK, I remember more now (it's coming back slowly!)
There are two things involved here. First, is the "look ahead" ability to find the next appropriate waypoint. Secondly, there is the cost of travelling along a certain path. So you can have 100 different ways to get from A to B, and the "look ahead" will ensure you do it one waypoint at a time. The path cost will define which of the 100 different ways the AI will pick, taking the cheapest option.

You need another command, executed just once...

AI Update Waypoint visibility

This sets the maximum visibility from one waypoint to the next.

The figures are the waypoint distances. Now, I don't know what the default unit is - maybe it is 1, maybe it's 0 or 1000 - I don't know.

I also did some other quirky things to make Railrider work better. For example, I set the path cost to the point behind me to 10,000. Then it was too expensive to go back the same way you had come. My game was cars on railtracks, so backward movement had to be impossible.

This is the code, taken straight out of the game, that I used to randomise path/waypoint weightings to make the enemy less intelligent. That is, he didn't always take the shortest path because of the cost involved.



Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 23rd Oct 2007 17:42
Cheers for the explaination, it does make sense but I still can't find this look ahead ability . I'm already using AI Update visibility but it doesn't seem to do much, no matter what I set the value to.

AI Make Path Between Points Path Number, Container Number, X1#, Y1#, X2#, Y2#, Max Start Cost#

Is the look ahead ability the Max Start Cost field? I've tried adding additional fields but it won't compile otherwise. Or is it a function you made?

It looks like it will be lot easier to just make a grid based astar function hehe.
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 23rd Oct 2007 19:24
Forcing a grid based formation on it is a little tricky but you are nearly there. The last thing that is preventing the path being created properly is that the lack of obstacles convinces the entity it doesn't need to create a path and so plots it's way directly through the level.

To overcome this you need to add some obstacles in the grid spaces that tells the entity it will need to avoid them and then will use your waypoint network to get around them. I've attached the modified code to do this for horizontal and vertical movement, if you wanted to allow diagonals you'd have to use more complicated obstacles (4 triangles per grid) which allow it.

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Oct 2007 21:53
Yes, that would be the final piece of the jigsaw! In Railrider, I had exactly that. The obstacles also had a large radius, to force the cars to stay on the tracks, and not cut corners.

Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 24th Oct 2007 16:27
That works brilliantly! Thank you for all your help

Tried getting the triangle method to work for diagonals and it seems to work perfectly. Will upload it when I tweak some things.

Thanks again
Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 25th Oct 2007 05:01
Added a diagonal example, the loading time can be rather slow though.

Attachments

Login to view attachments
Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 27th Oct 2007 03:39
hrmm the loading time is too long I think. I want to keep it to a minimum... Is it possible to make it load faster?

If I could make the obstacles into triangles I think it would improve performance, but the AI radius gives the triangles padding so they are 5 sided instead of 3 o.o

Any way to fix this?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Oct 2007 15:18
Once you have a design, you can make it into a memblock and save it. Next time, you just load the memblock instead of calculating everything again.

Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 1st Nov 2007 01:46
Hmm I can't seem to find any commands to load or save obstacles into memblocks. Are they undocumented commands or is there another method?

Cheers
MickeyIII
18
Years of Service
User Offline
Joined: 12th Aug 2006
Location: Louisiana
Posted: 11th Nov 2007 20:39
Yeah. I can't find it in the help commands either...Just got finished looking for it a few seconds ago.

Also, is there a way to QUICKLY update the obstacles in the DO...LOOP? I would love to be able to do that, like to have an obstacle fall onto the ground and add it as an obstacle...Dont't know why I want to do that, I just do. And is there a way to maybe have an obstacle that can move. NOT an entity. An obstacle. So far I only see static obstacles. Maybe, if there isn't any, they could add a command like "AI ADD DYNAMIC OBSTACLE" and hopefully a command to update those obstacles like "AI UPDATE OBSTACLE" or just put it all in "AI UPDATE".

Mickey III
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Nov 2007 00:00
It's not possible, becaue of the way it works. Every time you add an obstacle, you have to recalculate all paths to find the best way from every waypoint to every other waypoint within range. Feel free to rebuild them, but you're going to notice it!

The alternative is to load the existing waypoints into a memblock, and bump up the cost of travelling along paths that now have something undesirable in the way. That's how I stopped my cars on rails reversing - the intersection behind the car was always thousands of times more expensive than any other route.

MickeyIII
18
Years of Service
User Offline
Joined: 12th Aug 2006
Location: Louisiana
Posted: 13th Nov 2007 00:59
Thanks, BatVink. I guess I will just find another way...
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 4th Jan 2008 22:51
Hmmm... could this be worked with to make ...like way points for aircraft? Or vehicles over hilly terrain? Hmmmm.....

(I emailed RotorLib for a PRICE, NO FREAKING response... they can kiss my .... yeah)

Login to post a reply

Server time is: 2024-11-24 20:39:50
Your offset time is: 2024-11-24 20:39:50