Exemple #1
0
        private static void AddSimilarTileToGroup(Tile tile, TileGroup group, int key)
        {
            // Check if key already exists
            bool hasKey = group.ContainsKey(key);
            while (hasKey == true)
            {
                int otherTileIndex = group[key];
                //Tile otherTile = allSubImageTiles[otherTileIndex];
                Tile otherTile = allSubImageTiles.ElementAt(otherTileIndex);
                Tuple<float, float> results = otherTile.GetMatches(tile);
                float patternMatch = results.Item1;
                float colourMatch = results.Item2;

                bool areIdentical = Tile.IdenticalTo(patternMatch, colourMatch);
                if (areIdentical == true)
                {
                    Duplicates++;
                    return;
                }

                key++;
                hasKey = group.ContainsKey(key);
            }

            int tileIndex = tile.Index;
            group.AddSimilar(key, tileIndex);
        }