October 2025: Robot Baseball
Well, this was one of the easiest Jane Street puzzles I’ve seen yet. It was still pretty cool, don’t get me wrong — I just don’t have much to say about it this month.
Stats:
Difficulty: 2/10
Enjoyability: 5/10
Leaderboard Placing: 29/777
The approach:
Fix \(p\), and let \(V : \{0,1,2,3,4\} \times \{0,1,2,3\} \to \mathbb{R}\) denote the value function (i.e. expected score) for each state assuming optimal play (where the components correspond to ball count and strike count respectively). We similarly have functions \(x,y : \{0,1,2,3\} \times \{0,1,2\} \to [0,1]\) denoting the batter’s probability of swinging and the pitcher’s probability of throwing a ball, and \(R : \{0,1,2,3\} \times \{0,1,2\} \to [0,1]\) denoting the probability of reaching the state \((3,2)\) when starting from state \((b,s)\), all assuming optimal play.
One can recursively compute \(x(b,s)\), \(y(b,s)\), and \(V(b,s)\) from \(V(b+1,s)\) and \(V(b,s+1)\), so starting from \(V(4,s) = 1\) and \(V(b,3) = 0\), one easily obtains all values of \(x\), \(y\), and \(V\). (Note: x and y are characterised by giving unchanged expected scores assuming the opposite player makes either of the two available deterministic choices.) One can then recursively compute \(R(b,s)\) from \(x(b,s)\), \(y(b,s)\), \(R(b+1,s)\), and \(R(b,s+1)\), so starting from \(R(3,2) = 1\), one easily obtains all values of \(R\).
The above recursions can be coded in a simple Python function, expressing \(q = R(0,0)\) as a function of \(p\). The maximum of this function can then be found to the desired accuracy by any number of simple optimisation algorithms.