Question: I need this to be done in Visual Studio and also need entire working code for this A02 - Imperative Sliding Tile Puzzle.docx 1 /
I need this to be done in Visual Studio and also need entire working code for this
A02 - Imperative Sliding Tile Puzzle.docx
1 / 5
CIS 221 Programming II: C++ - Programming Assignment
Imperative Sliding Tile Puzzle
Overview
In this assignment, the student will write a C++ program that simulates a traditional sliding tile puzzle. The student will write this simulation strictly using the imperative programming paradigm (function-based programming)
When completing this assignment, the student should demonstrate mastery of the following concepts:
* Imperative Programming Paradigm Usage
* Simulation Design
* Pseudo-Random Program Behavior
* Windows API Calls
* Advanced UI Design Console Color Modification
* Advanced UI Design Simple Refreshing Display/Keystroke Processing
Assignment
In this assignment, you will be strictly adhering to the imperative programming paradigm. This means that objects/classes are not to be created as core operational elements in this solution. Instead, functions performing different tasks along with piece of driver code in main would be appropriate.
You will be creating a simulation for a traditional sliding tile puzzle. If you are unfamiliar with sliding tile puzzles, see the following:
* https://en.wikipedia.org/wiki/Sliding_puzzle
When writing a program using the imperative programming paradigm, you should be break the problem down into a series of functions that represent the logical interactions with the puzzle. You should be sending information to and from your functions with arguments and return values in a meaningful, thoughtful way. To know if you are operating within the spirit of the imperative paradigm, you should find yourself breaking the problem down into a series of repeatable, independent tasks that represent the individual functions of your solution. You should then have core driver logic in the main() function that orchestrates a series of calls to these functions to execute the simulation as you see fit. If you need more information on the imperative programming paradigm, see the following:
* https://en.wikipedia.org/wiki/Imperative_programming
When completing this project, there are several items to take into consideration upfront
You must carefully consider the manner in which you scramble the board initially. In some nave approaches, the tiles are simply lifted and placed
2 / 5
into random locations on the board. This may sound good in a pinch, but further mathematical investigation will quickly reveal that this approach will produce a board that cannot be solved 50% of the time. This happens because a solved state as illustrated in the first screen shot below cannot be transformed into a board state in which the 7 and 8 tiles are hypothetically transposed. In essence, there are two distinct sets of board states and a board that is currently set in one state will never move to one of the states in the other family through a series of legal moves (slides). As a result, you must create routine that scrambles the board by making a series of repetitious legal moves to the puzzle in a random fashion.
You must strategically use color to get full credit for this assignment. You can easily change the fore-color and back-color for the Windows console through the Windows API. It would probably be best to get the puzzle working first and then tackle the color second. However, make sure the colors update as the individual moves are made. You might want to set up a small demo for yourself to explore the manner in which colors are changed through the Windows API to get a handle on this before integrating it into your projects code.
Example Execution Screen Shot #1
When the game begins, the board should appear in the solved state.
Example Execution Screen Shot #2
3 / 5
Have the user press any key to begin scrambling the tiles. Remember, you must make actual moves on the board. A pure random arrangement of the tiles will result in half of the board states being solvable and the other have of the states being unsolvable.
Example Execution Screen Shot #3
Provide the user with an intuitive interface for moving the tiles. When a move is made, trigger the appropriate functions, clear the screen, and re-draw the board to reflect the new state. Do not show the old board states (force the screen to re-draw in an aesthetically pleasing manner). Make sure your prompts are intuitive with clear instructions that would help any reasonably intelligent user interact with your program.
Example Execution Screen Shot #4
4 / 5
Remember, the asterisk (*) represents the pivot point. Things should be considered from the perspective of a user interacting with a sliding tile puzzle since this is a simulation. The directions represent the direction in which a tile is pushed to occupy the blank space, not the direction in which the blank space moves.
Example Execution Screen Shot #5
Tiles placed in incorrect position should be colored in RED.
Example Execution Screen Shot #6
5 / 5
Tile that get moved into their correct resting position should draw in GREEN.
Example Execution Screen Shot #7
The puzzle is solved when every tile has been moved into the correct position
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
