Example #1
0
        private int GetHeuristic(TileGrid tileGridState)
        {
            // Currently using plain Manhattan Distance - should be improved
            int heuristic       = 0;
            int targetFaceValue = 0;

            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    targetFaceValue = tileGridState.tileGridArray[x, y].faceValue;
                    TargetCoordinate targetCoordinate = targetCoordinateList.Where(z => z.faceValue == targetFaceValue).FirstOrDefault();

                    heuristic = heuristic + Math.Abs(targetCoordinate.xCoordinate - tileGridState.tileGridArray[x, y].xCoordinate);
                    heuristic = heuristic + Math.Abs(targetCoordinate.yCoordinate - tileGridState.tileGridArray[x, y].yCoordinate);
                }
            }

            return(heuristic);
        }
        public void BindTileGridToUI(TileGrid _tileGrid)
        {
            int    faceValueCounter = 0;
            String buttonName       = "";

            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    buttonName = _tileGrid.tileGridArray[x, y].boundButtonName;

                    // Bind tiles to UI
                    var tileButton = Controls.Find(buttonName, true)[0];
                    tileButton.Text = _tileGrid.tileGridArray[x, y].faceValue.ToString();

                    faceValueCounter++;
                }
            }

            this.Refresh();
        }
Example #3
0
 public BoardState(TileGrid _tileGrid, BoardState _predecessor, int _heuristic)
 {
     predecessor   = _predecessor;
     tileGridState = _tileGrid;
     heuristic     = _heuristic;
 }
Example #4
0
 public ASharpSolver(TileGrid _tileGrid, List <TargetCoordinate> _targetCoordinateList)
 {
     tileGrid             = _tileGrid;
     targetCoordinateList = _targetCoordinateList;
     Console.WriteLine("Current Heuristic is : " + GetHeuristic(tileGrid));
 }
Example #5
0
 public ASharpSolver()
 {
     tileGrid             = new TileGrid();
     targetCoordinateList = new List <TargetCoordinate>();
 }