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. 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}

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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:

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:

  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.

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.println("Current Location = " + current location + "\n"+
"Square A status = "+A_status + "\n"+
"Square B status =" + B_status+ "\n"+
"Square C status =" + C_status+ "\n"+
"Square D status =" + D_status + "\n");
- Next Location = ");
}
System.out.println("\nAction
Transcribed Image Text: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.println("Current Location = " + current location + "\n"+ "Square A status = "+A_status + "\n"+ "Square B status =" + B_status+ "\n"+ "Square C status =" + C_status+ "\n"+ "Square D status =" + D_status + "\n"); - Next Location = "); } System.out.println("\nAction
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY