Ejemplo n.º 1
0
        public static bool isContrary(NumberRule rule1, PositionRule rule2)
        {
            if (rule1.OutputState == rule2.OutputState)
            {
                return(false);
            }

            switch (rule1.StateChoosen1)
            {
            case (int)GlobalSettings.States.Empty:
                if (rule1.Count == rule2.EmptyCount && rule2.DeadCount == 0 && rule2.AliveCount == 0)
                {
                    return(true);
                }
                break;

            case (int)GlobalSettings.States.Dead:
                if (rule1.Count == rule2.DeadCount && rule2.AliveCount == 0)
                {
                    return(true);
                }
                break;

            case (int)GlobalSettings.States.Alive:
                if (rule1.Count == rule2.AliveCount && rule2.DeadCount == 0)
                {
                    return(true);
                }
                break;
            }



            return(false);
        }
Ejemplo n.º 2
0
        public static bool  isContrary(NumberRule rule1, NumberRule rule2)
        {
            if (rule1.OutputState == rule2.OutputState)
            {
                return(false);
            }



            if (rule1.Count == rule2.Count && rule1.StateChoosen1 == rule2.StateChoosen1 && rule1.OutputState != rule2.OutputState)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        private void NumberBasedButton(object sender, RoutedEventArgs e)
        {
            byte numInSurr = 0;

            if (CountControl.Value != null)
            {
                numInSurr = (byte)CountControl.Value;
            }


            var nRule = new   NumberRule(numInSurr, (byte)CountStateControl.SelectedIndex, (byte)inputstateControl.SelectedIndex, (byte)outputstatecontrol.SelectedIndex);

            bool iscontrary = false;

            foreach (PositionRule secRule in RuleSet.PositionRules)
            {
                if (iscontrary = RuleSet.isContrary(nRule, secRule))
                {
                    break;
                }
            }

            foreach (NumberRule secRule in RuleSet.NumberRule)
            {
                if (iscontrary = RuleSet.isContrary(secRule, nRule))
                {
                    break;
                }
            }



            if (!iscontrary)
            {
                RuleSet.NumberRule.Add(nRule);
                Console.WriteLine("No Contrary");
                MessageBox.Show("Rule Added", "Confirmation", MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
            else
            {
                Console.WriteLine("Is Contrary");
                MessageBox.Show("This is contrary", "Confirmation", MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
        }