public static int Heuristic2(ZhedBoard board) { if (board.isOver) { return(0); } List <int[]> valueTiles = board.GetValueTiles(); List <int[]> finishTiles = board.GetFinishTiles(); int numAligned = 0; foreach (int[] finishTile in finishTiles) { foreach (int[] valueTile in valueTiles) { if (new Coords(valueTile[0], valueTile[1]).AlignedWith(new Coords(finishTile[0], finishTile[1]))) { numAligned++; } } } if (numAligned == 0) { return(9999); } int a = 1 / numAligned; //Console.WriteLine(a); return(a); }
private int Heuristic1(ZhedBoard board) { int minZhedDistance = int.MaxValue; foreach (int[] valueTile in board.GetValueTiles()) { foreach (int[] finishTile in board.GetFinishTiles()) { int zhedDistance; if (valueTile[0] == finishTile[0]) { zhedDistance = CalcZhedDistance(valueTile, finishTile, board, true); } else if (valueTile[1] == finishTile[1]) { zhedDistance = CalcZhedDistance(valueTile, finishTile, board, false); } else { continue; } //Console.WriteLine("Min zhed distance calculated: {0}", zhedDistance); if (zhedDistance < minZhedDistance) { minZhedDistance = zhedDistance; } } } return(minZhedDistance); }
/* Heuristic 1 * Minimum zhed Distance between a value tile and a finish tile. */ public static int Heuristic1(ZhedBoard board) { int minZhedDistance = int.MaxValue; foreach (int[] valueTile in board.GetValueTiles()) { foreach (int[] finishTile in board.GetFinishTiles()) { int zhedDistance; if (valueTile[0] == finishTile[0]) { zhedDistance = CalcZhedDistance(valueTile, finishTile, board, true); } else if (valueTile[1] == finishTile[1]) { zhedDistance = CalcZhedDistance(valueTile, finishTile, board, false); } else { continue; } if (zhedDistance < minZhedDistance) { minZhedDistance = zhedDistance; } } } return(minZhedDistance); }