001 /* 002 * Created on Sep 28, 2005 003 * 004 */ 005 package aima.test.search; 006 007 import junit.framework.TestCase; 008 import aima.search.eightpuzzle.EightPuzzleBoard; 009 import aima.search.eightpuzzle.MisplacedTilleHeuristicFunction; 010 011 /** 012 * @author Ravi Mohan 013 * 014 */ 015 016 public class MisplacedTileHeuristicFunctionTest extends TestCase { 017 public void testHeuristicCalculation() { 018 MisplacedTilleHeuristicFunction fn = new MisplacedTilleHeuristicFunction(); 019 EightPuzzleBoard board = new EightPuzzleBoard(new int[] { 2, 0, 5, 6, 020 4, 8, 3, 7, 1 }); 021 assertEquals(7.0, fn.getHeuristicValue(board)); 022 023 board = new EightPuzzleBoard(new int[] { 6, 2, 5, 3, 4, 8, 0, 7, 1 }); 024 assertEquals(6.0, fn.getHeuristicValue(board)); 025 026 board = new EightPuzzleBoard(new int[] { 6, 2, 5, 3, 4, 8, 7, 0, 1 }); 027 assertEquals(7.0, fn.getHeuristicValue(board)); 028 } 029 }