Concepts / Evaluation Functions in Game-Playing Programs

Evaluation Functions in Game-Playing Programs

Samuel's evaluation function judged checkers positions and guided the program's decisions.

  • Programming

From Moves to Judgments

A game-playing program cannot choose a move merely because the move looks attractive. It needs a way to judge the resulting checkers position: does the move improve the program's position relative to its opponent? Samuel's checkers program addressed this problem with an evaluation function. Its most important component was the piece advantage feature, which compared the program's pieces with the opponent's pieces.

The evaluation function converted information about a checkers position into guidance for choosing between possible moves.

The Evaluation Pipeline

The process can be understood as a pipeline. First, the program considers a board position. It identifies the program's pieces and the opponent's pieces. The piece advantage feature compares those two sides and contributes an important judgment about the position. The evaluation then guides decisions toward positions that improve the program's advantage.

providesproducescontributes toguidesBoard positionpiece informationPiece comparisonprogram and opponentPiece advantageimportant featurePosition evaluationfavorable or unfavorableMove guidanceimprove advantage
How does a checkers position become an evaluation that helps guide a move?

Piece Advantage

Piece advantage is the feature that compares the program's pieces with the opponent's pieces as part of judging a checkers position.

This comparison made piece advantage central to Samuel's evaluation function. The program was not only asking what move was immediately available. It was judging whether the move led to a position in which its pieces compared more favorably with the opponent's pieces. The feature therefore connected the board's piece situation to the program's decision-making.

comparedcomparedProgram's piecesone sidePiece advantagecomparison featureOpponent's piecesother side
How are the program's pieces compared with the opponent's pieces to form piece advantage?

A Qualitative Piece Comparison

Suppose two candidate moves lead to different positions. In one position, the program's pieces compare more favorably with the opponent's pieces than they did before the move. In the other, the comparison is less favorable.

Inspect the position: The program considers the pieces belonging to both sides.

Apply piece advantage: The program compares its pieces with the opponent's pieces as an important part of the evaluation.

Use the evaluation: The comparison helps guide the program toward the position that improves its advantage.

Piece advantage links the contents of a position to the decision about which direction is more favorable.

The Role of Kings

Samuel's feature did not treat every piece as having the same value. Kings received higher weight than ordinary pieces. This means that the feature responded not only to how many pieces each side possessed, but also to what kind of pieces they were. A position containing a king could therefore contribute differently to the evaluation from a position containing the same number of ordinary pieces.

higher weightOrdinary piecelower contributionKinghigher contribution
How does changing a regular piece into a king change the value assigned to that piece in the evaluation?

Same Count, Different Piece Types

Imagine two positions with the same number of pieces for a side. In the first position, the side has only ordinary pieces. In the second, one of those pieces is a king.

Compare the counts: A simple count would see the same number of pieces in both positions.

Compare the types: Samuel's feature also distinguishes ordinary pieces from kings.

Apply the ordering: Because kings receive higher weight, the king contributes more strongly than an ordinary piece.

The feature is sensitive to piece type as well as piece number, without requiring a numerical king value to be specified.

Trading Pieces by Situation

A simple piece count would treat every exchange in the same way. Samuel's feature was refined to account for the program's situation. Trading pieces was treated more favorably when the program was winning than when it was losing. The same general kind of exchange could therefore receive different treatment depending on the current relationship between the program and its opponent.

statusstatusevaluatesevaluatesPositioncurrent situationWinningprogram aheadTrademore favorable treatmentLosingprogram behindTradeless favorable treatment
How does the program's treatment of a piece trade change depending on whether it is winning or losing?

One Exchange, Two Situations

Consider a trade of pieces. Compare the program's evaluation of that trade when the program is already winning with its evaluation when the program is losing.

Winning situation: The feature treats trading pieces more favorably when the program is winning.

Losing situation: The feature treats trading pieces less favorably when the program is losing.

Interpret the difference: The evaluation is not based only on the fact that pieces were exchanged; it also reflects the program's situation on the board.

Trading pieces is situation-dependent in the refined feature: more favorable while winning and less favorable while losing.

Common Misreadings

  • Treating piece advantage as a simple total piece count.

    Kings received higher weight than ordinary pieces, so the feature considered piece type as well as piece number.

    Fix: Describe piece advantage as a comparison of the two sides that gives kings a stronger contribution.

  • Assuming the source provides an exact numerical value for a king.

    The source specifies only that kings received higher weight; it does not specify the numerical weight.

    Fix: State the ordering: king contribution is higher than ordinary-piece contribution.

  • Saying that trading pieces always has the same evaluation.

    The feature was refined so that trading pieces was treated more favorably when winning than when losing.

    Fix: Include the program's current situation when explaining the treatment of a trade.

  • Separating piece advantage from move decisions.

    The evaluation function used the judgment of positions to guide the program's decisions.

    Fix: Explain the chain from board position to piece comparison to evaluation to move guidance.

Check Your Understanding

MEDIUM

Explain, in your own words, why a piece advantage feature that counts only pieces would miss information that Samuel's feature included. Then explain why the treatment of a trade could differ between a winning position and a losing position.

Hints
  • Start with the difference between an ordinary piece and a king.
  • Then connect the program's current situation to the evaluation of trading pieces.
  • Do not invent a numerical weight unless one is provided.
  1. Samuel's evaluation function judged checkers positions and guided the program's decisions.
  2. Piece advantage was its most important component and compared the program's pieces with the opponent's pieces.
  3. Kings received higher weight than ordinary pieces, so piece type mattered as well as piece count.
  4. Trading pieces was treated more favorably when the program was winning than when it was losing.
  5. The evaluation connected board information to move guidance rather than treating a move in isolation.

Key Takeaways

  • Samuel's checkers program used an evaluation function to judge positions and guide decisions.
  • Piece advantage compared the program's pieces with the opponent's pieces and was the central feature.
  • Kings contributed more strongly than ordinary pieces, although the source does not give a numerical weight.
  • The feature treated trading pieces differently according to whether the program was winning or losing.