예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SudokuGene"/> class.
 /// </summary>
 /// <param name="gene">The gene.</param>
 public SudokuGene(SudokuGene gene)
 {
     for (var i = 0; i < 9; ++i)
     {
         Columns[i] = gene.Columns[i];
     }
 }
예제 #2
0
        /// <summary>
        /// Calculate the score for a row.
        /// The score simply is the number of unique values used in a row
        /// </summary>
        /// <param name="gene">The gene.</param>
        /// <returns>the score (higher=better)</returns>
        private int RowScore(SudokuGene gene)
        {
            var uniqueValues = 0;
            var used         = new bool[10];

            for (var col = 0; col < 9; ++col)
            {
                var val = gene.Columns[col];
                if (used[val])
                {
                    continue;
                }
                used[val] = true;
                uniqueValues++;
            }
            return(uniqueValues);
        }