Show Bid Request
Game of fifteen using Microsoft Visual C++ 6.0
Bid Request Id: 386
|
|
|
Description:
FIFTEEN game is played on a 4x4 frame that contains 15 tiles numbered from 1 to 15. For example--
4 7 1 11 9 8 6 10 5 . 3 2 12 14 13 15
The dot represents an open space. The player slides one of the tiles that is adjacent to the open space into the open space. For example, in the above situation the player may move the 8, 5, 3 or 14. If the player slides the 3 into the open space, then the frame will look like this:
4 7 1 11 9 8 6 10 5 3 . 2 12 14 13 15
If the player next moves the 6 into the open space, then the frame will look like this:
4 7 1 11 9 8 . 10 5 3 6 2 12 14 13 15
The goal is to arrive at the winning configuration--
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 .
Your job is to write a program that allows the user to play this game. Represent the frame as a two-dimensional array of integers. Write a function with prototype--
void move(int [ ][4], int n)
that checks to see if n is valid (i.e. the number n is adjacent to the open space), and if so moves n into the open space. Invalid moves are ignored.
Also write a function with prototype--
void display(int [ ][4])
that displays the frame as above. Use the setw manipulator to line the numbers up in columns of width 4.
Deliverables: Source code has to be compatible with Using Microsoft Visual C++ 6.0
Your program should first display the rules to the user. Then it should initialize the frame to the winning position and call the move function a thousand times with a random integer between 1 and 15, so that the frame is shuffled to a configuration from which it is possible to get to the winning configuration. Not all of the calls will be valid moves, but the invalid moves will simply be ignored. Note that this procedure is different than simply placing each number 1 to 15 into a random position, for in this case it may be impossible to get to the winning configuration.
Once the frame has been initialized, display it and prompt the user to enter a move. Also give the user the option of quitting. Use the move function to update the frame after each move, and the display function to display it.
When the game is over, display the total number of moves.
Special Conditions / Other:
I need it by 06/14/2001 12:00pm
Remember that contacting the other party outside of the site (by email, phone, etc.) on all business projects < $500 (before the buyer's money is escrowed) is a violation of both the software buyer and seller agreements.
We monitor all site activity for such violations and can instantly expel transgressers on the spot, so we thank you in advance for your cooperation.
If you notice a violation please help out the site and report it. Thanks for your help.
|
|
Bidding/Comments:
|
All monetary amounts on the site are in United States dollars.
Rent a Coder is a closed auction, so coders can only see their own bids and comments. Buyers can view every posting made on their bid requests. |
See all rejected bids (and all comments)
Name |
Bid Amount |
Date |
Coder Rating |
|
|
|
This bid was accepted by the buyer!
|
$70 (USD)
|
Jun 12, 2001 8:05:18 AM EDT
|
10
(Excellent)
|
|
|
Will be done. |
|
|
|
|
|