Dynamic Programming21 sections · 916 units
Open in Course

Challenge: Knight Expected Moves

Expected value variant

Instead of probability, find the expected number of moves before the knight leaves the board. Let E[r][c]E[r][c] = expected moves from (r,c)(r, c). If on board: E[r][c]=1+18E[next]E[r][c] = 1 + \frac{1}{8} \sum E[next] where nextnext are valid destinations. Off-board destinations contribute 0 (no future moves).

This creates a system of equations. Solve iteratively: initialize all E=0E = 0, then update until convergence. Or use Gaussian elimination for exact solution.