Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to create a simple reflex agent for a vacuum program. The vacuum agent wi

ID: 3752215 • Letter: I

Question

I need to create a simple reflex agent for a vacuum program. The vacuum agent will show up in one of the rooms and percept the room to look for dirt, if dirt is found it will then clean the room. Once the room has been cleaned it will move to the next room and do the process over again. The goal is to have both rooms clean. I am designing the assignment in Visual Studio as a sln file. The following code is my header file.

MyForm.h

#pragma once

namespace Project1 {

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

/// <summary>

/// Summary for MyForm

/// </summary>

public ref class MyForm : public System::Windows::Forms::Form

{

public:

MyForm(void)

{

InitializeComponent();

//

//TODO: Add the constructor code here

//

}

protected:

/// <summary>

/// Clean up any resources being used.

/// </summary>

~MyForm()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::Button^ button1;

protected:

private: System::Windows::Forms::PictureBox^ pictureBox1;

private: System::Windows::Forms::PictureBox^ pictureBox2;

private: System::Windows::Forms::Label^ label1;

private: System::Windows::Forms::Label^ label2;

private: System::Windows::Forms::Label^ label3;

private: System::Windows::Forms::Timer^ timer1;

private: System::Diagnostics::EventLog^ eventLog1;

private: System::ComponentModel::IContainer^ components;

private:

/// <summary>

/// Required designer variable.

/// </summary>

#pragma region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

void InitializeComponent(void)

{

this->components = (gcnew System::ComponentModel::Container());

System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));

this->button1 = (gcnew System::Windows::Forms::Button());

this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());

this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());

this->label1 = (gcnew System::Windows::Forms::Label());

this->label2 = (gcnew System::Windows::Forms::Label());

this->label3 = (gcnew System::Windows::Forms::Label());

this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));

this->eventLog1 = (gcnew System::Diagnostics::EventLog());

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox2))->BeginInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->eventLog1))->BeginInit();

this->SuspendLayout();

//

// button1

//

this->button1->Location = System::Drawing::Point(596, 389);

this->button1->Name = L"button1";

this->button1->Size = System::Drawing::Size(146, 30);

this->button1->TabIndex = 0;

this->button1->Text = L"State start";

this->button1->UseVisualStyleBackColor = true;

this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);

//

// pictureBox1

//

this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox1.Image")));

this->pictureBox1->Location = System::Drawing::Point(42, 30);

this->pictureBox1->Name = L"pictureBox1";

this->pictureBox1->Size = System::Drawing::Size(299, 228);

this->pictureBox1->TabIndex = 1;

this->pictureBox1->TabStop = false;

//

// pictureBox2

//

this->pictureBox2->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox2.Image")));

this->pictureBox2->Location = System::Drawing::Point(517, 30);

this->pictureBox2->Name = L"pictureBox2";

this->pictureBox2->Size = System::Drawing::Size(299, 228);

this->pictureBox2->TabIndex = 2;

this->pictureBox2->TabStop = false;

this->pictureBox2->Visible = false;

//

// label1

//

this->label1->AutoSize = true;

this->label1->Location = System::Drawing::Point(151, 277);

this->label1->Name = L"label1";

this->label1->Size = System::Drawing::Size(58, 17);

this->label1->TabIndex = 3;

this->label1->Text = L"Room A";

//

// label2

//

this->label2->AutoSize = true;

this->label2->Location = System::Drawing::Point(639, 277);

this->label2->Name = L"label2";

this->label2->Size = System::Drawing::Size(58, 17);

this->label2->TabIndex = 4;

this->label2->Text = L"Room B";

//

// label3

//

this->label3->AutoSize = true;

this->label3->Location = System::Drawing::Point(51, 326);

this->label3->Name = L"label3";

this->label3->Size = System::Drawing::Size(473, 51);

this->label3->TabIndex = 5;

this->label3->Text = L"Initial State : Room A and Room B are dirty, and the vacuum is in Room A Action"

L"s : Percept, Suck, Move right, Move left Goal : both rooms are clean";

//

// timer1

//

this->timer1->Interval = 1000;

this->timer1->Tick += gcnew System::EventHandler(this, &MyForm::timer1_Tick);

//

// eventLog1

//

this->eventLog1->SynchronizingObject = this;

//

// MyForm

//

this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->ClientSize = System::Drawing::Size(857, 529);

this->Controls->Add(this->label3);

this->Controls->Add(this->label2);

this->Controls->Add(this->label1);

this->Controls->Add(this->pictureBox2);

this->Controls->Add(this->pictureBox1);

this->Controls->Add(this->button1);

this->Name = L"MyForm";

this->Text = L"MyForm";

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox2))->EndInit();

(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->eventLog1))->EndInit();

this->ResumeLayout(false);

this->PerformLayout();

}

#pragma endregion

public: bool MoveLeft, MoveRight, DirtA, DirtB;

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

{

//this->timer1->Enabled = true;

//this->timer1->Start();

}

private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)

{

this->timer1->Stop();

int x = 1;

int y = 1;

DirtA = false;

DirtB = false;

this->timer1->

if (this->pictureBox1->Enabled == true)

{

this->label3->Text += " Percept";

if (x == 1)

{

this->label1->Text += "Dirty";

this->label3->Text += " Dirt found";

DirtA = true;

if (DirtA == true)

{

this->label3->Text += " Suck";

x = 0;

this->label1->Text = "Clean";

}

}

}

if (this->pictureBox2->Enabled == true)

{

this->label3->Text += "Percept";

if (x == 1)

{

this->label3->Text += "Dirt found";

DirtA = true;

if (DirtA == true)

{

this->label3->Text += "Suck";

x = 0;

}

}

}

}

};

}

My problem is the output happens all at once instead of staggering. I need the agent to run through all the logic for both rooms, while doing everything one step at a time.

Explanation / Answer

PROGRAM Agent:

START

PROCEDURE CheckAndClean :

IF Status Of Current Square is Dirty

THEN CALL Suck;

END IF

END PROCEDURE

CALL CheckAndClean;

IF location is A

THEN

CALL Right;

CALL CheckAndClean;

CALL Right;

CALL CheckAndClean;

END IF

ELSE IF location is B

THEN

CALL CheckAndClean;

CALL Left;

CALL CheckAndClean;

CALL Right;

CALL Right;

CALL CheckAndClean;

END IF

ELSE IF location is C

THEN

CALL CheckAndClean;

CALL Left;

CALL CheckAndClean;

CALL Left;

CALL CheckAndClean;

END IF

END

PROGRAM RationalAgent:

START

PROCEDURE CheckAndClean :

IF Status Of Current Square is Dirty

THEN CALL Suck;

END IF

END PROCEDURE

CALL CheckAndClean;

IF the location of the square is A

IF Square B is Dirty // Use a mapping table.

THEN

CALL Right;

CALL Suck;

END IF

IF Square C is Dirty

THEN

CALL Right;

CALL Suck;

END IF

END IF

IF the location of the square is B

IF Square A is Dirty

THEN

CALL LEFT;

CALL Suck;

IF Square C is Dirty

THEN

CALL Right;

CALL Right;

CALL Suck;

END IF

END IF

ELSE IF Square C is Dirty

THEN

CALL Right;

CALL Suck;

END IF

END IF

IF the location of the squre is C

IF Square B is Dirty

THEN

CALL LEFT;

CALL Suck;

IF Square A is Dirty

THEN

CALL Left;

CALL Suck;

END IF

END IF

ELSE IF Square A is Dirty

THEN

CALL Left;

CALL Left;

CALL Suck;

END IF

END IF

END

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote