It is currently Fri Aug 18, 2017 4:55 am Advanced search

Visualising AI state

Topics about starter packages, visualizer or any other third party tools.
Please submit new language requests in the Language Request Forum.

Visualising AI state

Postby jab_bott » Thu Oct 27, 2011 12:08 am

Is there a way to send commands to the visualiser that can draw lines, circles, boxes, text, etc. in different colours (and transparency), to overlay on top of the map during playback?

This would enable us to visualise our AI state (for example: waypoints, planned routes, known terrain, ant state, tracking objects/areas, search trees, etc.) and present ourselves with some stats. I'd personally find this really useful to help make sure my AI is doing what it's supposed to. Of course the online engine would ignore those commands (and you could enable/disable with a setup state too to speed up processing) - it would only be for local testing.

J

EDIT: If you're just reading this topic for the first time - things have moved on a lot. The upshot is there's a pretty-good working ai-state visualizer, instructions for how to use it are here:
https://github.com/j-h-a/aichallenge/bl ... OVERLAY.md
Even if you can't be bothered to read the whole topic, it's worth scanning through each page to see some of the pictures people have posted.
Last edited by jab_bott on Tue Nov 29, 2011 12:57 am, edited 1 time in total.
jab_bott
Lieutenant-Colonel
 
Posts: 44
Joined: Wed Oct 26, 2011 11:55 pm

Re: Visualising AI state

Postby jlgrall » Thu Oct 27, 2011 1:35 am

This would be awesome. A debug API.

Did my algorithm found all the relevant tiles ? Just mark the found tiles with the debug API, launch the game with debug activated, pause the game and check visually...

Why did my ant go there ? Lets map some informations on the map, then I can see whether they are correct...

Really nice idea :)

+1
Last edited by jlgrall on Thu Oct 27, 2011 12:16 pm, edited 1 time in total.
jlgrall
Lieutenant-Colonel
 
Posts: 41
Joined: Sun Oct 23, 2011 11:26 am

Re: Visualising AI state

Postby amstan » Thu Oct 27, 2011 5:41 am

Alexandru M. Stan
Contest Organizer
User avatar
amstan
Contest Organizer
 
Posts: 691
Joined: Sun Jan 31, 2010 4:02 am
Location: Stoney Creek, Ontario

Re: Visualising AI state

Postby jab_bott » Thu Oct 27, 2011 1:44 pm

Great to see some enthusiasm for this :)

I think the basic commands would be:

circle row col radius #RRGGBBAA fill [linewidth]
line row1 col1 row2 col2 #RRGGBBAA
tint row col #RRGGBBAA [linewidth]

Circle: Draws a circle of the specified radius with its centre at row, col. The row, col, and radius could be floating point values so that you can specify position and sizes on a sub-square resolution. The colour could be separate RGBA values but probably perhaps a #RRGGBBAA hex representation is the simplest. Fill would be 0 or 1 to specify a circle outline (0) or solid circle (1). If fill is 0 then linewidth specifies the thickness of the outline to be drawn - although I'm not sure if this should be in screen units or game units (i.e. 1.0 would be as thick as one game square) - logically it should be in game units, but as a visualiser aid it might be more practical to be in screen units so it looks the same on different map sizes.

Line: Draws a line from row1, col1 to row2, col2 - again these are floating point values so that you can draw lines from or along the edges of game squares. The integer at value would be the centre of the square, so for example the very top left of the board would be (-0.5, -0.5).

Tint: This would overlay the specified (integer) game square with the specified colour (users should use a transparent colour unless they want it to completely obscure the game board).

How's that for a starter, any ideas/comments/improvements?
jab_bott
Lieutenant-Colonel
 
Posts: 44
Joined: Wed Oct 26, 2011 11:55 pm

Re: Visualising AI state

Postby jlgrall » Fri Oct 28, 2011 1:26 am

It looks really nice ! Almost a finisher :D

I just thought about 1 thing.
It seams from the game specifications that the game engine likes lines beginning with a single character ("o" for order, "w" for water, "d" for dead ant, ...). Maybe to do it the same way, we could use as the first letter either:
- the first letter: "c", "l", "t".
- or a single letter that would mean draw or debug. We could use "d", followed by "circle" or "line" or "tint".

I don't know for the color representation. I would say that #RRGGBBAA is easier to read for a human, but in this case, the information is only to be read by a program, and it is much easier to parse values separated by spaces. So I would say separate each component.

Would it be better to use floats between 0 and 1 or integers between 0 and 255 to represent color components ?

Maybe we could also have a command to pause the visualizer ? I am not sure that it would be a good idea thought.
jlgrall
Lieutenant-Colonel
 
Posts: 41
Joined: Sun Oct 23, 2011 11:26 am

Re: Visualising AI state

Postby jab_bott » Fri Oct 28, 2011 9:01 pm

So how do we go about implementing this?

I had a quick look at the visualiser and it seems to be written in JavaScript - although there's a visualizer.jar file too so maybe it's in Java. However, it seems to take a big list of map states as input so we'd probably have to pass a separate list of overlay-states for each turn and of course generate this log-file too. What's the best way to get started?
jab_bott
Lieutenant-Colonel
 
Posts: 44
Joined: Wed Oct 26, 2011 11:55 pm

Re: Visualising AI state

Postby gvsmirnov » Sat Oct 29, 2011 12:34 am

Uh, I actually sort of implemented something like that, but it was only targeting a specific overlay layer for a specific AI info. Sending direct commands is a good idea, but as I see it, there should be a nearly-full replica of what canvas api can do.

Image

P.S. The java visualizer uses the js-based one. It fires up a browser frame.
gvsmirnov
Captain
 
Posts: 27
Joined: Thu Sep 09, 2010 8:13 pm

Re: Visualising AI state

Postby jab_bott » Sat Oct 29, 2011 12:45 am

A full replica of canvas APIs would be great, but we've got to start somewhere. I don't really know JavaScript but I took a look anyway - CanvasElement.js seems to be where all the drawing takes place.

I figure if we have a separate list of overlay states for each turn that can be passed in, we can draw it here. The tint one is probably the easiest to implement, looks like you already did something similar in your screenshot. Can you give any pointers where to edit the JS, and also how you managed to get replay data for your AI state out and into the JS?
jab_bott
Lieutenant-Colonel
 
Posts: 44
Joined: Wed Oct 26, 2011 11:55 pm

Re: Visualising AI state

Postby imargonis » Sat Oct 29, 2011 11:48 am

This sounds like a really cool idea.

+1 from me
imargonis
Cadet
 
Posts: 8
Joined: Mon Oct 24, 2011 12:13 pm

Re: Visualising AI state

Postby jab_bott » Sat Oct 29, 2011 12:18 pm

I've started looking into the visualiser. Here's my plan:

1: Define a prefix for visualiser commands. e.g. "#OVERLAY:"
2: Find the part of the game tools (engine.py I think) that outputs the html that is displayed by the visualiser and modify it to create an additional JSON component containing the filtered overlay commands.
3: Edit the visualiser code to draw the overlays (CanvasElementAntsMap in CanvasElement.js I thhink).

I don't know JavaScript or Python yet - so all help is appreciated :)
jab_bott
Lieutenant-Colonel
 
Posts: 44
Joined: Wed Oct 26, 2011 11:55 pm

Next

Return to Starter Packages & Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron