Originally Posted by
Fran
Could you explain the algorithm in detail? I've been interested in writing a Toribash AI, Toribash is not like most turn-based games and you can't use minimax/alpha-beta pruning.
I've thought about it and was thinking of training by doing self-play and a population-based Nash equilibrium bot.
Hey Fran i remember you, market bot pioneer 😁👹
Yeah, minimax/alpha-beta does not really fit Toribash.
What I’m using right now is not a search bot. It is reinforcement learning with self-play.
More specifically, the current version uses RLlib APPO, which is basically a distributed actor-critic / PPO-style training algorithm. Instead of looking ahead through a game tree, the bot plays huge numbers of real Toribash matches, gets rewarded or punished for what happened, and slowly changes its policy.
The rough pipeline is:
1. Toribash runs normally.
2. A Lua script inside Toribash reads the game state.
3. Python receives that state through a local TCP bridge.
4. The neural network chooses the next joint/grip action.
5. Python sends the action back to Toribash.
6. Toribash advances the turn.
7. Repeat for millions of turns/matches.
The policy sees things like:
- own body positions and velocities
- opponent body positions and velocities
- joint states
- grips
- injury difference
- current frame/turn
- distance from dojo edge
- center-of-mass information
- hand distance to opponent
- balance/stability signals
- DQ/ring pressure
The action is not pure random control of every joint from scratch anymore. For ABD I use an action space based on ABD-style templates plus residual overrides.
So the network first picks one of several broad ABD action templates, then it can override individual joints and grips. That makes the search space smaller and more Toribash-shaped than saying “pick all joints blindly every turn”.
Training is a mix of:
- current policy vs current policy
- current policy vs random
- current policy vs recent checkpoints
- current policy vs the current champion checkpoint
- current policy vs finalist/top checkpoints from sweeps
So your idea of population-based / Nash-style self-play is pretty close to where this is going.
It is not a true Nash equilibrium solver right now. I’m not calculating an exact mixed strategy equilibrium over a payoff matrix. It is more practical: a league system. The bot trains against a population of old versions so it does not just overfit to beating itself today and forget how to beat yesterday’s versions.
Current opponent sampling is roughly weighted toward strong opponents:
- some pure self-play
- very little random
- some recent checkpoints
- a lot of champion pressure
- some finalist/top checkpoint pressure
Every checkpoint gets evaluated separately. Evaluation does not directly train the model, but it decides which checkpoints are strong, which ones become champion/finalists, and therefore which opponents future training uses.
Reward is also not just “win good, lose bad”. ABD needs shaping or the bot discovers dumb survival tricks. Current reward includes:
- terminal win/loss reward
- injury advantage
- DQ/ring pressure
- edge safety
- useful grips
- balance/stability only when actually fighting
- tie penalty
- anti-stall penalty
- phase-based control rewards
That last part was important because it started learning tripod/stall behavior. Good balance, bad fighting. So now stability is rewarded only when connected to useful activity, not just “stand there and survive”.
In simple terms:
The bot is learning a policy:
“given this Toribash state, what joint/grip move gives me the best long-term chance to win against this pool of opponents?”
Not:
“calculate every possible future move and pick the best one.”
Toribash is too continuous/physics-heavy/weird for classic tree search to be practical.
Long term, a more formal population/Nash system could make sense: keep a payoff matrix between checkpoints, build a league, sample opponents based on exploitability, maybe train specialist counter-policies. But the current working version is APPO self-play + checkpoint league + champion sweeps.
Last edited by AlteredCode; Jun 9, 2026 at 02:26 AM.