Highlights
One can now pour the contents of one vessel into another one, without spilling, and stopping when the target vessel is filled. The task is the following: by pouring back and forth, how can one split the total of 8 litres of milk into two equal portions of 4 litres each? How can one pour the contents of the vessels from one to another such that at the end of the pouring process, one
vessel should contain 4 litres and another one also 4 litres. The following considerations apply: it is not allowed to estimate quantities “by eye”. In pouring the contents from one vessel to another, one stops either when the pouring vessel is empty, or
when the target vessel is full. One can not do a “partial decanting”.
1.1.2 The Rules for the General Decanting Task
State Consider a number of vessels 1,2,. . . ,n. Each vessel i has a capacity ci (which is an integer larger than 0). In each state, there is given a fill level fi (which is an integer ranging from 0 to the capacity of the vessel: 0 ? fi ? ci).
In above example, we had: (c1, c2, c3) = (5, 3, 8) and for the start fill level (f1, f2, f3) = (5, 3, 0).
Move A move consists of pouring the contents of one vessel i into another vessel j such that
1. nothing is spilled or added (conservation of liquid);
2. decanting stops when
• i is empty; or
• j is full; (or both).
Goal Starting with a particular start configuration, find a sequence of moves such that a goal configuration is reached (in the example from Sec. 1.1.1, that is (f1, f2, f3) = (4, 0, 4).
1.1.3 The Task
Based on the search algorithms covered in the lecture, write a Python program that starts from some starting state, (f1, f2, f3) and moves according to the rules until it reaches a given goal state for the decanting task. Your solution must at least be able to solve the example from Sec. 1.1.1, but should be more general than that, in that it allows for larger number of vessels and different fillings (see below for a variant).
For this, you have to adapt the search algorithms introduced in the lecture presented in the lecture and apply it to a Decant class which you have to write. Keep in mind that a naive depth-first search need not work, as the problem can repeat positions.
1.1.4 Detailed Instructions and Marking Scheme
Core Tasks You need to write a class Decant and define for it (at least) the following class methods:
1. start(self): returns the starting state for the decanting task.
2. goal(self, node): returns True if the configuration node is a goal configuration, i.e. if it fulfils the target requirement (in the example from Sec. 1.1.1, two vessels with 4 liters each).
3. such(self, node): yields successively all the successors of the configuration indicated by the node.
Furthermore, you will have to write
4. the code importing the various modules
5. the code running the search and printing the results
2 Advanced Tasks Once you have successfully implemented the depth-first or breadth-first solution for the Decanting Task, you can proceed to implement a variant of the problem for additional marks.
6. demonstrate the operation of your solution by solving a variant of the first task, with capacities (c1, c2, c3) = (7, 4, 3), initial state (f1, f2, f3) = (7, 0, 0) (all 7 litres in the first vessel at the beginning), target state (2, 2, 3). [2 mark]
7. modify your class to handle the following variations of the problem:
You have two vessels, one with 4 and one with 9 litres volume. You also have a tap (which allows you to completely fill a vessel) and a sink (which allows you to completely empty a vessel). How can you use the vessels to obtain exactly 6 litres of liquid (collected in a single vessel)?
2 Task: Bayesian Update — A “Whale Watching” Scenario
2.1 Description
The task consists of writing a Python program which simulates a ship trying to reach a whale in a 10 × 10 grid world. More precisely, the ship moves through the grid world and measures (e.g. by “sonar”) a distance to the whale. From it, it deduces where the whale could be (using a Bayesian model), moves, measures again, etc. until it knows where the whale is.
More precisely, the skeleton of the Python program is provided with the file whale_fillin.py (Fig. 1) and the task consists of filling in the missing components.
2.1.1 The Rules for the “Whale Watching” Scenario World The world consists of a 10 × 10 array, both x and y coordinates are numbered from 0 to 9 inclusive, in standard Python convention. Both, whale and ship are located on one of these
(x, y) positions, and the initial positions are randomly chosen (see the __init__() methods of the Whale and the Ship class in the whale_fillin.py file, Fig. 1).
Scenario Run Loop The scenario run loop is already implemented in the whale_fillin.py file (Fig. 1), via the function run(whale, ship) and the main body of the program.
The run loop of the Whale Watching scenario has the following phases:
1. It is first checked whether the whale has been found by the ship, which means that the ship has moved to the same location as the whale.
2. If this is the case, the scenario is completed successfully.
3. If not, the whale performs its move (to be filled in according to the specification in the
Tasks sections, Secs. 2.1.2 and 2.1.3).
4. The ship now obtains the measurement of its distance to the whale — implemented in method whale. estimated by(ship). The distance between two locations l1 = (x1, y1) and l2 = (x2, y2) is computed via
This Computer Science Assignment has been solved by our Computer Science experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.