Solving the Water-Sort-Puzzle Learning objective: Development of a complex, modular program with GUI Content: Class modelling...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Solving the Water-Sort-Puzzle Learning objective: Development of a complex, modular program with GUI Content: Class modelling of the game-state, techniques to structure the task into modules and operation, using a predefined class library, extended functionality in sequence processing, elementary graph search algorithms, building a graphical display using 'tkinter' The Water-Sort-Puzzle Water-Sort-Puzzle is a fun and addictive puzzle game. The objective is to sort segments of colored water in the glass tubes until all colors are in the same glass by filling a segment of color from one glass into another. A challenging problem when the number of tubes and colors increases. JUTU Figure 3: Start of game given a color configuration in 4 tubes Figure 2: After moving color pink from first tube to second The student's task is to write a Python computer program that solves this puzzle. The solution is a sequence of moves filling color from one tube into another. JUJU Figure 1: The target configuration to be achieved Defining a space of states Represent this problem in terms of states and transitions. In our case, each state represents the configuration of the colors within the water tubes. Define a suitable class whose objects describe such a game state. Use immutable objects. So, a state cannot be changed and care must be taken by defining the equal operation and corresponding hash-calculation (see example in figure 4). UUUU Figure 4: These two game states should be regarded to be equal The coding of colors can be done in many ways. But keep in mind: the colors are enumerable. The arrangement of colors as stack within a single tube and several tubes side by side result in a two-dimensional data-structure to represent a color configuration. Again, there are many possible ways to realize this; I don't want to see just one implementation copied by all students. Implementing possible moves of a game state The moves - filling colored water from one tube into another change the color configuration. A move is a transition from one state to another state. The complete state space of this game can be represented by a graph whose vertices are the states and the directed edges are the possible moves. www www Start wwww www wwww www www www www Goal Figure 5: A complete graph given a start state and all transitions towards a goal Identify all possible moves or transitions from the current state (parent) to neighbouring states (children). In the context of the water-sort-puzzle, this means generating all valid moves that can be applied to the current tube configuration. Searching for a solution used to find a solution. The solution is a sequence of transitions Common graph search algorithms can from state to state that begins in start state and ends in the goal state. Two search methods are already implemented: breadth first search (BFS) and depth first search (DFS). Only BFS obtains an optimal solution that means: you reach the goal in a minimum number of transitions. But complex games can only be solved by DFS. To use these search functions your class of a game state must implement some operations - see given code snippets in 'state.py". Graphical display of states A graphical display of a game state is also already implemented and can be used within your Python projects. The display class is based on a 'tkinter' Canvas (see example in this document). Also, a main program exists that shows a solution step by step. To use this display class your state class must provide some elementary operations to access the color configuration. The display is so far limited to 16 different colors. Your Task Compulsory part: You have to implement the missing operations of class state and combine all parts into a running main application that shows the solution of any game. Write a test module that tests your state implementation. Improve the main module that the parameters of the game (number of tubes and colors) should be adjustable by command line arguments in the following way: >>> watercolor tubes-12 colors-10 size-5 Currently these parameters are fixed as constants within the main program. Freestyle part: If you are aiming for an A grade you should do some more, e.g. one of these: Improve the searching algorithm by implementing some heuristics that informed search strategies can be used (like A*), or improve the main GUI so that the game parameters can be selected by graphical input, or add some interactive elements that the game can be played by a user too, or animate a move using a physical simulation of filling water from one tube into another (difficult), or any other additional functions related to the water-sort-puzzle. Solving the Water-Sort-Puzzle Learning objective: Development of a complex, modular program with GUI Content: Class modelling of the game-state, techniques to structure the task into modules and operation, using a predefined class library, extended functionality in sequence processing, elementary graph search algorithms, building a graphical display using 'tkinter' The Water-Sort-Puzzle Water-Sort-Puzzle is a fun and addictive puzzle game. The objective is to sort segments of colored water in the glass tubes until all colors are in the same glass by filling a segment of color from one glass into another. A challenging problem when the number of tubes and colors increases. JUTU Figure 3: Start of game given a color configuration in 4 tubes Figure 2: After moving color pink from first tube to second The student's task is to write a Python computer program that solves this puzzle. The solution is a sequence of moves filling color from one tube into another. JUJU Figure 1: The target configuration to be achieved Defining a space of states Represent this problem in terms of states and transitions. In our case, each state represents the configuration of the colors within the water tubes. Define a suitable class whose objects describe such a game state. Use immutable objects. So, a state cannot be changed and care must be taken by defining the equal operation and corresponding hash-calculation (see example in figure 4). UUUU Figure 4: These two game states should be regarded to be equal The coding of colors can be done in many ways. But keep in mind: the colors are enumerable. The arrangement of colors as stack within a single tube and several tubes side by side result in a two-dimensional data-structure to represent a color configuration. Again, there are many possible ways to realize this; I don't want to see just one implementation copied by all students. Implementing possible moves of a game state The moves - filling colored water from one tube into another change the color configuration. A move is a transition from one state to another state. The complete state space of this game can be represented by a graph whose vertices are the states and the directed edges are the possible moves. www www Start wwww www wwww www www www www Goal Figure 5: A complete graph given a start state and all transitions towards a goal Identify all possible moves or transitions from the current state (parent) to neighbouring states (children). In the context of the water-sort-puzzle, this means generating all valid moves that can be applied to the current tube configuration. Searching for a solution used to find a solution. The solution is a sequence of transitions Common graph search algorithms can from state to state that begins in start state and ends in the goal state. Two search methods are already implemented: breadth first search (BFS) and depth first search (DFS). Only BFS obtains an optimal solution that means: you reach the goal in a minimum number of transitions. But complex games can only be solved by DFS. To use these search functions your class of a game state must implement some operations - see given code snippets in 'state.py". Graphical display of states A graphical display of a game state is also already implemented and can be used within your Python projects. The display class is based on a 'tkinter' Canvas (see example in this document). Also, a main program exists that shows a solution step by step. To use this display class your state class must provide some elementary operations to access the color configuration. The display is so far limited to 16 different colors. Your Task Compulsory part: You have to implement the missing operations of class state and combine all parts into a running main application that shows the solution of any game. Write a test module that tests your state implementation. Improve the main module that the parameters of the game (number of tubes and colors) should be adjustable by command line arguments in the following way: >>> watercolor tubes-12 colors-10 size-5 Currently these parameters are fixed as constants within the main program. Freestyle part: If you are aiming for an A grade you should do some more, e.g. one of these: Improve the searching algorithm by implementing some heuristics that informed search strategies can be used (like A*), or improve the main GUI so that the game parameters can be selected by graphical input, or add some interactive elements that the game can be played by a user too, or animate a move using a physical simulation of filling water from one tube into another (difficult), or any other additional functions related to the water-sort-puzzle.
Expert Answer:
Answer rating: 100% (QA)
Solutions Step1 This is a complex and challenging task that requires Python programming skills and knowledge of graph algorithms However I can provide ... View the full answer
Related Book For
Business Communication Essentials a skill based approach
ISBN: 978-0132971324
6th edition
Authors: Courtland L. Bovee, John V. Thill
Posted Date:
Students also viewed these programming questions
-
Investment pays $125 at the beginning of every 6-month period for the next 10 years (a total of 20 payments). Assuming interest rate is 10% Show this what values go for N, I/Y, PV, PMT in the...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
For Wilder Corporation, sales is $1,600,000 (8,000 units), fixed expenses are $480,000, and the contribution margin per unit is $80. What is the margin of safety in dollars?
-
Why do the earnings per share and return on common shareholders' equity ratios use profit available to common shareholders in their numerator rather than profit?
-
Comcast Corporation is a global telecommunications company headquartered in Philadelphia, PA. Generally known for reliable service, the company periodically experiences unexpected service...
-
Where do you find the sources of law applicable to litigation matters? Explain the differences between the various sources of law.
-
Conduct additional research and answer the following: Discuss what policies are in place at local, state, and federal government levels to prohibit the spread of disease in the case of a pandemic....
-
Question 1: Consider how you felt about outsourcing before and after watching this YouTube video. Answer the following: a) Are there times where you feel it is still appropriate to 'Buy American'? b)...
-
Jackson Manufacturing holds a 150-day note of $10,000 that has an interest rate of 7% annually. After 90 days, the note is sold to a bank at a discount rate of 6% annually. Find the proceeds on the...
-
Question 3 [20 marks] Gibson Rythm Sdn. Bhd. (GRSB) is a manufacturer of sound system with production capacity 1,000 to 2,000 units per month. The following partial completed manufacturing cost...
-
George Black lives in Manitoba, a non-participating province that has an 8 percent provincial sales tax (GST is 5%). During the current year, he purchases a new Lexus for $83,000 from a car dealer....
-
At December 31, 2022, the following information was available for E. Concord Company: ending inventory $32,000, beginning inventory $63,000, cost of goods sold $327,750, and sales revenue $370,000....
-
Like we did previously, you may continually read Walmart and Targets 1 0 - k for fiscal year 2 0 2 0 and then answer the follow questions: 1 . Inventory a . What is the major inventory for the two...
-
Greener Garden Group produces and sells 2 3 , 0 0 0 litres of organic lawn and garden fertilizer. The fertilizer, GoGrow, is a favourite among landscaping companies in southern Manitoba. The selling...
-
John Smith and Mary Jones are in a partnership which provides consulting services in the bio - tech industry. John and Mary share profits and losses on a 2 : 3 ratio. On December 3 1 , 2 0 2 3 , they...
-
A moist soil has a moisture content of 10.2%, weighs 40.66 lb, and occupies a volume of 0.33 ft 3 . The specific gravity of the soil particles is 2.7. Find: (a) bulk density. (b) dry density. (c)...
-
Which of the following streaming TV devices does not involve use of a remote controller? A) Google Chromecast B) Apple TV C) Amazon Fire TV D) Roku
-
For years, a controversy has been brewing over the amount of junk food and soft drinks being sold through vending machines in local schools. Schools benefit from revenue-sharing arrangements, but...
-
You've been proud of many things your gardening tool company has accomplished as it grew from just you working in your basement shop to a nationally known company that employs more than 200 people....
-
Explain what the following gestures or one during a conversation. How did you reach your conclusions about each nonverbal signal? How do such signals influence your interpretation of spoken words?...
-
A steel shaft of diameter \(d\) and length \(l\) is fixed at one end and carries a propeller of mass \(m\) and mass moment of inertia \(J_{0}\) at the other end (Fig. 8.30). Determine the fundamental...
-
Show that the normal functions corresponding to the longitudinal vibration of the bar shown in Fig. 8.29 are orthogonal. x=0 1000 k x=/ FIGURE 8.29 Bar fixed at one end and connected to a spring at...
-
a. Longitudinal vibration of a bar b. Torsional vibration of a shaft c. Transverse vibration of a string \(c=\left(\frac{G}{ho} ight)^{1 / 2}\) Data:- \(c^{2} \frac{\partial^{2} w}{\partial...
Study smarter with the SolutionInn App