Build a console game in C++ which goal is to fill out the cell board with the corresponding number. The program shouldn’t have GUI like the one shown below; it is just a visual representation. The following are the game rules:
- Consecutive numbers must be adjacent, either horizontally, vertically or diagonally.
- For the 5×5 grid there are 25 positions and all those positions need to have a number on it (after auto generating position number 1 all other numbers should be in ascending order until 25)
- All numbers must be placed in the corresponding row, column, or diagonal in which they appear around the border of the board grid.
The game starts by placing number 1 randomly into the 5×5 inner grid
Immediately after that happens, the program plays and solves(random path) the game for the user. Note: The outer grid(grey cells) will be a guide for the user to fill out the 5×5 white grid.
The user then fills out the 5×5 grid by using the already preset values in the outer grey square as a guide on how to fill it out. Example above shows a game completed by user.
It is important to know that a game played n times at one moment will generate the same starting position, however, that doesn’t mean the program would calculate the same result. The calculated path should be randomly generated and for a same starting position, the path should be randomly generated.
It means after playing a number of n times, the game at one moment will place the starting position “1” in the same place as before (2nd row 4th column), however, the game will (probably) trace a path different from the previous game played.
If you have doubts, try to grab a piece of paper and draw a 5×5 grid and then choose a random starting position for number 1, continue adding numbers(2 adjacent to 1, 3 adjacent to 2 and so on until there are no more blank spaces left. Only difference between paper and the computer game the solution must have been calculated by the game and displayed in the outer grid while users’ job is to complete the path by following the pattern in the outer grid.


0 comments