| """Watch the wood run under the dummy random policy. Sanity/feel check, no LLM. | |
| Run: python scripts/run_random.py | |
| """ | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| from ttw.dummy import make_random_policy | |
| from ttw.market import gini | |
| from ttw.sim import step | |
| from ttw.world import seed_world | |
| def main(turns: int = 12) -> None: | |
| world = seed_world() | |
| policy = make_random_policy(seed=7) | |
| for _ in range(turns): | |
| events = step(world, policy) | |
| trades = [e for e in events if e["type"] == "trade"] | |
| prices = " ".join(f"{g}={p:.0f}" for g, p in world.last_price.items()) | |
| nets = [c.net_worth(world.last_price) for c in world.alive()] | |
| print(f"turn {world.turn:>2} | {len(trades)} trades | gini {gini(nets):.2f} | {prices}") | |
| for t in trades: | |
| print(f" {t['buyer']:<9} bought {t['qty']} {t['good']} from {t['seller']:<9} @ {t['price']}") | |
| print("\nFinal standings:") | |
| for c in sorted(world.alive(), key=lambda x: -x.net_worth(world.last_price)): | |
| print(f" {c.name:<9} pebbles={c.pebbles:>4} wellbeing={c.wellbeing} net={c.net_worth(world.last_price):.0f}") | |
| if __name__ == "__main__": | |
| main() | |