// решает один сектор // вход - Уровень, структура стыковки private void SolveOne(Level lvl, OneOlimp oo) { List <string> wrd3 = new List <string>(); List <string> wrd2 = new List <string>(); List <string> wrd1 = new List <string>(); List <List <string> > wrds = new List <List <string> >(); foreach (int i in oo.nums) { wrds.Add(GetSec(lvl, i)); } if (oo.nums.Count == 4) { wrd3.AddRange(Get3(oo.num, wrds, oo.nums, 0, 1, 2)); wrd3.AddRange(Get3(oo.num, wrds, oo.nums, 0, 1, 3)); wrd3.AddRange(Get3(oo.num, wrds, oo.nums, 0, 2, 3)); wrd3.AddRange(Get3(oo.num, wrds, oo.nums, 1, 2, 3)); wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 0, 1)); wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 0, 2)); wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 0, 3)); wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 1, 2)); wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 1, 3)); wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 2, 3)); wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 0)); wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 1)); wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 2)); wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 3)); } if (oo.nums.Count == 3) { wrd3.AddRange(Get3(oo.num, wrds, oo.nums, 0, 1, 2)); wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 0, 1)); wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 0, 2)); wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 1, 2)); wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 0)); wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 1)); wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 2)); } if (oo.nums.Count == 2) { wrd2.AddRange(Get2(oo.num, wrds, oo.nums, 0, 1)); wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 0)); wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 1)); } if (oo.nums.Count == 1) { wrd1.AddRange(Get1(oo.num, wrds, oo.nums, 0)); } wrd1 = Words.KillDupesAndRange(wrd1); wrd2 = Words.KillDupesAndRange(wrd2); wrd3 = Words.KillDupesAndRange(wrd3); Answer.Add(OT, 3, wrd3, oo.num); Answer.Add(OT, 4, wrd2, oo.num); Answer.Add(OT, 5, Associations.GetFirstItems(wrd1, 7), oo.num); Answer.Add(OT, 6, wrd1, oo.num); }
// для нерешенных секторов ищет решенные стыковки, которые можно решить // вход - объект уровня // выход - набор задач по стыковке private List <OneOlimp> FindBlanks(Level lvl) { List <OneOlimp> res = new List <OneOlimp>(); for (int i = 0; i < lvl.sectors; i++) { if (lvl.sector[i].Replace(" ", "") == "") { List <int> nums = GetLinks(i + 1); List <int> bad = new List <int>(); foreach (int j in nums) { if (lvl.sector[j - 1].Replace(" ", "") == "") { bad.Add(j); } } foreach (int j in bad) { nums.Remove(j); } if (nums.Count < 2) { foreach (int j in bad) { nums.AddRange(GetLinks(j)); } List <int> bad2 = new List <int>(); foreach (int j in nums) { if (lvl.sector[j - 1].Replace(" ", "") == "") { bad2.Add(j); } } foreach (int j in bad2) { nums.Remove(j); } } nums.Sort(); string id = (i + 1).ToString(); foreach (int j in nums) { id = id + "," + j.ToString(); } // i - номер сектора, который будем искать 0..max-1 // nums - сектора (1-4), от которых зависит решение // id - строка идентификатор if (nums.Count > 0) { OneOlimp temp = new OneOlimp(); temp.num = i; temp.nums = nums; temp.id = id; res.Add(temp); } } } return(res); }