Whats the fastest way to do this?

Whats the fastest way to do this?

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Whats the fastest way to do this?

Post by krogothe »

Right, i have a load of points in a 2d array, in a certain order:

Image

I want to draw lines beween them of a certain (variable) thickness (think locii of connected lines) so that any point within a certain distance from the dots and the imaginary lines connecting them has some operation performed to them (in this picture they are made black). Like this:

Image

Surely i could work out every point on the lines and then draw a circle around it and then set a flag so that the points around it arent processed again, but that would be much too slow! How could i speed that up?
User avatar
Weaver
Posts: 644
Joined: 07 Jul 2005, 21:15

Post by Weaver »

Why cant you do it with circles on the points and rectangles between them?
Sheekel
Posts: 1391
Joined: 19 Apr 2005, 19:23

Post by Sheekel »

dragons teeth placement?

:P
User avatar
Lindir The Green
Posts: 815
Joined: 04 May 2005, 15:09

Post by Lindir The Green »

:roll:

mex placement.
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

neither now shut up or help :P
yeah weaver's way is faster, but i think there must be a way to make it faster still, probably with matrix algebra or something
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

If we knew what it was for we could answer you better.

My thoughts would be to use more points inbetween the points, sorta like a dotted line, spaced apart by x*0.6, where x would be the breadth/thickness of the lines you describe.

When you get a new point you need to check, split the problem space into 4 quadrants, and search for the nearest existing point to the new point in the new points quadrant. Then measure the distance and if distance <= the x of that point, then it is inside the line, else it is outside.

Or you could list each point in turn, and find the gradient of the lines joining them up. Then all you have todo is check the gradient of the new point against existing points, and if the gradient of the new line is equal to the gradient of any of the existing lines then it is on the line, and if it is inside but nto on then you'd ahve to vary it to how big the difference is in proportion to what x is.

Or you could use a grid approach, flagging grid squares that have a point in them, or have a lines passing through or nearby. That would mean generating the grid data would eb costly, but after that the checks are much faster. Find which grid square the new point is and check if it's flagged.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

=O

Where else have we seen these diagrams from krogothe?!?!?! his mex class! And what was it that somebody recently told me about how NTAI handled mex spots (maybe it was in a pm with an NTAI test build log), how they didnt follow a path to make visiting each mex in turn more efficient... I think that might be what krogothes doing, if not it's given me enough to try and implement it once my exams are done.

hmm that and I now know how I'm gonna do DT walls.....
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

neither now shut up or help
yeah weaver's way is faster, but i think there must be a way to make it faster still, probably with matrix algebra or something
Whatever way you do it, the thing that actually takes up most of the CPU time will be rasterizing it onto a grid, and accessing whatever 2D array you want to access.
I would also represent everything by quads, then you don't have to make a seperate rasterization for the circles. Now just make a fast quad rasterization. There are plenty of tutorials about software rendering anyway so that should be no problem.
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

LOL
you guys suck at guessing! :lol:
all i want is the quickest way to do just what youre seeing, filling in pixels from a certain distance from points and lines, nothing else!
AF, The first way you mentioned could work, but thats basically drawing less circles, which are slow to draw(then again i could use some faster methods ive learnt :twisted:)... ill try either way and see which is fastest...
EDIT Ill stay on the safe side and take advice from zaphod first (eg find out what rasterizing means) :)
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

We aren't guessing, we're giving possible solutions. You still seem to thing that there is an optimal solution for every problem... THERE ISN'T.
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

I dont think theres an optimal solution for things (except my metal class :roll: )
You didnt guess, but the 3 guys before you did, guessing if it was for mexes or dragon teeth, which i pointed out, its for neither, please dont all go hostile on me because i made a little joke, if weve managed a couple of weeks without krogothe barbecues, we can manage a few more!
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

I didn't really mean that as hostile though... just a bit too persuasive I guess ;)
Ok my guess, is it for unit group movement through the map?
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

hmmm a good guess (considering you read the old posts about it) but no biscuit :P
okay im getting acquainted to rasterizing, it could be good since the corners need not be rounded
User avatar
Masse
Damned Developer
Posts: 979
Joined: 15 Sep 2004, 18:56

Post by Masse »

this must be some sort of a defence placement...

well... lets think... what u need is
better defence placement
unit grouping
all air/water stuff
...umm...
i forget all the other stuff...
Last edited by Masse on 08 Jan 2006, 21:53, edited 1 time in total.
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

nope
User avatar
Min3mat
Posts: 3455
Joined: 17 Nov 2004, 20:19

Post by Min3mat »

scouts attacking mexes?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Is this the actual thing your messing with or is it you trying to log it to an image file...
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

no and its the actual thing
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

is it a new painting program?
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

rofl
not its KAI-related
Post Reply

Return to “AI”