Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USE JAVA Recall the water jug problem discussed in class. Write a program inEet.or Java, that takes an input file specifying: b) initial state, and
USE JAVA
Recall the water jug problem discussed in class. Write a program inEet.or Java, that takes an input file specifying: b) initial state, and c) goal state (all as integer values). The capacities and input state's values are provided as precise amounts. That is, for example, an initial state could be a pair (0, 3). The goal state, however, can be entered as (2, -1) where 2 denotes exactly 2 gallons in the first container and-1 denotes any amount (less than or equal to the allowed capacity) of water in the second container. Similarly, (-1. 3) would denote any amount in the first container (again subject to the capacity constraint) and exactly 3 gallons in the second container). For instance, the goal state (2, 1) would require exactly 2 gallons in the first container and exactly 1 gallon in the second The program should output a sequence of actions necessary to solve the problem, i.e., actions that allow you to arrive at the goal state given your initial state, for two control strategies: a) random given the list of operators ordered in ascending order, randomly generate the next operator's number and check to see if that operator applies to your current state (if so, apply it, otherwise randomly select another operator), and b) a systematic state expansion Example input file Capacity of jug A: 4 Capacity of jug B: 3 Initial state: 00 Goal state: 2-1 Sample output Strategy A Starting out with a 4-gal jug and a 3-gal jug >Empty the 4-gal jug (4, (8, 8) e) state: state: >Strategy B Starting out with a 4-gal jug and a 3-gal jug >Pour water from the 4-gal jug into the 3-gal jug state: (4, ) state: (1, 3) Run your test cases twice, that is for the strategies a) and b) as defined above. For strategy a) if the search is unsuccessful after you have tried 250 state expansions, terminate it. Please use the public cases in D2L) to check your result. Grading will use not only these public cases
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started