Exemplo n.º 1
0
        public static ulong[,] SortArrayByColumn(ulong[,] orgArray, SortedList sortedList)
        {
            ulong[,] arrayCopy = (ulong[, ])orgArray.Clone();
            IList valueList = sortedList.GetValueList();

            for (int i = 0; i < orgArray.GetLength(0); i++)
            {
                for (int j = 0; j < orgArray.GetLength(1); j++)
                {
                    orgArray[i, j] = arrayCopy[i, (int)valueList[j]];
                }
            }
            return(orgArray);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines whether [is game finished] [the specified board].
        /// </summary>
        /// <param name="board">The board.</param>
        /// <returns>
        ///   <c>true</c> if [is game finished] [the specified board]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsGameFinished(ulong[,] board)
        {
            var dirrections = new[] { Direction.Down, Direction.Up, Direction.Left, Direction.Right };

            foreach (var direction in dirrections)
            {
                ulong[,] clonedBoard = (ulong[, ])board.Clone();
                ulong score;
                if (this.UpdateBoard(clonedBoard, direction, out score))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
 public static ulong[,] MatrixPow(this ulong[,] arr, ulong pow, ulong mod)
 {
     if (pow == 0)
     {
         return(Identity(arr.GetLength(0)));
     }
     if (pow == 1)
     {
         return((ulong[, ])arr.Clone());
     }
     if (pow % 2 == 0)
     {
         return(MatrixPow(MatrixMul(arr, arr, mod), pow / 2, mod));
     }
     return(MatrixMul(MatrixPow(arr, pow - 1, mod), arr, mod));
 }
Exemplo n.º 4
0
 public Board Clone()
 {
     return(new Board((ulong[, ])_board.Clone()));
 }