Request: AI Visual Debug tools

Request: AI Visual Debug tools

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Request: AI Visual Debug tools

Post by AF »

I'd quite like to see 2 debugging tools implemented via lua widgets:

Map overlay

I'd quite like to be able to overlay my AIs threat matrix onto the map, so that I can finally tweak the update timing and deflation multipliers properly.

It'd be a simple grid with intensity with a grid square size specified by the AI.

Unit tags and markers

Early on in NTais history I implemented a class that would make units have coloured markers above them in various colours, conbots would have yellow markers, attackers markers would be colour dependant, I'd quite like to see two versions of this implemented.

A widget that implemented command based colour coded markers, and a version that added AI markers, allowing multiple markers to be added.

AI<->Lua communication

Now I can't think of how it would be done, but I think that we should leave the AI end to us AI developers, and the lua end to the lua developers, from what I see the AI end is nice and simple, but Ive never seen it discussed from a lua standpoint, and Im not sure how these widgets would be implemented, although they sound trivial.

So you have free reign over what API you wish to implement. This would help quite a lot =]
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Request: AI Visual Debug tools

Post by hoijui »

It would be good to have an AI dedicated Lua coder around, that could do stuff like this. i would have some wishes too :D

about the AI<->Lua communication:
i already proposed in an other thread (can not find it anymore):

Code: Select all

AICallback {
   int sendMsgToLua(string/int receiver, string topic, string[] strParams, float[] fltParams, int[] intParams);
}
this is for AIs, and on the lua side, there would be a corresponding sendMsgToAI() method.
take it appart :D it is meant as a start for discussion.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Request: AI Visual Debug tools

Post by AF »

I thought the C API had a lua communication mechanism of the kind the old interface had? =s

Such a widget as this I could easily pick up as it would demonstrate what to do to us AI developers anyway.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Request: AI Visual Debug tools

Post by AF »

Okay Im sort of in rather urgent need of debugging tools for my threat map. Since nobody is even bothering to help, how would I do this myself?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Request: AI Visual Debug tools

Post by Kloot »

1. write gadget for threatmap visualization
2. add gadget to local mod archive (if non-sdd: decompress, copy, recompress)
3. pass threatmap data updates to gadget from AI via CallLuaRules
4. rejoice

I'll probably be writing one for KAIK and XAI, so now's your chance to give input.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Request: AI Visual Debug tools

Post by AF »

I know the gadget bit, its the actual rendering of the data being passed I'm bothered by, and I'd actually quite like to mess around rather than be relayign requests to everyone all the time whenever Lua is mentioned

If your wanting requests though, 2 modes, one with plain intensity, and one that specifies rgba values
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Request: AI Visual Debug tools

Post by Argh »

OK... do you just want a visualization tool for analyzing the threatmap as the gamestate changes? If so, it'd be easy to strip out the FBO visualization tool out of P.O.P.S., and just build the FBO using whatever color values / resolution you need, using the 'color' FBO. It's very fast- a lot faster than using the CPU to maintain a similar set of quads to perform a quick visual appraisal of the state of the threatmap. Heck, you could keep it intact, and have 4 different analysis tools of various things the AI "sees" on the grid.

As for numerical output for further analysis, it can store the cell values per-row at the end of each cycle in a table, then output it all to a document at the end- see the code for World Builder to see an example of how to write to a document.

There are probably better ways, it's just that this mainly would involve stripping stuff out, not writing much new code, other than getting the value(s) via a callback.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Request: AI Visual Debug tools

Post by AF »

The data is already in lua and AI land, and it would have to be represented in lua land to get it to POPS in the first place.

So the only thing to be talked about here is actual rendering on the map, which is the great big gap in my knowledge, as I dont know the spring lua apis very well at all.

When I said overlay I also meant overlaid on the map itself, not a box on the screen.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Request: AI Visual Debug tools

Post by Argh »

Ah, so you want to render to the map... kk, then you just need to construct a low-resolution display list, using Lua to get ground heights, then use a FBO to store pixel values which will be used as 1:1 textures on the display list. IOW, each square XY == square of threatmap.

IIRC, user wrote a fixed-function concept like this at one point (he was trying to replace SMF), but it doesn't use FBOs or GLSL, so it's slow as hell. But the concept's the same.

I don't have time to write this atm- that's fairly non-trivial programming, if you want it to be fast. The display list should probably get broken into chunks to speed things up, etc., but the basic concept as outlined above should be fine. You don't need LOD or other fancy stuff, if you keep the resolution reasonable.

Oh... talk to zxswg, he's been doing large-scale map-sized rendering lately. He might be your best bet for a quick fix.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Request: AI Visual Debug tools

Post by Kloot »

All too easy:
ThreatOverlayMap.png
(1.96 MiB) Downloaded 43 times
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Request: AI Visual Debug tools

Post by AF »

Its debugging, not particularly bothered about speed...

Kloot where can I find the code for that?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Request: AI Visual Debug tools

Post by Argh »

@Kloot: cool. I was thinking about this problem while driving home from somewhere and I was like, "oh, duh, just do XYZ, it won't be that bad" but I guess you beat me to the punch 8)
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Request: AI Visual Debug tools

Post by SpliFF »

Image
unit_scout_metalstorm - demonstration of using markers and lines

Image
stats_resource_labels - demonstration of using labels that follow unit

http://warriorhut.org/spring/mods/metalstorm/widgets/

Place ALL files in your widgets directory (keep the structure intact, ie the metalstorm/ folder goes into widgets/). Still very alpha code but hopefully it demonstrates some things you can use for your debugging.
Post Reply

Return to “Lua Scripts”