public void ThreadCalculate(object index) { var i = (int)index; for (int j = 0; j < Arr.GetLength(1); j++) { if (i + 1 < Arr.GetLength(0) && j + 1 < Arr.GetLength(1)) { var tmp = new List <int>(); tmp.Add(Arr[i, j]); tmp.Add(Arr[i + 1, j]); tmp.Add(Arr[i, j + 1]); tmp.Add(Arr[i + 1, j + 1]); tmp = tmp.Distinct().ToList(); if (tmp.Count == 4) { lock (Locker) { Count4++; } } } } }
public King(int x, int y, Bitmap img) : base(x, y, img) { this.Arr = new String[, ] { { "X", "X", "X" }, { "X", "O", "X" }, { "X", "X", "X" }, }; movePermited = new String[Arr.GetLength(0), Arr.GetLength(0)]; }
private void GenerateArray() { for (int i = 0; i < Arr.GetLength(0); i++) { for (int j = 0; j < Arr.GetLength(1); j++) { Arr[i, j] = Rand.Next(0, 4); } } }
public void Print() { for (int i = 0; i < Arr.GetLength(0); i++) { for (int j = 0; j < Arr.GetLength(1); j++) { Console.Write($"{Arr[i, j]} "); } Console.WriteLine(); } }
public int Calculate4() { List <Thread> threads = new List <Thread>(); for (int i = 0; i < Arr.GetLength(0); i++) { Thread thread = new Thread(ThreadCalculate); thread.Start(i); threads.Add(thread); } threads.WaitAll(); return(Count4); }
public int[,] ArrayMoveDown() { int rowCount = Arr.GetLength(0); int colCount = Arr.GetLength(1); for (int i = 0; i < colCount; i++) { for (int j = 0; j < N; j++) { int Save = Arr[rowCount - 1, i]; for (int k = rowCount - 1; k > 0; k--) { Arr[k, i] = Arr[k - 1, i]; } Arr[0, i] = Save; } } return(Arr); }
public int[,] ArrayMoveRight() { int rowCount = Arr.GetLength(0); int colCount = Arr.GetLength(1); for (int i = 0; i < rowCount; i++) { for (int j = 0; j < N; j++) { int Save = Arr[i, colCount - 1]; for (int k = colCount - 1; k > 0; k--) { Arr[i, k] = Arr[i, k - 1]; } Arr[i, 0] = Save; } } return(Arr); }
public Pawn(int x, int y, Bitmap img, int type) : base(x, y, img) { if (type == 1) { Arr = new String[, ] { { "-", "-", "-" }, { "-", "O", "-" }, { "Y", "X", "Y" }, }; } if (type == 2) { Arr = new String[, ] { { "Y", "X", "Y" }, { "-", "O", "-" }, { "-", "-", "-" }, }; } movePermited = new String[Arr.GetLength(0), Arr.GetLength(0)]; }