This is a Battleship Game built using HTML, CSS, and JavaScript. It simulates the classic battleship experience where players take turns guessing the location of their opponent’s ships.
0
stars
3
forks
source link
Integrate Difficulty Levels: Easy, Medium, Hard #6
This PR introduces a new feature that adds three distinct difficulty levels to the game: Easy, Medium, and Hard. Each level offers a unique challenge, providing a more dynamic and customizable gameplay experience for players of all skill levels. The main changes are as follows:
Changes Made:
Easy AI Logic:
The Easy AI selects random squares on the grid without any strategic consideration.
This level was designed to give a casual and relaxed gameplay experience for new players or those seeking a lower difficulty.
Medium AI Logic:
The Medium AI now uses a basic strategic approach, selecting adjacent squares around the last successful hit.
The logic filters adjacent squares, ensuring it doesn't target squares that have already been hit (boom) or missed (miss).
If no valid adjacent squares are available, it reverts to a random selection from the remaining unhit squares.
This AI level provides a balanced challenge, making it more engaging for intermediate players who expect some strategy from the AI.
Hard AI Logic:
The Hard AI implements a more advanced and aggressive strategy, where it methodically targets squares and continues hitting adjacent squares upon a successful hit until the entire ship is sunk.
This level is designed for advanced players who are looking for a serious challenge, with the AI being highly efficient and difficult to defeat.
Reason for Changes:
Improved Player Experience: By adding difficulty levels, players can now select their preferred challenge level, increasing the game’s accessibility and replayability.
Balanced Gameplay: The introduction of the Medium AI ensures that players have a middle ground between the randomness of the Easy AI and the ruthless efficiency of the Hard AI. The strategic selection of adjacent squares after a hit adds more depth to the game without making it overwhelming.
Scalability: This new structure lays a foundation for future AI improvements or additional difficulty levels, allowing us to continue enhancing the gameplay experience.
Testing:
This PR introduces a new feature that adds three distinct difficulty levels to the game: Easy, Medium, and Hard. Each level offers a unique challenge, providing a more dynamic and customizable gameplay experience for players of all skill levels. The main changes are as follows:
Changes Made:
Easy AI Logic: The Easy AI selects random squares on the grid without any strategic consideration. This level was designed to give a casual and relaxed gameplay experience for new players or those seeking a lower difficulty. Medium AI Logic: The Medium AI now uses a basic strategic approach, selecting adjacent squares around the last successful hit. The logic filters adjacent squares, ensuring it doesn't target squares that have already been hit (boom) or missed (miss). If no valid adjacent squares are available, it reverts to a random selection from the remaining unhit squares. This AI level provides a balanced challenge, making it more engaging for intermediate players who expect some strategy from the AI.
Hard AI Logic: The Hard AI implements a more advanced and aggressive strategy, where it methodically targets squares and continues hitting adjacent squares upon a successful hit until the entire ship is sunk. This level is designed for advanced players who are looking for a serious challenge, with the AI being highly efficient and difficult to defeat.
Reason for Changes: Improved Player Experience: By adding difficulty levels, players can now select their preferred challenge level, increasing the game’s accessibility and replayability. Balanced Gameplay: The introduction of the Medium AI ensures that players have a middle ground between the randomness of the Easy AI and the ruthless efficiency of the Hard AI. The strategic selection of adjacent squares after a hit adds more depth to the game without making it overwhelming. Scalability: This new structure lays a foundation for future AI improvements or additional difficulty levels, allowing us to continue enhancing the gameplay experience. Testing: