quis

2 items

How did it work/ Lessons learned.md

SFV Frame Data App.md

How did it work/ Lessons learned

How did it work?

Unfortunately, Capcom doesn’t have a public web API to access their frame data table, so we relied on web scraping to build our character JSON models. At the time, I chose JavaScript for Amazon Skill Development, though today I would use Python, especially for the scraping portion, mistake number 1. I had a separate script that took a link to a character’s movelist (where the frame data was), scraped that page, and outputted a JSON file with the frame data. If I remember correctly, I ran the script manually 40 times (once per character) to build the dataset for the Alexa Skill. I stored this data model locally and built it with the app; that was mistake number 2. I did the rest of the skill development in the index.js file, where I wrote handlers for the different intents (voice commands).

This works by taking a user’s voice command and breaking the sentence into predefined “slots.” Take the command: “How many frames is Chun-Li’s standing fierce on block?”

This would be broken into the following slots:

characterName = "Chun Li"
frameType = "Block"
normalMoveMapping = "HP" (Fierce = Heavy Punch)

We would fill the appropriate slots and use the inputs to determine what we needed to look up and where. The characterName was the first value, telling us which file to search; the move mapping told us which value in our Normal moves block to look for, and the frame type told us which value to return.

Here’s what the model looked like:

{
    "Chun-Li": {
        "Fireball": "Kikoken",
        "DP": "EX Spinning Bird Kick",
        "Normal Moves": {
         ...
                "Standing HP": {
                "moveCommand": "",
                "startUpFrames": "11",
                "activeFrames": "2",
                "recoveryFrames": "18",
                "framesOnHit": "0",
                "framesOnBlock": "-4",
                "vTriggerCancelHit": "",
                "vTriggerCancelBlock": "",
                "moveProperties": "High",
                "moveType": "Normal Moves"
            },
        }
      }   
}

This command would then return -4, which may or may not still be accurate today (due to mistake 2)

Lessons Learned:

  1. Use Python for web scraping. I used Cheerio to scrape the Character’s moves and build my dataset, which was fine and got the job done. At the time, I had no complaints about using Cheerio, but now, 6 years later, I have switched from JavaScript to Python and used BeautifulSoup for web scraping, which would have saved me so much time and lines of code. BeautifulSoup just felt much more developer-friendly and ergonomic when it came to parsing HTML files

  2. Do not store “live” data models locally. This mistake came from a combination of limited fighting game experience and limited developer experience. I was new to this “patch” era of fighting games, where developers periodically added new characters, moves, mechanics, and frame data. This meant that every few months, a frame-data update required updating the entire app. I couldn’t keep up with all the updates and eventually stopped, so the frame data is likely outdated and will probably remain so. Storing the model data locally improved performance because our app didn’t have to make a network request to fetch any data, but the trade-off was stale data. If I did this today, I would store all the models in a database (Firebase or Supabase) and have the app query it to fetch the data. Latency is a concern if users ask mid-match, but we can assume their Alexa device is connected to Wi-Fi, so the latency may not be a major concern. The main benefit of this approach was that following the game updates would be a simple database update and could probably be handled entirely by a script.