public static void runCombinatoricTest() { string logFilePath = Path.Combine("./", String.Format("{0:yyyy-MM-dd-hhmmss}_{1}.txt", DateTime.Now, "combinatoric_test")); var charCombinations = new List <string>(); var alphabet = new List <char>(Alphabet.chars.Keys); var counters = new int[3]; while (true) { var word = ""; for (var j = 0; j < 3; j++) { word += alphabet[counters[j]]; } charCombinations.Add(word); if (counters[2]++ >= alphabet.Count - 1) { counters[2] = 0; counters[1]++; } if (counters[1] >= alphabet.Count - 1) { counters[1] = 0; counters[0]++; } if (counters[0] >= alphabet.Count - 1) { break; } } for (var i = 0; i < charCombinations.Count; i++) { var combination = charCombinations[i]; bool?[][] table = Utils.createTable(60, 20, false); Utils.writeWord(ref table, combination, 12, 6); var logStr = Utils.getFormattedLogLine("", new Dictionary <string, string> { { "word", combination }, { "total", charCombinations.Count.ToString() }, { "current", (i + 1).ToString() }, }); Console.WriteLine(logStr); using (StreamWriter stream = new StreamWriter(logFilePath, false)) { for (var leftOffset = 0; leftOffset <= 60 - AbstractClient.windowWidth; leftOffset++) { var client = new FakeClient(table, leftOffset, 0); var strategy = new Strategy(client); loopCombinatoricTest(stream, $"Left offset: {leftOffset}", combination, strategy); } } } }
// ЫЫЫ public static void runTestCase8() { bool?[][] table = Utils.createTable(60, 20, false); Utils.writeWord(ref table, "ыыы", 12, 6); var client = new FakeClient(table, 17, 1); var strategy = new Strategy(client); loopTest(client, strategy); }
// Сразу поподаем на середину слова public static void runTestCase7() { bool?[][] table = Utils.createTable(60, 20, false); Utils.writeWord(ref table, "колеса", 8, 6); var client = new FakeClient(table, 30, 7); var strategy = new Strategy(client); loopTest(client, strategy); }
// Поподаем на нижний левый угол слова начинающегося на букву Т public static void runTestCase6() { bool?[][] table = Utils.createTable(60, 20, false); Utils.writeWord(ref table, "торус", 11, 3); var client = new FakeClient(table, 2, 8); var strategy = new Strategy(client); loopTest(client, strategy); }
// Поподаем на верхний правый угол слова заканчивающегося на букву Ь public static void runTestCase5() { bool?[][] table = Utils.createTable(70, 20, false); Utils.writeWord(ref table, "кокоь", 8, 8); var client = new FakeClient(table, 42, 3); var strategy = new Strategy(client); loopTest(client, strategy); }
// Поподаем сверху на середину слова public static void runTestCase1() { bool?[][] table = Utils.createTable(70, 20, false); Utils.writeWord(ref table, "аллоха", 8, 5); var client = new FakeClient(table, 8, 0); var strategy = new Strategy(client); loopTest(client, strategy); }
public static void runMultipleWordsTestCase1() { bool?[][] table = Utils.createTable(100, 50, false); Utils.writeWord(ref table, "мотор", 38, 5); Utils.writeWord(ref table, "рыба", 8, 15); Utils.writeWord(ref table, "чай", 10, 24); var client = new FakeClient(table, 8, 0); var strategy = new Strategy(client); loopTest(client, strategy); }
private static void loopTest(FakeClient client, Strategy strategy) { Utils.printTable(client.table); while (strategy.state != StrategyState.WalkOutBorders) { strategy.nextStep(); Utils.printDebugInfo(client, strategy); } Console.WriteLine(); var foundWordsStr = String.Join(",", strategy.foundWords); Console.WriteLine($"Result: words={foundWordsStr} steps={strategy.step}"); Console.ReadKey(); }