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?
-
Consider the following pseudo-WEP protocol. The key is 4 bits and the IV is 2 bits . The IV is appended to the end of the key when generating the keystream. Suppose that the shared secret key is 10...
-
The following information appeared in the 2017 annual report of Rumours, Inc.: Long-Term Debt Rumours, Inc. issued $10 million, 10% coupon bonds on January 1, 2014, due on December 31, 2018. The...
-
Continuing Problem: Front Row Entertainment} In addition to developing online fan communities, Cam and Anna believe that they could increase Front Row Entertainment's revenue by selling...
-
As an auditor for the CPA firm of Gratis and Goode, you encounter the following situations in auditing different clients. 1. JR Corporation is a closely held corporation whose stock is not publicly...
-
A proposed project lasts three years and has an initial investment of $200,000. The after-tax cash flows are estimated at $60,000 for year 1, $120,000 for year 2, and $135,000 for year 3. The firm...
-
Determine the zero-force members in the Pratt roof truss. Explain your answers using appropriate joint free-body diagrams. A B 300 N C 400 N D L K J E F I H 12 m, 6 @ 2 m- 3 m
-
During year 1, Perez Manufacturing Company incurred $79,800,000 of research and development (R&D) costs to create a long-life battery to use in computers. In accordance with FASB standards, the...
-
What are the underlying psychological mechanisms driving resistance to change initiatives and how can organizational leaders effectively mitigate such resistance ?
-
Black Langshan chickens have feathered legs. When this breed is crossed with a Buff Rock with featherless legs, the entire F1 generation has feathered legs. Of the 360 F2 offspring, 24 had...
-
What do you think are the shifting economic trends that are affecting the purchasing behavior of consumers and, ultimately, the retailing industry in the current situation, where community quarantine...
-
In a cap with quarterly reset dates, the cap rate is 3.5% per annum and the notional principal is $1 million. Suppose that the LIBOR rate is 4.0% per annum for a particular 3-month period. What is...
-
What are the given variables when we are using the production function? Reference https://content.streamhoster.com/preview/parkg002/Dr_Park_Ch_13-2.mp4?autoPlay=1&width=640&height=360
-
Using these financial statements, what is the value of Net Fixed Assets on 12/31/2021. Put your answer in this format: 1234 Balance Sheet 1/1/2021 Cash 1000 Accounts Payable 300 Accounts Receivable...
-
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?...
-
Production mix and yield variances The Theodore Berlin Manufacturing Company makes construction and road building supplies. One product used as a top coat sealer has the following material standards...
-
Unit standard costs and mix and yield variances The Littlefield Baking Company makes a popular whole-grain bread, which it sells through grocery stores in the region. The bakery uses standard costs...
-
Marketing variance analysis and interpretation Aegean Marine Sales carries several lines of boats and outboard motors. The owner-manager of the company prepared standard sales and cost data for each...
Study smarter with the SolutionInn App