① Rational — classic maxN
Each player picks the child that maximises their slot in the (P1, P2, P3) tuple. Utility = own. The baseline selfish agent.
② Cooperative — alliance
Utility = own + w × ally. A cooperative player sacrifices personal score to benefit their ally. This changes which branch they choose, demonstrating that rational self-interest and cooperation diverge.
Example (w=1): option (3,5,2) scores 3+5=8 vs (5,1,1) scoring 5+1=6 → cooperative P1 gives up 2 own points to give ally 4 extra.
③ Spiteful — dushmani
Utility = own − w × enemy. The spiteful player penalises outcomes that benefit their enemy, even at personal cost. Common in political games, predatory pricing, competitive auctions.
Example (w=1.5): option (3,4,1) scores 4−1.5=2.5 vs (2,5,4) scoring 5−6=−1 → spiteful P2 accepts lower own score to crush enemy.
④ Zero-sum
Utility = own − Σ(others). When scores sum to a constant across all leaves, this is equivalent to 2-player minimax MAX — maximising own = minimising everyone else. Verify this equivalence using the simulator.
⑤ Alpha-Beta with alliances
Standard 2-player α-β requires zero-sum. For 3 non-zero-sum players this solver uses shallow pruning (Luckhardt & Irani, AAAI-86): each player tracks a floor — the best utility they secured at the nearest ancestor where they moved. A branch is pruned when the current player's best already meets that floor.
All algorithms run server-side in Python. The browser sends your tree as JSON, Python solves it, and sends back the annotated result.
Luckhardt, C. A., & Irani, K. B. (1986). An algorithmic solution of N-person games. AAAI-86, 158–162.