## Project

### A. Goals

This is a closed-ended project that provides you the opportunity to apply everything you have learned in CIS 110 to one of the options below. You will be responsible for choosing one of the four given problems, analyzing that problem to determine how to solve it, decomposing the functionality of your program to identify its class structure and the API for each class, and then implementing and testing your program. You will ​not​ be given any skeleton code for this project. You must write your own files and make the best design and data structure choices as you see fit.

You are ​not​ permitted to work with a partner on this project.

Start early and reach out if you have any questions or concerns.

You may be tempted to use code directly from the internet or use such code as a base template. Please do not do so. We are extremely adept at catching such cases and strict action will be taken.

### B. Project Requirements

In this assignment, you will implement 1 of 4 games below. Your project must use ​object-oriented​ design. If you implement your entire project as static, with no object instances, you will lose significant points. Each project has their own requirements enumerated at the end of their writeup.

### C. Project Ideas

You must pick one of these 4 options. Brickbreaker - implement the game Brickbreaker using mouse or keyboard controls. 2048 - implement 2048 game using keyboard controls. 9x9 Sudoku Solver - Implement an interactive Sudoku game. Minesweeper - a classic puzzle game where you have to be careful where you click! Implement the beginner difficulty of minesweeper.

### D. Designing the Game

We encourage you to spend time thinking out the design of your game before you begin programming it. A well-thought out design would include a list of classes, the functionality corresponding to each class, the fields and methods contained in each class, and the functionality corresponding to each method.

If you spend the time creating a design, we encourage you to stop by office hours and talk over your design with a TA before you begin coding.

### Sudoku

In this project, you will implement an interactive 9x9 Sudoku game. ​You can practice solving strategies by playing here. Sudoku​ is a puzzle where a player must fill an ​n​x​n​ (typically 9) grid with numbers 1-​n​ such that no single number appears twice in any row, column, or grid box. Typically, Sudoku puzzles are written such that they have 1 and only 1 solution. This means most Sudoku’s can be solved by deductive reasoning.

The input sudoku table will be passed as a text file. For example, ​this text file​ represents the Sudoku puzzle below. This file should be passed in via ​command line arguments​. Each digit is used for a square that is filled in at the start, while a whitespace character ​’ ‘​ is used for an empty square. Your program should produce a meaningful error message if the input is incorrectly formatted (such as not 9x9 characters, using characters besides whitespace and digits 1-9, or an illegal grid, such as two 4s in the same row as a starting point.)

Note that in 9x9 Sudoku, the grid boxes are all 3 rows by 3 columns. A single digit cannot appear twice in a bolded box. Your program will be an interactive sudoku game with meaningful visual interactions and involve both the mouse and keyboard. It cannot simply be text based through the command line.

Players must be able to choose which square they want to provide input for and then be able to type in a number to put in that square.

If a player inputs a value which directly violates a rule (for example, there was already a 1 in the row and the player input another 1 in the same row), you should mark the contradictory values in red and highlight the region of the board causing an issue. For example, if there’s a conflict in the second row, you should highlight the second row and mark the problem values in red. If there’s a contradiction in both a row and a column, you should highlight both the row and the column, etc. When a player has filled in all the squares correctly, you should provide a “win” message.

#### Extra Credit

The following additions are each worth extra credit points. You can not receive more than 5 points of extra credit. They are also challenging and cool additions to code into your game!

• Implement clear, where presing the space bar clears all numbers inputted in by the user (1 pt)
• Implement a solver button, which solves the sudoku board upon clicking it (3 pts)
• Implement a 6x6 Sudoku board as a level (cannot be done in place of the 9x9 board, but instead includes a 6x6 board as a possible option) (1 pt)
• Implement a color-scheme feature which allows the user to toggle between dark mode (light colored text on a dark background) and light mode (dark colored text on a light background) (1 pt)

### Brickbreaker

In this project, you will implement the game, Brickbreaker. ​If you need a refresher or introduction to the game, you can play here.

Brickbreaker is a game in which a ball is initially launched from a platform and collides with bricks in the upper region of the game board. When the bricks have been hit a certain amount of times, they lose their strength completely, and disappear. The game (or a certain level) is complete when the ball knocks out all of the bricks. The game is lost when the ball falls to the ground (off-screen), missing the platform enough times that it no longer has any lives/attempts left.

#### Requirements

• The game must have a restart feature such that when the player has no more lives, the screen redirects to a page that requires user input to restart the game as if the program were run for the first time.
• Each time the ball misses the platform or if the game is being played for the first time, the game must begin with the ball stationary on the platform and require player input before the ball is allowed to begin movement again.
• The platform must only move in the x-direction.
• There must be at least three kinds of bricks with varying strengths and their strength should be differentiated with some visual cue.
• Each of the three kinds could be a different color
• Or you could display a number on each brick, representing its strength
• In addition, when a brick loses strength after a collision, there should be some visual cue to indicate that it was hit by the ball.
• The ball must bounce off the top, left, and right boundaries.
• The ball must move with some velocity in the x-direction and y-direction as well as an acceleration.
• The acceleration should change in different way when it collides with a brick compared to when it collides with the platform.
• If the player eliminates all of the bricks, the game should stop, a victory message should be displayed in text on the screen, and the player should have the option to start a new game.
• It is up to you how complex or simple to to make this movement, but at a minimum the acceleration should be affected in some unique way in the two cases described above.
• The game must specify the number of lives the player has.

#### Extra Credit

The following additions are each worth extra credit points. You can not receive more than 5 points of extra credit. They are also challenging and cool additions to code into your game!

• Implement a score feature which keeps track of the user’s score (1 pt)
• Implement power up bricks which change the game state after being hit (lengthens platform, adds an extra ball, grants an extra life, etc) (1 pts per power up, maximimum of 3 pts for 3 power ups)
• Implement a toggle feature which allows the user to decide between different backgrounds or color schemes for a given level (1 pt)

### 2048

For this option you will be implementing the highly addictive 2048 game. Here is a description of the game. ​If you need a refresher or introduction to the game, you can play here.

The best way to understand the game is to play it yourself. You can find an online version ​here​.

Your game should have a 4x4 grid. Using WASD controls (W is up, A is left, D is right, S is down). Pressing in a direction moves all blocks in that direction. Example:

Like numbers can be “combined”. That is, if two numbers “crash” into each other, they combine to be the sum of the two numbers. For example, two “2” blocks would combine to be a “4”, and two “4” blocks would combine to be an “8”. Example:

There are two special cases worth considering, 3 elements in a row or column and four in a row or column. Example of 3 in a row:

#### Requirements

• The user’s screen should be a 4x4 grid. Each square on the grid either contains a number tile or not.
• You are not required to match any aesthetic style. I.e., the number colors are not required. However, the numbers should be visible within each cell, and should be easily legible.
• The user presses one of four keys - w, s, a, d which represent the directions up, down, left, right. All the current tiles on the board shift to the direction specified by the user’s key press. If a number tile “crashes” into another tile with the same number - then they merge to form a single tile with twice the value.
• During every turn, a new number tile consisting of 2 or 4 should enter the board. The tile must enter at any random, unoccupied position on the board.
• If the grid is full of number tiles and there is no move possible for the user then the game is over. If the user has managed to bring a 2048 tile onto the board (by merging 2 1048 tiles) then the user wins.
• Do not end the game if there are possible moves, even if the board is full!
• The game should keep track of the number of moves made by the user and output this in the victory/defeat message.

#### Extra Credit

The following additions are each worth extra credit points. You can not receive more than 5 points of extra credit. They are also challenging and cool additions to code into your game!

• Implement animation in the game (i.e. show the blocks sliding as the user plays the game) (2 pts)
• Implement a color gradient (like the one shown above, where each number has a unique color) (1 pt)
• Implement an AI that plays the game itself as optimally as possible (3 pts)
• Note: as long as there is still a valid move, this AI must find it.
• Implement a hint button which gives a hint to the user as to which direction they should move the pieces (2 pts)

### Minesweeper

Minesweeper is a classic puzzle game (​which can be played here​).

In the game, a single player tries to sweep a minefield to clear out every space that isn’t a mine. Each space is either ​blank​,a​ numberspace,​ or a ​mine. ​The contents of each space are initially hidden. By clicking on a space, you reveal its contents.

A mine ​is a square that if you click on, you lose the game. You can avoid clicking on mine squares by using the hints provided by ​number spaces​.

A number space​ indicates that there is a mine either left, right, up, down, or diagonal of a mine. Clicking on a number square reveals that square and that square only. Example, a 1 means there is 1 mine nearby. The maximum possible digit is 8, which would mean all 8 squares around the space are mines.

A blank space​ is like a numbered square where the number is zero. That is, there are no mines in any of the adjacent 8 spaces. If you click on a blank space, it reveals both itself and all adjacent squares. If any of the adjacent squares are blank, it should further reveal all adjacents squares. For example, in the below game, when I click on the bottom right corner, I got about a third of the board shown:

The player wins the game if they click on every space that isn’t a mine. However, if the player clicks on a single square that is a mine, the player loses the game. Below is an example of a completed minesweeper game:

### Requirements

• The game must be implemented in PennDraw.
• The board must be 9x9 (That is, the same as beginner difficulty).
• There must be exactly 10 mines
• The mines must be placed randomly, they should be in a different place each game
• The mines should not be visible until a player clicks on one (at which point the player loses the game).
• The first square a player picks must never be a mine. The easiest way to handle this is to generate the location of the mines after the player clicks the first square.
• You must generate the numbered squares and blank spaces correctly. That is, if I click on a numbered square and see a “2”, there should be exactly 2 mines touching that square.
• If a player reveals a space that isn’t a mine or adjacent to a mine, it should reveal itself and all adjacent non-mine spaces. Each adjacent space should also reveal itself all adjacent non-mine spaces, and this should continue outwards.
• If a player reveals every space that isn’t a mine, the game should end and the player should get a message saying they won
• If a player reveals a mine, they game should end and the player should get a message saying they lost
• You may use any aesthetic style you like (you are not required to match the windows aesthetic). However, the following must be true:
• The game must be 9x9 grid
• There should be a visible difference between an ​unrevealed​ square and a revealed square
• PennDraw does ​not​ support right clicking, so you do not need to implement the flag mechanic. Similarly, the “middle clicking” tool many minesweeper players use will also not be possible to implement in PennDraw.
• The game must be replayable after a game over (either win or loss) without rerunning the program. The board should be reset - you cannot use the same board as the last game.

### Extra Credit

The following additions are each worth extra credit points. You can not receive more than 5 points of extra credit. They are also challenging and cool additions to code into your game!

In minesweeper, it is valuable to be able to “mark” spaces you know aren’t safe. This is done typically using a flag. In most variations of the game, this is done by right clicking with the mouse. However, PennDraw does NOT support right clicking. Try to implement another way to use flagging in the game. This could include things like:

• Implement a “flagging” mode. Have a button on the screen that enables the user to toggle to “flagging” mode. While in flagging mode, clicking on a square does NOT reveal it. It does mark it with a flag, however. This button would switch the user between “flagging” mode and “revealing” (that is, click reveals the tile) mode. (2 pts)
• Implement the “flagging” mode by allowing the user to toggle between modes if they click on a title while holding the space bar. This approach may be a bit more intuitive to play with, but is harder to implement. (2 pts)
• Implement a menu with multiple difficulties. (2 pts)
• Implement visual effects to make it look cooler. (1 pt)

## Submission

Submissions will be through Gradescope. Any Java source files you submit will be tested for compilation and style. Make sure to submit every file necessary for running your program.

Important: You must write your own README text file and submit it with everything else. Structure it however you wish, but it must contain the following information:

• Instructions for how to run your program (which class to run, any command line arguments)