예제 #1
0
 public MainForm()
 {
     InitializeComponent();
     fuzzy = new FuzzyLogic();
     fuzzy.setRectangleSize(this.ClientSize.Width, this.ClientSize.Height);
     lblClientSize.Text = "Client Size of Screen: " + this.ClientSize.ToString();
     oldLocation = this.Location;
     this.trkRenderSpeed.Value = renderSleep;
     menu = new MenuForm();
     menu.chkSelf = chbtnShowMenu;
     menu.picFox = this.Fox;
     menu.picRabbit = this.Rabbit;
     menu.RandomLoc((FuzzyLogic.Distance(new Point(100, 100), new Point(FuzzyLogic.Width, FuzzyLogic.Height)) - 100) / 2);
     thFuzzyLogic = new Thread(new ThreadStart(Fuzzy));
 }
예제 #2
0
        public ShowGraphsForm()
        {
            InitializeComponent();
            txtAverage0.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtAverage0.Leave += new EventHandler(txtAveVar_Leave);
            txtAverage1.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtAverage1.Leave += new EventHandler(txtAveVar_Leave);
            txtAverage2.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtAverage2.Leave += new EventHandler(txtAveVar_Leave);
            txtAverage3.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtAverage3.Leave += new EventHandler(txtAveVar_Leave);
            txtAverage4.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtAverage4.Leave += new EventHandler(txtAveVar_Leave);

            txtVariance0.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtVariance0.Leave += new EventHandler(txtAveVar_Leave);
            txtVariance1.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtVariance1.Leave += new EventHandler(txtAveVar_Leave);
            txtVariance2.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtVariance2.Leave += new EventHandler(txtAveVar_Leave);
            txtVariance3.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtVariance3.Leave += new EventHandler(txtAveVar_Leave);
            txtVariance4.KeyDown += new KeyEventHandler(txtAveVar_KeyDown);
            txtVariance4.Leave += new EventHandler(txtAveVar_Leave);
            //
            //
            myPane = zgc.GraphPane;
            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);

            // Fill the pane background with a color gradient
            myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);
            //
            // fill by default values
            //
            fuzzy = new FuzzyLogic();
        }
예제 #3
0
 /// <summary>
 /// Fuzzy Logic Algorithm for 
 /// Chase and catch rabbits by foxes
 /// </summary>
 private void Fuzzy()
 {
     fuzzy = new FuzzyLogic();
     double DXF; // Fox displacement distance for the X axis
     double DYF; // Fox displacement distance for the Y axis
     double DXR; // Rabbit displacement distance for the X axis
     double DYR; // Rabbit displacement distance for the Y axis
     Point pFox; // Location central of Fox
     Point pRabbit; // Location central of Rabbit
     //
     // Keep the commands until the distance of the fox rabbit is more than 35
     //
     while (FuzzyLogic.Distance(shapCentral(Fox.Size, Fox.Location),
             shapCentral(Rabbit.Size, Rabbit.Location)) > 35)
     {
         pFox = shapCentral(Fox.Size, Fox.Location);
         pRabbit = shapCentral(Rabbit.Size, Rabbit.Location);
         //
         // Move Rabbit Code
         //
         moveRabbit(pRabbit.X, pRabbit.Y, pFox.X, pFox.Y, out DXR, out DYR);
         pRabbit.X += (int)DXR;
         pRabbit.Y += (int)DYR;
         show(Rabbit, pRabbit);
         //
         // Move Fox Code
         //
         moveFox(pRabbit.X, pRabbit.Y, pFox.X, pFox.Y, out DXF, out DYF);
         pFox.X += (int)DXF;
         pFox.Y += (int)DYF;
         show(Fox, pFox);
         //
         // this thread waited a few milliseconds.
         //
         Thread.CurrentThread.Join(renderSleep);
     }
     //
     #region End of Find Rabbits
     timerTickCount.Stop();
     MessageBox.Show(string.Format("Fox successful to get a rabbit to be within {0} seconds.",
         (Environment.TickCount - Time) / 1000), "Fox brings rabbit to grab",
         MessageBoxButtons.OK, MessageBoxIcon.Information);
     check(chbtnStartStop, false);
     #endregion
 }