private void RecalculateRule() { Console.WriteLine("[DEBUG:MainController] RecalculateRule()"); // Calculate Rule base on "IS" textbox List <Tuple <int, int> > res = _gameStateModel.FindAll("T_IS"); // Only two combinations are allowed, i.e. Left & Right, Up & Down foreach (var tuple in res) { string left = GetValue(tuple.Item1, tuple.Item2 - 1); string right = GetValue(tuple.Item1, tuple.Item2 + 1); string up = GetValue(tuple.Item1 - 1, tuple.Item2); string down = GetValue(tuple.Item1 + 1, tuple.Item2); Console.WriteLine(String.Format("[DEBUG:MainController] Locate IS: ({0}, {1})", tuple.Item1, tuple.Item2)); if (_rulePrefix.Contains(left) && _ruleSuffix.Contains(right)) { Console.WriteLine(String.Format("[DEBUG:MainController] Added LR Rule: {0} IS {1}", left, right)); left = left.Replace("T_", ""); if (right == "T_WIN") { _rulesDict[left].CanWin = true; } if (right == "T_YOU") { _rulesDict[left].CanControl = true; } if (right == "T_KILL") { _rulesDict[left].CanKill = true; } if (right == "T_PUSH") { _rulesDict[left].CanPush = true; } if (right == "T_STOP") { _rulesDict[left].CanStop = true; } } if (_rulePrefix.Contains(up) && _ruleSuffix.Contains(down)) { Console.WriteLine(String.Format("[DEBUG:MainController] Added UD Rule: {0} IS {1}", up, down)); up = up.Replace("T_", ""); if (down == "T_WIN") { _rulesDict[up].CanWin = true; } if (down == "T_YOU") { _rulesDict[up].CanControl = true; } if (down == "T_KILL") { _rulesDict[up].CanKill = true; } if (down == "T_PUSH") { _rulesDict[up].CanPush = true; } if (down == "T_STOP") { _rulesDict[up].CanStop = true; } } } return; }