Concepts / Evaluation Functions in Game-Playing Programs

Evaluation Functions in Game-Playing Programs

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

  • 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.

Key point

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.

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

Piece Advantage

Definition

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.

Program's piecesone sidePiece advantagecomparison featureOpponent's piecesother sidecomparedcompared
How are the program's pieces compared with the opponent's pieces to form piece advantage?
Worked example

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.

  1. 1
    Inspect the position

    The program considers the pieces belonging to both sides.

  2. 2
    Apply piece advantage

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

  3. 3
    Use the evaluation

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

Result

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.

Ordinary piecelower contributionKinghigher contributionhigher weight
How does changing a regular piece into a king change the value assigned to that piece in the evaluation?
Worked example

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.

  1. 1
    Compare the counts

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

  2. 2
    Compare the types

    Samuel's feature also distinguishes ordinary pieces from kings.

  3. 3
    Apply the ordering

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

Result

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.

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

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.

  1. 1
    Winning situation

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

  2. 2
    Losing situation

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

  3. 3
    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.

Result

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

Common Misreadings

  • Common mistake

    Treating piece advantage as a simple total piece count.

    What it looks like

    Assuming that every piece contributes identically.

    Why it fails

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

    Do this instead

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

  • Common mistake

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

    What it looks like

    Assigning a specific number to a king without evidence.

    Why it fails

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

    Do this instead

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

  • Common mistake

    Saying that trading pieces always has the same evaluation.

    What it looks like

    Treating an exchange identically whether the program is winning or losing.

    Why it fails

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

    Do this instead

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

  • Common mistake

    Separating piece advantage from move decisions.

    What it looks like

    Describing the feature as a count with no role in choosing moves.

    Why it fails

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

    Do this instead

    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. 1
    Samuel's evaluation function judged checkers positions and guided the program's decisions.
  2. 2
    Piece advantage was its most important component and compared the program's pieces with the opponent's pieces.
  3. 3
    Kings received higher weight than ordinary pieces, so piece type mattered as well as piece count.
  4. 4
    Trading pieces was treated more favorably when the program was winning than when it was losing.
  5. 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.

Related concepts

More concepts starting with E