Feedjit

Articles for you

Showing posts with label Vacuum Cleaner. Show all posts
Showing posts with label Vacuum Cleaner. Show all posts

Thursday, June 6, 2013

Vacuum Cleaner Artificially Intelligent Implementation A.I based with Auto Manual System in C#



                           VACUUM_CLEANER
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Dru_Cleaner      //Main Form
{
    public partial class Main_Form : Form
    {
        public Main_Form()
        {
            InitializeComponent();}

    private void button2_Click(object sender, EventArgs e)
        {this.Close();}

    private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int choice = int.Parse(textBox1.Text);
                if (choice == 1)
                {
                    Manual_Form obj = new Manual_Form(); obj.Show();this.Hide();}
                else if (choice == 2)
                {
                Automatic_Form obj = new Automatic_Form();obj.Show();this.Hide(); }
                else if (choice == 3)
                {
               Choice_Random obj = new Choice_Random();obj.Show();this.Hide(); }
                textBox1.Text = null;}
            catch (Exception ex) { MessageBox.Show(ex.Message); }}}}
/////////////////////////////////////      Manual Form
namespace Dru_Cleaner{
    public partial class Manual_Form : Form
    {
        public Manual_Form()
        {
            InitializeComponent();}
      
public string[,] lookup = new string[5,3];
private void button1_Click(object sender, EventArgs e)
        {
         string location, status = null;location = textBox1.Text.ToUpper();
         status =   textBox2.Text.ToUpper();int bound0 = lookup.GetUpperBound(0);
        int bound1 = lookup.GetUpperBound(1);
            for (int j = 0; j < bound0; j++)
            {
 for (int k = 0; k < bound1; k++){
 
if (location == lookup[j, k])
  {
     if (status == lookup[j, ++k]){ MessageBox.Show(lookup[j, ++k]); }}}}
      textBox1.Text = null;textBox2.Text = null;
        }
private void Form1_Load(object sender, EventArgs e){
            lookup[0, 0] = "A"; lookup[0, 1] = "DIRTY"; lookup[0, 2] = "CLEAN";
            lookup[1, 0] = "A"; lookup[1, 1] = "CLEAN"; lookup[1, 2] = "MOVE RIGHT";
            lookup[2, 0] = "B"; lookup[2, 1] = "DIRTY"; lookup[2, 2] = "CLEAN";
            lookup[3, 0] = "B"; lookup[3, 1] = "CLEAN"; lookup[3, 2] = "MOVE LEFT";}
private void button2_Click(object sender, EventArgs e){
            this.Close();
            Application.OpenForms[0].Show();}}}
/////////////////////////////////////////
namespace Dru_Cleaner
{
    public partial class Automatic_Form : Form
    {
        public Automatic_Form()
        {
            InitializeComponent();}
public string[,] lookup = new string[5, 3];
private void button2_Click(object sender, EventArgs e)
{
  this.Close();Application.OpenForms[0].Show();}

private void button1_Click(object sender, EventArgs e)
{
   textBox1.Text = null;button1.Enabled = false;
   int bound0 = lookup.GetUpperBound(0);int bound1 = lookup.GetUpperBound(1);
 for (int j = 0; j <= bound0; j++)
            {
                for (int k = 0; k <= bound1; k++)
             
 textBox1.Text += "   ";textBox1.Text += lookup[j, k];textBox1.Text += "                    ";
 Stopwatch delayWatch = new Stopwatch();
 while (delayWatch.ElapsedMilliseconds < 1200)
                    {
                        delayWatch.Start();
                        Application.DoEvents();
                        delayWatch.Stop();} } textBox1.Text += Environment.NewLine}}
     textBox1.Text += "STOP...! The whole area is now cleaned up";
            button1.Enabled = true;}
        private void Automatic_Form_Load(object sender, EventArgs e)
        {
            lookup[0, 0] = "A"; lookup[0, 1] = "DIRTY"; lookup[0, 2] = "CLEAN";
            lookup[1, 0] = "A"; lookup[1, 1] = "CLEAN"; lookup[1, 2] = "MOVE RIGHT";
            lookup[2, 0] = "B"; lookup[2, 1] = "DIRTY"; lookup[2, 2] = "CLEAN";
            lookup[3, 0] = "B"; lookup[3, 1] = "CLEAN"; lookup[3, 2] = "MOVE LEFT";
            lookup[4, 0] = "A"; lookup[4, 1] = "CLEAN"; lookup[4, 2] = "MOVE RIGHT";
        }}}
////////////////////////////   //Random Choic Form
namespace Dru_Cleaner
{
    public partial class Random_Form : Form
    {
        public Random_Form()
        {
            InitializeComponent();
        }
        public string[,] lookup = new string[5, 3];
 private void Random_Form_Load(object sender, EventArgs e)
        {
            lookup[0, 0] = "A"; lookup[0, 1] = "DIRTY"; lookup[0, 2] = "CLEAN";
            lookup[1, 0] = "A"; lookup[1, 1] = "CLEAN"; lookup[1, 2] = "MOVE RIGHT";
            lookup[2, 0] = "B"; lookup[2, 1] = "DIRTY"; lookup[2, 2] = "CLEAN";
            lookup[3, 0] = "B"; lookup[3, 1] = "CLEAN"; lookup[3, 2] = "MOVE LEFT";
        }

 private void button1_Click(object sender, EventArgs e)
        {
    if (textBox1.Enabled==false)
            {
                Random RandNum = new Random();
                int MyRandomNumber = RandNum.Next(4);
                string location, action = null;
                location = lookup[MyRandomNumber, 0];
                action = textBox2.Text.ToUpper();
                int bound0 = lookup.GetUpperBound(0);
                int bound1 = lookup.GetUpperBound(1);
                for (int j = 0; j < bound0; j++)
                {
                    for (int k = 0; k < bound1; k++)
                    {
                        if (location == lookup[j, k])
                        {
                            k++;
                            if (action == lookup[j, ++k])
        { MessageBox.Show("Location:  " + location + "\n" + "State:    " + lookup[j, --k]); }
                        }}}
            }
            else if (textBox2.Enabled == false)
            {
                Random rd = new Random();
                int rnum = rd.Next(4);
                string location, action = null;
                location = textBox1.Text.ToUpper();
                action = lookup[rnum, 2];
                int bound0 = lookup.GetUpperBound(0);
                int bound1 = lookup.GetUpperBound(1);
                for (int j = 0; j < bound0; j++)
                {
                    for (int k = 0; k < bound1; k++)
                    {
                        if (location == lookup[j, k])
                        {
                            k++;
                            if (action == lookup[j, ++k])
        { MessageBox.Show("State:  " + lookup[j, --k] + "\n" + "Action:  " + action); }
                        }
                    }
                }

            }
         textBox1.Text = null;
         textBox2.Text = null;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
            Application.OpenForms[1].Show();
        }
    }
}

Read More

Articles for you