Write a Java program to simulate the behaviour of a model-based agent for a vacuum cleaner environment based on the following conditions: The vacuum cleaner can move to one of 4 squares: A, B, C, or D as shown in Table 1. Table 1: vacuum cleaner environment A B C D The vacuum cleaner checks the status of all squares and takes action based on the following order: If all squares are clean, the vacuum cleaner stays in its current location. If the current location is not clean, the vacuum cleaner stays in its current location to clean it up. The vacuum cleaner can only move horizontally or vertically (cannot move diagonally). The vacuum cleaner moves only one square at a time. Horizontal moves have the highest priority over vertical moves. The vacuum cleaner moves to another square only when it needs to be cleaned up. If a diagonal square needs to be cleaned up, the vacuum cleaner moves to its neighbour vertical square first. The vacuum cleaner action is evaluated based on the current location and the status of all squares. The program evaluates only one action (one move) at each run. Example: Current Location A-status B-status C-status D-status Action (Stay in or Move to) A Clean Clean Clean Clean A B Not Clean Clean Clean Clean A B Not Clean Clean Clean Not Clean A Inputs to the program: Current Location = {A, B, C, D} Status can be represented using Boolean datatype, Where: Clean -> true, and Not Clean -> false A-status = { true, false } B-status = { true, false } C-status = { true, false } D-status = { true, false } Output: Action = {A, B, C, D} The program accepts five inputs as command line arguments and prints out the action. Please use the template below. public class MyClass {       public static void main(String args[]) {             char current_location = args[0].charAt(0);        // STATE: true -> clean  , false -> not clean        boolean A_status = Boolean.parseBoolean(args[1]);        boolean B_status = Boolean.parseBoolean(args[2]);        boolean C_status = Boolean.parseBoolean(args[3]);        boolean D_status = Boolean.parseBoolean(args[4]);        System.out.printIn(“Current Location =”  + current_location + “\n” +                             “Square A status=” + A_status + “\n” +                             “Square A status=” + B_status + “\n” +                             “Square A status=” + C_status + “\n” +                             “Square A status=” + D_status + “\n” );         //--------------------------------        // Model-based Agent function here        //---------------------------------------                System.out.printIn(“\nAction – Next Location =”);             } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a Java program to simulate the behaviour of a model-based agent for a vacuum cleaner environment based on the following conditions:

  1. The vacuum cleaner can move to one of 4 squares: A, B, C, or D as shown in Table 1.

    Table 1: vacuum cleaner environment

    A

    B

    C

    D

  2. The vacuum cleaner checks the status of all squares and takes action based on the following order:

    1. If all squares are clean, the vacuum cleaner stays in its current location.

    2. If the current location is not clean, the vacuum cleaner stays in its current location to clean it up.

    3. The vacuum cleaner can only move horizontally or vertically (cannot move diagonally).

    4. The vacuum cleaner moves only one square at a time.

    5. Horizontal moves have the highest priority over vertical moves.

    6. The vacuum cleaner moves to another square only when it needs to be cleaned up. If a diagonal square needs to be cleaned up, the vacuum cleaner moves to its neighbour vertical square first.

    7. The vacuum cleaner action is evaluated based on the current location and the status of all squares.

    8. The program evaluates only one action (one move) at each run.

Example:

Current Location

A-status

B-status

C-status

D-status

Action (Stay in or Move to)

A

Clean

Clean

Clean

Clean

A

B

Not Clean

Clean

Clean

Clean

A

B

Not Clean

Clean

Clean

Not Clean

A

Inputs to the program:

  • Current Location = {A, B, C, D}

    Status can be represented using Boolean datatype,

    Where:

    Clean -> true, and

    Not Clean -> false

    A-status = { true, false }

    B-status = { true, false }

    C-status = { true, false }

    D-status = { true, false }

Output:

  • Action = {A, B, C, D}

The program accepts five inputs as command line arguments and prints out the action. Please use the template below.

public class MyClass {

      public static void main(String args[]) {

            char current_location = args[0].charAt(0);

       // STATE: true -> clean  , false -> not clean

       boolean A_status = Boolean.parseBoolean(args[1]);

       boolean B_status = Boolean.parseBoolean(args[2]);

       boolean C_status = Boolean.parseBoolean(args[3]);

       boolean D_status = Boolean.parseBoolean(args[4]);

       System.out.printIn(“Current Location =”  + current_location + “\n” +

                            “Square A status=” + A_status + “\n” +

                            “Square A status=” + B_status + “\n” +

                            “Square A status=” + C_status + “\n” +

                            “Square A status=” + D_status + “\n” );

        //--------------------------------

       // Model-based Agent function here

       //---------------------------------------

               System.out.printIn(“\nAction – Next Location =”);    

        }

}

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Introduction to classical planning
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education