Diego Malagrida Calculator Game Solver ↑ Top

Authors Diego Malagrida GonzálezAndreu Massanet Felix

Published27 May 2026

Sectionalgorithms

Calculator Game Solver

A two-player counting game solved by dynamic programming, with the winning move shown for any position you can reach.

The application window with a calculator keypad on the left and the table of played turns on the right.
The keypad, and the turn-by-turn record of a match.

Overview

A Java Swing application that solves the calculator game with dynamic programming, plays it against you with perfect-play hints and a live decision tree, and benchmarks a family of solver strategies.

Two players take turns adding a digit to a running total, and which digits are legal depends on where the last one sat on the keypad. Whoever reaches 31 or goes past it loses. The game is finite, deterministic and fully observable, so optimal play is not a matter of judgement: the value of a position follows from the values of the positions it leads to, and the solver can name the winner from any state on the board.

Because every position is solved, the interactive mode can show the perfect move while you play, and the benchmark can compare solver strategies knowing they all agree on the answer.

Project 5 of 7 for the Advanced Algorithms course at the Universitat de les Illes Balears, the one on dynamic programming.

javadynamic-programminggame-theory

← All projects