|
Algorithm Development Kit 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectalgs.model.problems.eightpuzzle.BadEvaluator
public class BadEvaluator
Bad evaluation function.
Instead of considering the goal, take differences of distant cells and sum. Note that we subtract in (what should be) decreasing order of the results. Then compare against 16 (the ideal). For example,
8 1 - 6 - 3 = 3 6 7 3 2 - 0 = 2 2 5 4 5 - 1 = 4 4 - 8 = -4 ----- 5 1 4 8 7 - 0 = 7 7 3 - 6 - 8 = -2 6 5 2 5 - 4 = 1 2 - 1 = 1 ---- 7Has distance of 19 from the ideal of 16.
Constructor Summary | |
---|---|
BadEvaluator()
|
Method Summary | |
---|---|
int |
eval(INode state)
Eval = g(n) + W(n), where g(n) is length of the path from initial to node n, and W(n) counts number of misplaced tiles in the state description |
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 |
---|
public BadEvaluator()
Method Detail |
---|
public void score(INode state)
IScore
score
in interface IScore
state
- The board state whose score value is to be updated.IScore.score(INode)
public int eval(INode state)
eval
in interface IScore
state
- state being evaluatedIScore.score(INode)
|
Algorithm Development Kit 1.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |