Who's That Pokemon TCG: Online game to test your card art knowledge

Finally got our answer haha

ex done

3 Likes

I’m glad people are having fun with it! And finding it difficult haha.

We wanted to make it sort of like GeoGuessr
 If you played long enough you would be able to get a great score and people would find it impressive. But on first try, there would be no way you could score 100%.

I would recommend two QOL improvements that are relatively simple and will go a long way.

  1. make the user input and the answer both lowercase before comparing them (to remove case sensitivity)

  2. use Levenshtein distance to allow a certain amount of typos. It will calculate the number of differences between the user input and the answer. If it’s below a threshold, treat it as correct. The downside is that porygon will also work as an answer for porgon2 but the upside is the user doesn’t have to google the proper spelling of the name for every answer

ChatGPT implementation:

function levenshteinDistance(s, t) {
  // Create a matrix
  const d = [];

  // Initialize the first row and column of the matrix
  for (let i = 0; i <= s.length; i++) {
    d[i] = [i];
  }
  for (let j = 0; j <= t.length; j++) {
    d[0][j] = j;
  }

  // Populate the matrix
  for (let i = 1; i <= s.length; i++) {
    for (let j = 1; j <= t.length; j++) {
      const cost = s[i - 1] === t[j - 1] ? 0 : 1;
      d[i][j] = Math.min(
        d[i - 1][j] + 1, // deletion
        d[i][j - 1] + 1, // insertion
        d[i - 1][j - 1] + cost // substitution
      );
    }
  }

  // The Levenshtein distance is in the bottom-right corner of the matrix
  return d[s.length][t.length];
}

// Function to check if the Levenshtein distance is less than a given threshold
function isLevenshteinDistanceLessThan(s, t, threshold) {
  return levenshteinDistance(s, t) <= threshold;
}
// Example usage
const str1 = "kitten";
const str2 = "sitting";
const threshold = 3;

console.log(isLevenshteinDistanceLessThan(str1, str2, threshold)); // Output: true or false depending on the threshold
1 Like

Good call on the first one. Is Ho-Oh is the edge case that can disrupts this? Regardless that’s how the comparison should be done but I’m wondering what Pokemon is breaking the current comparison logic? as it seems like all names from the API are lowercase.

And the 2nd point we’ve debated. We didn’t know if misspelling would be a big problem since you could also Google it and the game wasn’t on a timer. We also considered just adding another option to make spelling more forgivable.

But considering that there have been many mobile users & the feedback we’ve gotten, Googling the spelling is definitely a hassle. We will update it to make spelling more forgiving. Thanks!

1 Like