Interpretable game state?

20 views
Skip to first unread message

Pedro

unread,
Apr 25, 2016, 12:31:16 PM4/25/16
to javatari
Hi all,

I'm trying to figure out if I can make sense of the saved gamestate. Specifically:

1. Is it possible to pull out the game score (e.g., for a game like Frostbite) directly from the saved state, or from the emulator as it is running? 
2. Does the base-64-encoded string near the end correspond to an image? I've tried decoding and reading as several popular image formats but no luck, so far.
3. Do I have any chance at all of getting actual information about, say, location of sprites on the screen?

If anyone has answers to any of these questions of the top of their head, I'd very much appreciate them.

Thanks!

Pedro

Paulo Peccin

unread,
Apr 25, 2016, 12:56:27 PM4/25/16
to java...@googlegroups.com
Hello,

I'm the author of Javatari, I can give you some answers.
What are you trying to achieve?
Are you trying to implement some kind of AI do play Atari games?  :-)

Peccin


--
You received this message because you are subscribed to the Google Groups "javatari" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javatari+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pedro

unread,
Apr 25, 2016, 1:40:18 PM4/25/16
to javatari
Hi Paulo,

First -- thanks for all the great work!

Yes, I'd eventually love to implement an AI to play Atari games :) For now what I want to do is actually analyze human behavior on the games.
The very easiest thing I want to pull out is score over time. The more interesting things I'd like to look at involve analyzing game state to infer goal-directed actions, like how often does a player deliberately try to run into a bird (taking Frostbite as an example), etc. I haven't yet decided how exactly to analyze these (and which exact things to look at), because they partly depend on what kind of game state information I have. But definitely I want to avoid trying to annotate game videos (e.g., recorded frames of people's play) by hand. So if I know at minimum where different sprites of different types are (e.g., on an x-y grid), I can probably do some simple but meaningful analyses.

If more details about what I will analyze would help, let me know and I'll think more about it and send you a more concrete answer :)

Pedro

Paulo Peccin

unread,
Apr 25, 2016, 2:23:47 PM4/25/16
to java...@googlegroups.com
Well, if I were you, I would go for analyzing the memory state (RAM) of the machine.

The Atari 2600 is a quite difficult machine to analyze, if you want to get the image generated, because it does not have a video frame buffer (the frame image is not stored anywhere). The video is actually generated on-the-fly, for EACH LINE, one after another. The CPU constantly tells the video hardware what to display at each line. So, you do not have concepts like Sprite positions, X-Y coordinates, etc. The best you would get is how the image looks for a specific line, but there are 262 lines for each frame, and the software changes this image constantly mid-frame.

Yes, the games for the Atari are not generated frame by frame, but line by line!

But, If you look at the RAM, you will probably be able on infer the current state of the game, like the score, the enemies positions, the player action being performed, etc...

And here is the good thing; the Atari 2600 has only 128 bytes of RAM (not KBytes), which would make the analysis easier and faster. The games have to simplify things and hold all the game state in those 128 bytes. They sometimes implement very clever ways of storing information in such a few bytes.

Imagine implementing a working chess algorithm with only 128 bytes of memory! They did it! 

The Javatari's savestate files are a collection of objects, in an encoded format, representing all the internal hardware state, including RAM.

The easiest way to get the state of the machine is in Javascript, when the emulator is running.
Instead of using a savestate file, you can use an "internal" savestate.

For instance, to get the content of the RAM for the savestate no. 1 (Ctrl + 1), you do something like:

jt.Util.byteStringToUInt8Array(atob(JSON.parse(localStorage.javatarisave1.slice(16)).r.b))

This will give you an Array[128], with the exact contents of the RAM.

You can do similar things with a savestate file, the format is the same. Just be sure to remove the first text (the part up to the "!" char), the rest of the String is a JSON object.

Working in Javascript, you could even be able to read the contents of the RAM right while the emulator is running, without needing savestates. Or even control the players directly, pause the machine, modify RAM, record video, save states to go back to a certain point in time and try things again, etc...

Javatari is the perfect platform to do experiments like this. I would need to upload a modified version with easy access paths for this to work, of course.

Hope that helps, and please let me know when you get any interesting results!

Paulo








Pedro

unread,
Apr 25, 2016, 4:00:42 PM4/25/16
to javatari
Thanks, Paulo! Super helpful! Will let you know when I've done some interesting things:)

Pedro
Reply all
Reply to author
Forward
0 new messages