ExchangeValuesOfHorizontalLines (line1, line2);
}
public void ExchangeValuesOfHorizontalLines (short line1, short line2)
{
if (line1!= line2)
{
short lineTemp;
for (short i = 0; i <9; i++)
{
lineTemp = field [line1, i].Value;
field [line1, i].Value = field [line2, i].Value;
field [line2, i].Value = lineTemp;
}
}
}
public void MixVerticalLines ()
{
Random rand = new Random ();
short line1, line2;
//Переставляем две строки в первой тройке
line1 = (short)(rand.Next (12432) % 3);
line2 = (short)(rand.Next (87457) % 3);
ExchangeValuesOfVerticalLines (line1, line2);
//Переставляем две строки во второй тройке
line1 = (short)(rand.Next (12432) % 3 +3);
line2 = (short)(rand.Next (87457) % 3 +3);
ExchangeValuesOfVerticalLines (line1, line2);
//Переставляем две строки в третьей тройке
line1 = (short)(rand.Next (12432) % 3 +6);
line2 = (short)(rand.Next (87457) % 3 +6);
ExchangeValuesOfVerticalLines (line1, line2);
}
public void ExchangeValuesOfVerticalLines (short line1, short line2)
{
if (line1!= line2)
{
short lineTemp;
for (short i = 0; i <9; i++)
{
lineTemp = field [i, line1].Value;
field [i, line1].Value = field [i, line2].Value;
field [i, line2].Value = lineTemp;
}
}
}
// Перестановка регионов (блок из трех строк/столбцов)
public void MixVerticalRegions ()
{
Random rand = new Random ();
short Region1, Region2;
//Переставляем две строки в первой тройке
Region1 = (short)(rand.Next (7654) % 3);
Region2 = (short)(rand.Next (45545) % 3);
ExchangeValuesOfVerticalRegions (Region1, Region2);
}
public void ExchangeValuesOfVerticalRegions (short Region1, short Region2)
{
if (Region1!= Region2)
{
short lineTemp1;
short lineTemp2;
short lineTemp3;
for (short i = 0; i <9; i++)
{
lineTemp1 = field [i, Region1 * 3].Value;
lineTemp2 = field [i, Region1 * 3 + 1].Value;
lineTemp3 = field [i, Region1 * 3 + 2].Value;
field [i, Region1 * 3].Value = field [i, Region2 * 3].Value;
field [i, Region1 * 3 + 1].Value = field [i, Region2 * 3 + 1].Value;
field [i, Region1 * 3 + 2].Value = field [i, Region2 * 3 + 2].Value;
field [i, Region1 * 3].Value = lineTemp1;
field [i, Region1 * 3 + 1].Value = lineTemp2;
field [i, Region1 * 3 + 2].Value = lineTemp3;
}
}
}
public void MixHorizontalRegions ()
{
Random rand = new Random ();
short Region1, Region2;
//Переставляем две строки в первой тройке
Region1 = (short)(rand.Next (7654) % 3);
Region2 = (short)(rand.Next (45545) % 3);
ExchangeValuesOfHorizontalRegions (Region1, Region2);
}
public void ExchangeValuesOfHorizontalRegions (short Region1, short Region2)
{
if (Region1!= Region2)
{
short lineTemp1;
short lineTemp2;
short lineTemp3;
for (short i = 0; i <9; i++)
{
lineTemp1 = field [Region1 * 3, i].Value;
lineTemp2 = field [Region1 * 3 +1, i].Value;
lineTemp3 = field [Region1 * 3 +2, i].Value;
field [Region1 * 3, i].Value = field [i, Region2 * 3].Value;
field [Region1 * 3 +1, i].Value = field [i, Region2 * 3 + 1].Value;
field [Region1 * 3 +2, i].Value = field [i, Region2 * 3 + 2].Value;
field [Region1 * 3, i].Value = lineTemp1;
field [Region1 * 3 +1, i].Value = lineTemp2;
field [Region1 * 3 +2, i].Value = lineTemp3;
}
}
}
// Освобождение клеток на поле
public void DeleteNumbersFromField ()
{
Random rand = new Random ();
for (short k = 0; k <9; k++)
{
short [] randString = new short [9];
numbers = new short [9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
for (short i = 0; i <9; i++)
{
short temp = (short)(rand.Next (45689 * (i +1) – 6) % (9 – i));
randString [i] = numbers [temp];
for (short j = temp; j <9 – i – 1; j++)
{
numbers [j] = numbers [j +1];
}
}
short tempRand = (short)(rand.Next (4, 7));
for (short t = 0; t <tempRand; t++)
{
field [k, randString[t]].Value = 0;
}
for (short t = tempRand; t <9; t++)
{
field