Alpha-Beta Pruning Calculator

Read the Theory Guide →

Build a game tree, enter your own leaf values, and step through Alpha-Beta Pruning to see how values and bounds move through the tree.

What You Can Explore

  • Build and modify the game tree by adding, connecting, moving, or deleting nodes.
  • Change leaf values and run the solver to see how the final result responds to your inputs.
  • Step through the search to follow updated node values and α\alpha and β\beta bounds at each stage.
  • Change the tree structure or branch order and compare which parts of the tree are evaluated or pruned.
Core Mechanics
▼
  • MAX only updates α\alpha: It starts at −∞-\infty because MAX is searching for the highest possible value. α\alpha represents the best score MAX is guaranteed so far.
  • MIN only updates β\beta: It starts at +∞+\infty because MIN is searching for the lowest possible value. β\beta represents the best score MIN is guaranteed so far.
  • Down vs. Up: The boundary limits (α\alpha and β\beta) flow down the tree. The evaluated leaf scores flow up the tree.
  • The Cutoff: If α≥β\alpha \ge \beta at any node, the algorithm instantly stops evaluating that branch. The opponent would never allow this path to be reached!
Initializing Workspace...

Understanding Your Result

The solver calculates the result from the tree and values you entered. Use the step-by-step states to follow how values and α\alpha and β\beta bounds move through the tree and identify where branches are pruned.

  • The final value at the root represents the result determined from your current game tree.
  • Each step shows the current tree state, including updated node values and the α\alpha and β\beta bounds reaching the nodes.
  • Dashed and faded branches marked as pruned were skipped once the search determined they could no longer affect the current decision.
  • Compare different runs to see how changing values, structure, or branch order can change the search while producing the same or a different final result.

Try These Experiments

Change the Branch Order

Setup: Run the preloaded tree and note which branches are evaluated and which are pruned.

Action: Change the order in which branches are explored while keeping the leaf values unchanged, then run the solver again.

What to Observe: Step through both runs and compare when the bounds become restrictive and how many branches are eventually pruned.

Takeaway: The order in which branches are explored can change how much of the tree the solver needs to evaluate, even when the final result stays the same.

Change a Pruned Leaf

Setup: Run the solver and identify a leaf inside a branch marked as pruned.

Action: Change that leaf to a substantially different value while leaving the rest of the tree unchanged, then run the solver again.

What to Observe: Check the final root value and the step states to see whether the changed leaf was ever needed by the search.

Takeaway: A branch that has already been pruned does not need to be evaluated for that search, so changing a skipped value may leave the final result unchanged.

Test the α=β\alpha = \beta Boundary

Setup: Step through the solver until you find a node where the current α\alpha and β\beta bounds can become equal.

Action: Adjust a leaf value so that the relevant bounds meet exactly, then run the solver and inspect the resulting tree state.

What to Observe: Look at the step where the bounds become equal and check which remaining branches are marked as pruned.

Takeaway: The interactive steps let you observe the cutoff boundary directly and verify what happens when α\alpha and β\beta meet.