JStellAI first video

Yesterday I finished implementing the basic pieces to have JStella ouput traces, yesterday I recorded a trace of going through the first 3 screens of the game.  Objects are rendered in the color they appear as in the game, and the rectangles are rendered with alpha transparency and also have a solid border of the same color:

The Good:

  • The implementation is simple; uses only Java source, and standard Java libraries.  This means people should be able to get this running much more easily (why I started this in the first place).

The Bad:

  • Seems to be about as slow as Stella AI (I’m trying to optimize the code now).
  • There is lag time at the beginning before the controls become responsive; it seems to be a period where the game is loading.
  • There are a few frames that are empty aside from the black background – I need to investigate why thats happening.
  • Hangs after Harry dies?

Notice that the holes don’t show up.  That is simply because there is a black border on the left and bottom of the screen, so a black bounding rectangle is drawn over the entire screen so no other rectangles are drawn inside that.  The simple fix (I tried it already) is just to crop out the black border on the screen.

Also, the logs and vines are hard to see because of their close color to the other colors around/behind them, but they are there.  I specifically added the solid borders to make them easier to see.

So more work needs to be done, but at the very least I think we can end up with an implementation that is at least as fast, and much easier to run, when compared to the C/Lua Stella AI, and I also think it won’t have the issue of dropping objects that earlier versions of that seemed to have.  I think with a bit of work I can get it faster.

2 thoughts on “JStellAI first video

  1. Michael Littman says:

    neat. can you say a bit about how you find rectangles? I wonder if we can do some clever algorithm design to eliminate some redundant calculation.

  2. hut3 says:

    Right so the basic pieces of information that are useful from JStella is the video buffer (an array of ints), and the color palette (another array of ints), where the video buffer contains indices into the color palette to determine what the color of the pixel is at that point.

    For this version, I convert the 1d array to a 2d array which has a representation which matches the way its rendered on screen. At the same time that I do that I make a list of all the unique colors on screen. For each of the unique colors, I make a 2d array of booleans which just represents whether that exact color exists at that location or not.

    Then for each 2d boolean array I scan through each pixel. If I find a ‘1’ pixel, I start to grow out a bounding box from that point iteratively. At each stage, I check if I need to push out any of the top, left, right, bottom boundaries. If so, I do and then set all values where the old boundary to ‘0’. I then return the boxes found that way matched up with the original color it was to be rendered as.

    Clearly this isn’t optimal as far as speed goes as I can just make do with just one copy of the original video buffer, instead of one and then another one for each color that shows up on screen. I’m trying to get that working right now, but there must be a bug because its horribly slow.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: