Skip to main content

Matthew - Blog Post 7


Since January, we've been working hard to not only finish writing the Replay Parser and Frame Collector but also totally synchronize them. I'm pleased to report our success. This is an amazing milestone for us because it means that we've surmounted one of our most troubling obstacles.


I have also made sure to keep our documentation up to date. So, if you like, you can follow along with this blog post by replicating its results.

The Frame Collector uses timed input sequences to start each replay associated with the currently running game version. Then, after waiting a set amount of time for playback to begin, it starts grabbing 1/4-scale frames at a rate of 10 frames per second. The Frame Collector takes these down-scaled frames, which are NumPy arrays, and rapidly pickles and dumps them into the file system. Here's a screenshot of the Frame Collector in action:


If you look at the image above, you'll see that each pickle (the .np files) is simply assigned a number as its file name. This number corresponds with an estimate on how many frames passed since playback started, so "0.np" is the 1st frame and "348.np" is the 349th frame. The frame index values are only estimates because we do not have access to the game's internal state. However, frame 0 appears to be more or less consistently synchronized with the moment when "GO!" is fading out, which is close enough for our purposes. Recall that we are not trying to classify which character animation is associated with each movement type; rather, we are trying to predict the best movement type for any given situation.

We chose 1/4 scale because full scale results in about 1 GB per minute of playback, which is not only taxing on our collective storage capabilities, but is also excessive for machine learning. After all, each individual pixel will need to be represented by its own input node in our neural network. Otherwise, we are running the Frame Collector at about 10 FPS because, after some experimentation, we found that it provides a good balance in terms of the number of frame buffer captures generated per minute and the number of missing frames between each capture.

Our next step will be to run the Frame Collector for additional replays in order to confirm that the frames index values for all of the pickles continue to synchronize with the replay files. This can only be achieved via manual review of random samples. Hopefully we do not encounter too many discrepancies. The biggest risk I am aware of is the possibility that different replay files may take slightly different amounts of time to load in the game. I think that this is unlikely to have a significant effect, though, because replay files are never especially large.

Once we've finished those tests, we will need to collect a larger portion of the dataset. Unfortunately the collection phase can only happen in real time because the Frame Collector has to watch each replay file from start to finish. The upside of this is that the Frame Collector can run independently, fetching and watching replay files one after the other until there are none left for the installed version of the game. After we have collected all of our dataset, we will then need to finish writing the Replay Loader, implement our neural network with Keras, and begin training.

Comments

Popular posts from this blog

Rei - Blog Post 10

So,  I missed blog post 9. This is me acknowledging that for consistency. Anyway, the past couple of weeks have been incredibly productive for ContentsMayBeHot. Matthew has finished collecting all the replay data, we have refactored our project to reduce complexity, we have improved the runtime of our code, and finally we have started seriously training our model. The Changes Matthew implemented multi-threading for the model loading. Which reduced our load time between files from about 3-5 Seconds to 1 Second or less. Which allows us to fully train a model in much less time! While Matthew did this I reduced the code duplication in our project. This way, if we needed to change how we loaded our training data, we didn't have to change it in multiple places. This just allows us to make hot-fixes much more efficiently. We also started working on some unittests for our project using pytest. These tests were written because of a requirement for another class, but we thought it...

Rei - Blog Post 8

This most recent work period involved a lot of refactoring and adding some new key functionality. Matthew asked me to create a simplified Action Type in addition to the one that was all in place, basically just the same actions without PRESSED and RELEASED. Since we still wanted the original structure to be there, all I had to do was cast the "complex" actions to "simple actions. Matthew then asked if I could convert that SimpleAction type into a matrix, so we could have a clearly defined Y. This was also incredibly easy. I am actually quite happy with how it works as well. All you have to do to create an array for the action is two steps! matrix = numpy.zeros(26) if action is not SimpleAction.INVALID:     matrix[action] = 1; The 26 is the number of different Simple Actions we have. Then, to make it so we can run the parser separately from the Agent, I made it the replay can output numpy files for each character where each row in the file contains the frame of...