public int ifConflict(List<Rule> rules, Rule rule) { int conflict = 0; for (int i = 0; i < rules.Count; i++) { if (rules[i].comparison == 0 || rule.comparison == 1) { if (rules[i].num > rule.num) conflict = 1; break; } if (rules[i].comparison == 2 || rule.comparison == 2) { if (!(rules[i].num == rule.num)) conflict = 1; break; } } return conflict; }
private void addRule_Click(object sender, RoutedEventArgs e) { if (initialState.Text.ToString() == "Alive") initState = 1; else initState = 0; if (state1.Text.ToString() == "Alive") states = 1; else states = 0; nums = Int32.Parse(num1.Text); if (comparison1.Text.ToString() == "more than") comparisons = 0; else if (comparison1.Text.ToString() == "exactly") comparisons = 1; else if (comparison1.Text.ToString() == "less than") comparisons = 2; //comparisons = comparison1.Text.ToString(); if (initState == 1) finState = 0; else finState = 1; name = "rule" + k; rule = new Rule(initState, name, states, nums, comparisons, finState); rulesList1.Add(rule); rules.Items.Add("rule_"+k); k++; // num1.Clear(); // cells[5].Fill = new SolidColorBrush(Colors.Blue); for (int i = 0; i < 25; i++) { // if cells[i] } }
private void Button_Click_3(object sender, RoutedEventArgs e) { states_gui = new int[25]; int state_middle; if (finalState.Text.ToString() == "Alive") final = 1; else final = 0; if (buttons[12].Background.ToString() == "#FF000000") { state_middle = 0; } else { state_middle = 1; } for (int i = 0; i < 25; i++) { // if cells[i] if (i == 12) { states_gui[i] = state_middle; continue; } if (buttons[i].Background.ToString() == "#FF000000") states_gui[i] = 0; else states_gui[i] = 1; } name = "rule" + k; rule = new Rule(states_gui, state_middle, name, final); rulesList2.Add(rule); rules2.Items.Add("rule_" + k); k++; rule = null; }