While reverse engineering Animal Crossing I was asked to look into how the game’s letter system worked. How do the villager NPCs interpret your letters? The original Twitter thread can be found here. The thread text is reproduced below.

Letter system thread

I got a question from Cris asking about how the characters in Animal Crossing “read” the letters that you send them and come up with a response. Specifically, what’s required for a good response with a gift? I’ve also been curious about this, so I took a look at how it works…

As soon as you drop off a letter at the post office it’s given a score. The score is determined by a series of 7 different checks, labeled A through G.

  • A: Checks for punctuation at the end of sentences, and capital letters. A ‘.’, ‘?’, or ‘!’ symbol at the end of the letter grants 20 points. After that, every punctuation mark must be followed by a capital letter within 3 spaces (+10 or -10 each occurrence)
  • B: Checks the beginning of each word for common trigrams, using this lookup table: https://github.com/jamchamb/ac-letter-score/blob/master/trigram_table.txt The total number of trigram hits is multiplied by 3 and added to the score.
  • C: This checks for the first (non-space) character in the letter. If it’s a capital letter, gives +20 points. If not, -10 points.
  • D: If a letter of the alphabet is repeated three times in a row, deducts 50 points and stops checking. Otherwise it does not affect the score.
  • E: Checks ratio of spaces to non-spaces in the letter. If it’s all spaces, or (n_spaces * 100 / n_other) is less than 20, gives -20 points. Otherwise, +20 points.
  • F: If the letter is more than 75 characters long and goes on for at least 75 characters without any punctuation (., ?, !), it deducts 150 points!
  • G: Checks each group of 32 characters for at least one space. Deducts 20 points for each group that doesn’t have one.

Overall, a letter that uses proper punctuation, capitalization, has a decent word count, and uses common words (or at least words that begin with common trigrams) will get the highest score. You get a good reply if the score is 100 or above, or a bad reply if it’s under 50.

That’s actually exactly what the animals recommend you do when you talk to them (use proper punctuation, capitals, etc.), but there’s always been a lot of mystery around how it actually works and why some letters that seem OK get bad replies (maybe they had many uncommon words).

The score affects how many friendship points you earn with the recipient. A bad letter has a base score of -1, good letters have a base score of 3. Attaching a present boosts the score by 3, so you can at least get 1 point with a nonsense/bad letter.

In general, a good letter has a random chance of getting a gift (clothing or furniture) with the reply. However, if a special quest/event has occurred, a different set of checks are used for yet another ranking algorithm that selects from a larger variety of rewards.

The special reply ranking system is based only on trigram counts and excess repeating characters. It gets the trigram hit count and percentage of trigram hits in the entire letter. 0 to 2 points are awarded based on trigram percentage.

Another 3 points are awarded if there are no non-space characters repeated 3+ times, except for a specific set of characters than can repeat up to 7 times (!, ?, -, %, @, 💢). Finally, 6 points are awarded if a present is attached to the letter.

If the rank is above 3 you’ll get a gift. Each rank above 3 causes a different group of items to be selected for the reply gift, including furniture, wallpaper, carpets, fruit (foreign or local), and clothing.

Referenced in