Range-Finding?
grimtooth
Member Posts: 69
Hi Guys,
I am trying to implement a Range-Finding function to facilitate AI. The problem I have is that Rule Logic Blocks only seem to allow "IF ATTRIBUTE". Currently I have a Table and Pointers set up to constrain actor X,Y positions to table cells. I was hoping to simply be able to have a constantly running AI actor that would calculate distance from one Actor to multiple others, allowing the AI to select its closest target.
The Mechanics behind doing this don't seem to hard at all, but if you'll pardon the expression... I keep getting ****-blocked by the inability of the Attribute Editor to look at a table cell value. Do I really have to make 40+ global attributes in order to "export" the table values to "Attributes"?
-Grim-
I am trying to implement a Range-Finding function to facilitate AI. The problem I have is that Rule Logic Blocks only seem to allow "IF ATTRIBUTE". Currently I have a Table and Pointers set up to constrain actor X,Y positions to table cells. I was hoping to simply be able to have a constantly running AI actor that would calculate distance from one Actor to multiple others, allowing the AI to select its closest target.
The Mechanics behind doing this don't seem to hard at all, but if you'll pardon the expression... I keep getting ****-blocked by the inability of the Attribute Editor to look at a table cell value. Do I really have to make 40+ global attributes in order to "export" the table values to "Attributes"?
-Grim-
Comments
Currently doing something I haven't done since junior high... Factoring Polynomials (just as fun as you remember it) will post if its a dead end when I finish I unless I get a better answer before then
-Grim-
It would be nice if GS Tables could hold formulas in their cells. All that comparing could be done within the table!
Meanwhile (just brainstorming here) the new looping behavior might come in handy. It will allow you to loop "i' rows across "j" columns. Its in the nightly builds -- but could in the near future find its way into the stable release. It might be worth waiting on this aspect of your project until it's available.
two actors attributes, one to represent "Z^2" and I can use self.X and Self.Y in the expression editor and then store the current least distance in a 2nd actor attribute to compare against table values with a global pointer! (maybe)
You probably could have been more help if I told you that this was a tower defense project. I know that there are quality templates out there but I am still a Newbie and the learning opprotunity of failing a few times is worth more than the time saved by buying a template.
You said "a temp variable to access table data" I said "one variable doesn't allow for comparison"
LEARNING OPPROTUNITY and I almost missed it because I was blinded by complex math. One temp variable doesn't allow for table cell comparisons, but two (and a pointer) DO, duh
So once again, THANK YOU and of course I'd be glad to post some of the code when finished but that might be a week or three at my current work rate hehe.
-Grim-
In the mean time I assume we must use a "Math" actor (with attributes) to access table data, do calculations, and constrain back to the table?
-Grim-
-Grim-
IF: Self.Range.toTarget < Self.Closest.Target
I just now replaced "Self.Closest.Target" with a copy of the range finding equation substituting Self.Closest.Target in for Self.Table.Pointer.
One suggestion -- you can get rid of the extra rule and shave off a little CPU time if you increment the pointer like this:
Change Attribute: self.Table.Pointer To: (self.Table.Pointer %30)+1
but since the % operator is being depreciated its probably better to use the mod(x,y) function to avoid future complications:
Change Attribute: self.Table.Pointer To: mod( self.Table.Pointer,30)+1
At this point I'm getting scared for a different reason, x# of towers running timers and y# of enemies ALSO running timers because you cannot CONSTRAIN tableCellValue TO: Self.x
I understand now why one of my fave TD games bogs down from time to time...
Because it is my understanding that the timer function is a bit resource intensive, I will probably replace the timers with something like:
RULE: IF self.time = prec(self.time, 1)
Who knows if that will work or help...
Lunch break over, back to the daytime grind
-Grim-
There are many ways to set-up what you are trying to do. And not all of them need tables and/or timers.
I Worked hard to make this project function with the "save enemy X,Y to table and have Towers read the table for targets" line of programming. In the end it works perfectly as an exercise in what is possible, and it does not work at all as a playable game.
What it has boiled down to is TIME. Using a modulo timer with a 0.02 global and a 0.04 iteration time it takes a tower 1.28 seconds to scan my 32 entry table, which means it can take over a second to find a target or switch targets when one moves out of range depending on the next targets position on the table.
I don't feel that the timer can get much faster, and I chose 32 as a table size because for some of the harder waves with longer paths I really feel like there could be 32 enemies on the screen at once (if the player is failing hehe).
I knew that Tower Defense AI can be created with collision behaviors before starting this project, but I wanted to try something new and challenging.
For now I am just going to file the templates away and start fresh, perhaps when I have access to the Loop function it will become feasible to continue.
-Grim-