public IEnumerable <int> GetMatchedTiles() { // Cut tiles from chromosome var cutTiles = E2Chromosome.CutTiles(this); // Create a copy of the real tiles for us to work with var comp = Tiles.ToList(); var tileIndex = 0; foreach (var tile in cutTiles) { // Walk our own list of all the real tiles... for (var n = 0; n < comp.Count; n++) { if (comp[n].Matches(tile)) { yield return(tileIndex); comp.RemoveAt(n); break; } } tileIndex++; } }
public (int, double) GetMatchedTileScore() { // Cut tiles from chromosome var cutTiles = E2Chromosome.CutTiles(this).ToList(); // Create a copy of the real tiles for us to work with var comp = Tiles.ToList(); var score = 0.0; var tileMatches = 0; foreach (var tile in cutTiles) { // Walk our own list of all the real tiles... for (var n = 0; n < comp.Count; n++) { if (comp[n].Matches(tile)) { score++; tileMatches++; comp.RemoveAt(n); break; } } } // Walk the list again and look for partial matches new int[] { 4, 3 }.Each(threshold => { foreach (var tile in cutTiles) { for (var n = 0; n < comp.Count; n++) { if (comp[n].SymbolMatches(tile) == threshold) { score += ((double)threshold / 24.0); comp.RemoveAt(n); break; } } } }); return(tileMatches, score); }