> LAB.07 // MULTI_AGENT_SOCIETY.in_vitro
In vitro market
A society of fishes, sharks and whales, bound by a trust matrix, trading one asset: $HOPIUM. Tune their instincts, poke them with god-mode buttons, and count the damage.
- fish
- shark
- whale
- bought today
- sold or shorted today
- trust 01
- click an agent to inspect it
money won or lost by each class since day 0, scaled to humanity — who's taking whose money?
about the model
MAS — Multi Agent Society — is a model Andrei built during his MSc in Physics of Complex Systems (University of Turin, 2023) to simulate cryptocurrency markets. Agents live on a Barabási-Albert network; every link carries a level of trust between 0 and 1. When two linked agents' profits move together, their trust grows; when they diverge, it decays.
Each day every agent decides, then the exchange clears all orders at once:
ln P′ = ln P + μ · (buy$ − sell$) / depth, and everybody trades at the new price.
Depth grows with the price, a circuit breaker caps a day at −50% / +100%, and shorts that lose their
collateral are liquidated. The exchange caps daily short selling — unless you press deregulate.
A crash is −30% within two weeks; a bubble is ×2 within two months.
The society is humanity: each agent stands for 8 billion ÷ agents people (40 million at 200 agents). The two default whales are 80 million millionaires — about what the real world has — and the fishes are 6.3 billion people with $1,000 each. Every dollar in the ledger is what those people actually won or lost.
- Fish — retail. Holds $HOPIUM or cash, never shorts. Buys when its trusted friends buy (all in, during FOMO), trims its bag when they sell, panics with the timeline after a rug pull. Drops friends below its trust threshold, sleeps.
- Shark — never trades randomly. Copies the positions of the most popular agents, but only when they agree with its own belief on the market (bullish, bearish, lateral).
- Whale — rich and semi-periodic. Accumulates in silence; once its bag is big it goes loud, recruits followers and posts about its position every day — and keeps posting while it sells that position to them (distribution), until its profit streak (WPS) is cashed in.
what changed from the 2023 code
This sandbox is a TypeScript port of the original Python/Mesa code, running in your browser, seeded so a shared link replays the same run. While porting it, the 2023 price rule turned out to be a money printer: only opening a position moved the price, selling never did, and everybody traded at yesterday's price — so herding fishes profited from their own price impact, 83% of them ended in profit, and wealth appeared from nowhere. Now every trade moves the price and fills at the day's clearing price, price impact is measured in value (so cheap prices don't explode order sizes), and loud whales stay loud while distributing, as the paper describes. Result: the market is (almost) zero-sum again, whales profit at the expense of fishes and sharks, and a higher WPS makes them richer — the paper's Figure 4, for real. Fishes became spot holders (the 2023 ones shorted at random and emptied their wallet half the days, so they profited from crashes), and price impact was recalibrated so μ = 5% gives crypto-like days. Smaller fixes: trust clamped to [0, 1], whales counted in the population and the short-selling cap, nobody trusts themselves.
Read the paper · the original code ·