Agent-based modeling in JavaScript in the browser or on the server. [v0.5.19]

Minority Game

In the minority game (based on the NetLogo model of the same name), agents make a guess of either 0 or 1 with each tick of the simulation. After each tick, the goal for each agent is to be in the minority (guessing the same as less than half of all other agents).
Agents are initialized with a set of strategies — binary strings, i.e. 010111011000… — and the history of recent winning (minority) guesses are stored as another binary string. A strategy ‘chooses’ the agent’s guess by converting the history to a decimal number (i.e. 1101 → 13) and selecting that digit from the strategy (which is always either 0 or 1). After each tick, an agent updates the scores of all its strategies and selects the one with the highest score, using it for subsequent guesses. Although this behavior is somewhat opaque, it does result in unpredictable, chaotic behavior as agents attempt to guess at and outperform the market.