Intro
An n-gram is a sequence of n adjacent items (e.g. words or characters) from a text. N-grams slide a fixed-size window over text, helping models learn common patterns like phrases, word order, and context
Example
“The quick brown fox jumps over the lazy dog”
Unigrams (n = 1)
- The
- quick
- brown
- fox
Bigrams (n = 2)
- The quick
- quick brown
- brown fox
Trigrams (n = 3)
- The quick brown
- quick brown fox
N-grams in Games
N-grams can be applied to Game AI as a simple prediction mechanism by modeling sequences of behavior. 1
For example, if a player frequently performs the sequence:
- Strafe → Shoot → Reload
The AI can learn to dodge when the player is likely to shoot and rush/engage aggressively during reload



