JSON-Bag: A generic game trajectory representation
Dien Nguyen, Diego Perez-Liebana, Simon Lucas · 2025
Read JSON-Bag: A generic game trajectory representation by Dien Nguyen, Diego Perez-Liebana, Simon Lucas (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2508-00712.txt.
Introduction
Dien Nguyen, Diego Perez-Liebana, and Simon Lucas turn game logs into word bags in a 2025 paper. A game run can be writ as a text file of states and acts. If that text is cut to bits and counted, two runs can be set side by side by how their bags differ.
Their test bed spans six board and card games. For each, runs must be sorted by who played, by the game set-up, or by the seed that dealt them. Set next to a hand-built trait list, the bag way wins most tasks and learns from few runs. Game study gains one tongue for all games.
Catalog record
| CREATOR | Dien Nguyen, Diego Perez-Liebana, Simon Lucas |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 37 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2508-00712
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
JSON-Bag: A generic game trajectory representation Dien Nguyen, Diego Perez-Liebana, Simon Lucas Abstract We introduce JSON Bag-of-Tokens model (JSON-Bag) as a method to generically represent game trajectories by tokenizing their JSON descriptions and apply Jensen-Shannon distance (JSD) as distance metric for them. Using a prototype-based nearest-neighbor search (P-NNS), we evaluate the validity of JSON-Bag with JSD on six tabletop games— 7 Wonders , Dominion , Sea Salt and Paper , Can’t Stop , Connect4 , Dots and boxes —each over three game trajectory classification tasks: classifying the playing agents, game parameters, or game seeds that were used to generate the trajectories. Our approach outperforms a baseline using hand-crafted features in the majority of tasks. Evaluating on N-shot classification suggests using JSON-Bag prototype to represent game trajectory classes is also sample efficient. Additionally, we demonstrate JSON-Bag ability for automatic feature extraction by treating tokens as individual features to be used in Random Forest to solve the tasks above, which significantly improves accuracy on underperforming tasks. Finally, we show that, across all six games, the JSD between JSON-Bag prototypes of agent classes highly correlates with the distances between agents’ policies. I Introduction Defining features and representations for games and their corresponding distance/similarity metric is foundational for any task that requires game analysis. Designing agents to play a game in a certain way (either to optimize playing strength [ 1 ] , model human players [ 2 ] , or optimize playstyle diversity [ 3 ] ) often requires hand-crafted features using domain knowledge. Automated game design and content generation requires defining game metrics to evaluate generated solutions [ 4 ] . In these tasks, instead of only optimizing for the targeted fitness functions, optimizing also for diversity and novelty in the solution population can produce better results [ 5 ] [ 3 ] . Diversity in the population is usually enforced by either defining behavior criteria that partition the search space [ 6 ] or using a distance metric to evaluate the novelty of new solutions [ 5 ] . Data mining and analysis of game data, such as playstyle clustering [ 7 ] , also use distance and similarity metrics to discover patterns in the data. In the majority of cases, features and representations are defined manually using domain knowledge or automatically using deep-learning models. The latter case often still requires feature engineering and further tuning to adapt to specific use cases. The distance and similarity metrics of choice are typically Euclidean distance [ 7 ] and cosine similarity [ 8 ] . This work proposes the JSON Bag-of-token model (JSON-Bag) to generically represent game trajectories by tokenizing their JSON descriptions. The JSON representation for a game trajectory is simply formed by concatenating the JSON of individual game states, serialized from the game objects’ data, into a list. A JSON-Bag is a collection of token-occurrence count pairs from tokenizing the game trajectory in JSON. We interpret JSON-Bag as a probabilistic model of game trajectories and use the Jensen-Shannon distance (JSD) [ 9 ] to measure similarity between them. To validate our approach, we test it on six tabletop games— 7 Wonders , Dominion , Sea Salt and Paper , Can’t Stop , Connect4 , Dots and boxes , each on three classification tasks: classifying different playing agents, game parameters, and game seeds. For each task, a classifier uses JSON-Bag as the representation to classify game trajectories into the correct class of agents, game parameters, or game seeds that have been used to generate the trajectories. Using a prototype-based nearest neighbor search algorithm (P-NNS), we compare JSON-Bag with JSD against a baseline with hand-crafted features and Euclidean distance and show that our approach outperforms the baseline in the majority of cases. The first three games above have many unique game components, therefore sensible hand-crafted features are easy to define and the JSON-serialized game states are rich in information. We call the other three games “sparse” games, meaning they have few unique game components. For example, 7 Wonders has coins, material resources, and multiple unique cards, while Connect4 only has a grid with a unique board piece type for each player. For sparse games, their JSON descriptions are therefore not as informative and P-NNS performance degrades. However, by applying Random Forest (RF) with minimal tuning, JSON-Bag performance significantly improves on tasks P-NNS underperformed, especially on sparse games. This further validates JSON-Bag’s ability for automatic feature extraction and suggests the potential to use JSON-Bag with more sophisticated feature selection methods and models that can learn interactions between features. A JSON-Bag prototype of a class is a single JSON-Bag that best represents a class of game trajectories. We evaluate N-shot classification for JSON-Bag P-NNS to show that JSON-Bag prototypes efficiently represent game trajectory classes, only needing a few samples per class to accurately classify classes with “obvious” differences. This is useful for the application of diversity/novelty search, such as in playstyle modeling [ 3 ] , to determine the novelty of new solutions. JSON-Bag prototype being sample efficient means a new solution would not require many game trajectories for its novelty to be estimated by JSD. We compare the JSD between JSON-Bag prototypes of different playing agent classes to their actual behavioral differences. The JSD of JSON-Bag prototypes is found to be highly correlated with the average distance in the agents’ policies. The main contributions of this paper are: • JSON-Bag : A method to generically represent game trajectories using only the JSON descriptions of individual game states for tokenization. We describe a domain-agnostic method of tokenizing that works well across a diverse range of tabletop games. JSON serialization is general and many game implementations are able to either directly serialize game states to JSON or require little coding effort. JSON-Bag enables comparing JSON game logs without further domain-specific processing. • We show that game trajectory similarity can be evaluated using a probabilistic interpretation of JSON-Bag with Jensen-Shannon distance , a probability distribution distance metric well-founded in information theory. • We demonstrate the sample efficiency of JSON-Bag prototypes for game trajectory classes representation and their ability to automatically extract game features to be used in other methods of feature selection. • We show that the JSD between JSON-Bag prototypes of different types of agents highly correlates with their behavioral difference measured by a policy distance. II Background In traditional board game research, abundant work has been done to determine which game features to extract for different tasks (game-playing agents, game analysis, procedural content generation, etc.). In Go, Silver et. al. [ 1 ] use local board features in a value function approximator to build a strong playing agent. Browne [ 4 ] introduces an extensive set of game metrics to evaluate the overall game structure and aesthetics in the context of automated board game generation. With the advances of deep learning, AlphaZero is a framework taking advantage of neural networks’ ability for automatic feature learning and self-play reinforcement learning to build a superhuman Go, Chess, and Shogi agent without domain knowledge [ 10 ] . In video games, due to more complex game dynamics, hand-crafted features are difficult to define, so a common choice of game state representation is the raw pixels and the game