Skip to content

harshadodda/8tiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

8tiles

Summary:

This program lets the user play the 8 tiles game. The user can play the classic game by themselves or they can ask the program to see if there is a solution for the current board state. If there is a solution, the program will terminate after the solution is reached, if there is no solution, the program will terminate at the best possible board state. the player can set the starting board state and play from that state as well. The user can move tiles by clicking on a tile that is adjacent to the blank tile. The tile that was clicked on will then move to where the blank tile was.

The auto complete algorithm gives the program control of the board and the algorithm figures out how to either solve the puzzle or it generates the best possible board state. This algorithm uses a heuristic to determine the best possible moves and executes those moves accordingly. The program then automatically goes through the moves that the algorithm took to get to the ending board state.

Here is a sample of the program running:

Step 1: Lets have the program set up a random board for us, initially. The initial board it gave us looks like this:

screen shot 2017-06-21 at 4 39 11 pm

Step 2: Lets move a few tiles and see what happens. We will move the tiles in the following order: 3, 5, 6, 3. The screen shots will show the 4 moves in order. Each screen shot will show the board state before the move. The 5th screen shot will show the board state after the 4 moves.

screen shot 2017-06-21 at 4 39 11 pm

Step 3: First we move tile 3.

screen shot 2017-06-21 at 4 39 27 pm

Step 4: Then we move tile 5.

screen shot 2017-06-21 at 4 39 36 pm

Step 5: Next we move tile 6.

screen shot 2017-06-21 at 4 39 44 pm

Step 6: Finally we move tile 3 again.

screen shot 2017-06-21 at 4 39 53 pm

Now let us manually configure a board and have the auto complete algorithm try to finish the game for us.

screen shot 2017-06-21 at 4 40 10 pm

This is the ending board state after using the automatic solver algorithm. It looks like the initial board we gave has a solution so the ending board is the numbers in order. Some boards do not have a solution and in these cases, the algorithm will display the best possible board state.

screen shot 2017-06-21 at 4 42 32 pm

About

8 Tiles game in Java with a GUI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages