JAVA- OOP Project: Hanoi Tower AI Game In the main page of the application, user will see a Login page which can prompt

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

JAVA- OOP Project: Hanoi Tower AI Game In the main page of the application, user will see a Login page which can prompt

Post by answerhappygod »

JAVA- OOP
Project: Hanoi Tower AI Game
In the main page of the application, user will see a Login pagewhich can prompt the user to login or create a newaccount. Once the user login, they can play the game ofTowers of Hanoi. This game involves moving the tower of disks inone ‘peg’ to the other ‘peg’ without putting the bigger disks ofthe tower on top of the smaller disk of the tower. When the userlogin, user can configure the game. (How many pegs there are, howmany blocks there are, etc.) After the user configs the game, usershould be able to see the visual representation of the tower. Thiscan be implemented using JavaFX. Once the user starts the game(This can happen from a ‘Start’ button), timer goes off until theuser finishes the game. User should be able to interact with theGUI to move the disks around and finish the game. Once the userfinishes game, application stores the record of the game with theusername and time so that anyone accessing the application see therecords. User can give up the game and see the answer. AI with thealgorithm to solve Hanoi tower will show the animation on how thegame could be finished. User need to be able to save and load thegame in progress.
When the application starts, JavaFX window will popup and promptthe user to either login or create an account. If the user wants tocreate an account, the application needs to make sure all theusername in the DB is unique. This has to be done by connecting toJDBC. Application checks the credential by matching the usernameand the password that are stored in the JDBC database. Once loggedin, user can choose to either start the game or load the saved gamefrom the file system. If the user chooses to start the game, theycan specify how many pegs/disks there can be, from which peg towhich peg does the disks have to be moved, etc. Minimum 3 pegs, 3disks, maximum limit is up to the programmer. The application needsto provide an easy UI involving mouse clicks and entering thenumber. For example, they should be able to move the disks from onecolumn to the other by mouse click or drag. Game follows the ruleof Tower of Hanoi. For example, a disk cannot be put on top of adisk that is smaller than them, etc. Application should be able toknow when the game is finished (Solved). When the game is finished,it shows the time record and ask the user whether to save therecord or not. Then, it prompts the user to configure another gameof Tower of Hanoi. Timer keeps track of the time since thebeginning of the game until the user finishes or gives up. Timershould display the lively updated time to the user. Once the userfinishes the game, the application stores the record and store therecord in the JDBC database. Any user can view the game record ofany other user. Application can show the ‘leaderboard’ whichdisplays the top player in each game configuration. User can savethe game without finishing it; thus, the application needs to beable to serialize the object that stores info of the on-going gameand deserialize it if the user wants to load the game andcontinue.
KEY FUNCTIONS The main functions of the simulator may besummarized as follows:
· Login credentials involving JDBC
· User score record involving JDBC
· Save/Load the on-going game using object serialization
· Game GUI with JavaFX
· Algorithm to solve any Tower of Hanoi game
· Animation to show how the algorithm solved the game.
CLASS
DBHelper Class
This is the class to connect to the JDBC database, PUT data onthe database and GET data on the database.
Key methods:
checkUserCredential: take the username and password as stringsand check if the user exists and check if the password is correct.Passwords are good to be hashed for security reasons, but it is notrequired to implement the security side of the application for thisproject.
createNewUser: take the username and password as string tocreate a new user in the database.
DisplayLeaderboard: Sort the players by shortest time to finishthe game and send the list of sorted records.
DisplayRecordOfUser: Get records of the certain user in theDB.
SaveGame Class
This object gets serialized to save the on-going game. It can bestored inside the Java project folder.
Application needs to know if the saved game opened by the rightuser. It needs to stop one user from opening the saved game ofanother user.
GUI Class
This class is specialized for displaying animation and take userinput for the game. It is a good idea to separate game logic fromGUI
AI Class
Like mentioned in the requirement, the application needs to beable to solve the game by itself and display the process inanimation. Solving the Tower of Hanoi game involves an algorithmcovered in the course. It is a good idea to create a separate classto solve the game.
GameLogic Class
Game logic can be implemented in many different ways. Here arethe suggestions:
- Peg object gets populated with ID in the game logic class.Each disk object stores the id of the peg they belong to. Wheneverthe user moves the disk, the event handler access the GameLogicclass to set the position value inside the certain disk object.
- GameLogic class stores a codified information of which disksare in which pegs. This data changes every time there is an inputfrom the user.
- GameLogics can be integrated into the GUI event handlers (Manystudents choose this way and regret it)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply