AI Glossary / Graphs and symbolic AI / Intermediate

Weighted linear function

Definition

A weighted linear function combines numerical features by multiplying each feature by a coefficient and adding the results. In AI game search, it can serve as a heuristic evaluation of a position when searching all the way to a terminal outcome is impractical. Its basic form is Eval(s) = sum of w_i*f_i(s), where the features describe state s and the coefficients control their contributions.

What it means

The function is linear in the feature values: each contribution is added without multiplying it by another feature inside this expression. The features themselves can be complicated or nonlinear descriptions of the original state.
For example, a feature might count available moves, measure an advantage, or indicate a particular pattern. A positive coefficient raises the score when its feature increases; a negative coefficient lowers it. Coefficients do not have to be probabilities or sum to one. Their practical meaning also depends on feature units and scale, so a numerically large coefficient is not automatically the most influential.

How it works

Choose a consistent perspective, define the features, assign or learn coefficients, and compute the weighted sum. In a game, the perspective might be one designated player: a positive score favors that player, while a negative score favors the opponent.
When used at a search cutoff, the function estimates how promising an unfinished position is. The search combines these estimates with its decision rules. A heuristic estimate is not an exact game-theoretic value. Terminal positions need appropriate treatment, and tactical instability can make a shallow feature score misleading even when its arithmetic is correct.

Three practical examples

  • A toy board-game program can combine material advantage, mobility difference, and an exposure penalty to evaluate unfinished positions.
  • A planning prototype can score candidate states using progress and resource-use features, while checking whether the scoring rule matches the intended objective.
  • A classroom exercise can show how rescaling one feature requires a corresponding coefficient adjustment to preserve the same function.

Think of it this way

Think of an assessment sheet that awards or subtracts points for several listed characteristics. Each line contributes separately to the total. The analogy is limited because useful AI features may be learned or difficult to interpret, and adding points cannot automatically capture interactions between characteristics or guarantee a sound decision.

Worked example

Consider an original game-state evaluator with three features: material advantage M, mobility difference R, and exposed-unit count E for the player being evaluated. Define score = 5*M + 0.5*R - 2*E. Higher is better from this player's perspective.
Position A has M = 2, R = 4, and E = 1. Its score is 10 + 2 - 2 = 10. Position B has M = 1, R = 10, and E = 0. Its score is 5 + 5 = 10. The evaluator ties the positions even though their feature profiles differ.
Now increase the exposure penalty from 2 to 4. Position A's score becomes 10 + 2 - 4 = 8, while B remains at 10. This is a change in the preferences represented by the function, not new evidence that B must lead to a win.
Suppose mobility is subsequently recorded in tens of moves, so R_new = R/10. To preserve the original contribution, replace coefficient 0.5 with 5. For A, R_new = 0.4 and 5*0.4 = 2, matching the old 0.5*4. Keeping coefficient 0.5 after the unit change would accidentally reduce mobility's contribution tenfold.
Finally, if exposure is especially dangerous only when material is low, a simple independent sum may miss that relationship. An added feature indicating the joint condition could represent it. The function would remain linear in the expanded feature vector, even though that new feature is nonlinear in the original measurements.

Illustrative case study

Fictional case: a small game-development team builds an evaluator that performs well on quiet positions but chooses a move that exposes a valuable unit to immediate capture. The static score rewards material that will not survive the opponent's reply.
The team inspects the search horizon, adds test positions with immediate threats, and considers extending tactical analysis before evaluation. It also checks score perspective and terminal handling. The lesson is that adjusting coefficients alone may not resolve information missing from a shallow search; no production performance gain is claimed.

Common misconceptions and mistakes

Do not confuse a weighted sum with a weighted average. An average generally includes normalization and suitable weight assumptions. Do not interpret the output as a win probability unless a separate justified mapping provides that meaning.
Also distinguish a strictly linear expression from an affine one with an added constant. An intercept can be represented by a constant feature, but the distinction is useful mathematically. Avoid double-counting highly overlapping features without examining their effect. A transparent formula can still encode poor assumptions or omit decisive information.

Business use

Weighted linear functions offer a simple starting point for explainable scoring and heuristic evaluation. Individual contributions can be inspected, which helps teams diagnose unexpected rankings.
Document feature definitions, units, sign conventions, and coefficient origins. Test sensitivity by changing one feature at a time and examine cases where different profiles receive the same score. If the score guides an important decision, assess outcomes rather than relying only on intuitive weights. Keep required constraints separate when a high score must never compensate for violating them.

People also ask

Must the coefficients sum to one?

No. That condition belongs to certain normalized averages, not weighted linear functions in general.

Can the function use nonlinear features?

Yes. It can be linear in features that are themselves nonlinear functions of the original state.

Does the highest score guarantee the best move?

No. The result depends on feature quality, coefficients, search depth, and what the score is intended to estimate.

Check your understanding

Why must the mobility coefficient change from 0.5 to 5 when mobility is measured in tens of moves?

Answer: The feature becomes one tenth as large, so multiplying the coefficient by ten preserves its contribution.

Related terms

  • Evaluation function
  • Feature
  • Linear model
  • Heuristic search
  • Quiescence search
  • Coefficient
  • Affine function
  • Feature scaling
  • Interaction feature

Learn next

Create position C with M = 0, R = 8, and E = 1. Its original score is 2. Compare its three separate contributions with A and B, then explain one important property of a game position that this evaluator might fail to represent.

More in Graphs and symbolic AI

  • Type signature - A type signature specifies the types of inputs and outputs associated with a function or operation.
  • UCB1 - UCB1 is a multi-armed bandit algorithm that selects an action using its average observed reward plus an exploration bonus.
  • UCT - UCT is a method for guiding Monte Carlo tree search by applying upper-confidence-bound ideas at decision nodes.
  • Łukasiewicz logic - Łukasiewicz logic is a family of many-valued logics associated with Jan Łukasiewicz.
  • Unary constraint - A unary constraint is a rule that restricts the allowed values of one variable in a constraint satisfaction problem.
  • Unbounded cost search - Unbounded-cost search seeks a valid solution without requiring its cost to fall below a specified threshold or within a specified factor of the best...

Sources

Primary source: AIMA original heuristic game-evaluation discussion and weighted linear expression: https://raw.githubusercontent.com/aimacode/aima-glossary/master/sentences.txt . The evaluator, feature-scaling calculation, and fictional case are original.

Previous: Weighted least squares Next: Weighted majority algorithm (machine learning)

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer