Algorithm
Development Kit 1.0

algs.model.problems.eightpuzzle
Class GoodEvaluator

java.lang.Object
  extended by algs.model.problems.eightpuzzle.GoodEvaluator
All Implemented Interfaces:
IScore

public class GoodEvaluator
extends java.lang.Object
implements IScore

Better evaluation function, as drawn from Nilsson, p. 66.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Constructor Summary
GoodEvaluator()
           
 
Method Summary
 int eval(INode state)
          h^(n) = P(n) + 3*S(n), where P(n) is the sum of the distances (via manhattan metric) that each tile is from "home".
 void score(INode state)
          Evaluate the given state and update its score using our scoring function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GoodEvaluator

public GoodEvaluator()
Method Detail

score

public void score(INode state)
Description copied from interface: IScore
Evaluate the given state and update its score using our scoring function.

Specified by:
score in interface IScore
Parameters:
state - The board state whose score value is to be updated.
See Also:
IScore.score(INode)

eval

public int eval(INode state)
h^(n) = P(n) + 3*S(n), where P(n) is the sum of the distances (via manhattan metric) that each tile is from "home". S(n) is a sequence score obtained by checking around the noncentral squares in turn, allotting 2 for every tile not followed by its proper successor and 0 for every other tile, except that a piece in the center scores 1.

Compute f^(n) = g^(n) + h^(n) where g(n) is the length of the path form the start node n to the state.

Specified by:
eval in interface IScore
Parameters:
state -
See Also:
IScore.score(INode)

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.