コード例 #1
0
        private static List<Tile> GenerateNeighbourTilesList(Tile freeTile, Tile tile, List<Tile> neighbourTiles)
        {
            bool areValidNeighbourTiles = AreValidNeighbourTiles(freeTile, tile);
            if (areValidNeighbourTiles)
            {

                neighbourTiles.Add(tile);
            }
            return neighbourTiles;
        }
コード例 #2
0
        private static bool AreValidNeighbourTiles(Tile freeTile, Tile tile)
        {
            int tilesDistance = freeTile.Position - tile.Position;
            int tilesAbsoluteDistance = Math.Abs(tilesDistance);
            bool isValidHorizontalNeighbour =
                ((tilesAbsoluteDistance == HORIZONTAL_NEIGHBOUR_TILE) && !(((tile.Position + 1) % MATRIX_SIZE == 1 && tilesDistance == -1) || ((tile.Position + 1) % MATRIX_SIZE == 0 && tilesDistance == 1)));
            bool isValidVerticalNeighbour = (tilesAbsoluteDistance == VERTICAL_NEIGHBOUR_TILE);
            bool validNeigbour = isValidHorizontalNeighbour || isValidVerticalNeighbour;

            return validNeigbour;
        }
コード例 #3
0
        private static Tile DetermineFreeTile(List<Tile> resultMatrix)
        {
            Tile freeTile = new Tile();

            foreach (Tile tile in resultMatrix)
            {
                if (tile.Label == string.Empty)
                {
                    freeTile = tile;
                }
            }
            return freeTile;
        }
コード例 #4
0
        public static List<Tile> GenerateMatrix()
        {
            List<Tile> tiles = new List<Tile>();

            for (int index = 0; index < 15; index++)
            {
                String tileName = (index + 1).ToString();

                Tile tempTile = new Tile(tileName, index);
                tiles.Add(tempTile);

            }

            Tile emptyTile = new Tile(string.Empty, 15);
            tiles.Add(emptyTile);

            return tiles;
        }
コード例 #5
0
        private static bool TilePositionValidation(List<Tile> tiles, Tile freeTile, Tile tile)
        {
            bool areValidNeighbourTiles = AreValidNeighbourTiles(freeTile, tile);

            return areValidNeighbourTiles;
        }