
Battleship Advanced Tactics

Some of these images may be from earlier builds because I may make visual improvements.
Introduction
A version of Battleship that I made using Unity. The game follows the goal of Battleship, but has ships all with different functionalities to make the game much more tactical. As such, this is a Strategy Guessing Game. My main goal was to add more genres that are not the action genre to my portfolio, because most of my games are action games. I want to show that I can make a variety of genres. My goal was to make a strategic game where player and enemy have the same capabilities. Usually, enemies don't have the same capabilities as players, partially because of how much harder or more time consuming it would be to program. I chose to make this game to challenge myself to write more advanced AI. I also wanted to work much more with scenes and scene design. I did this through extensive use of scenes for the gameplay. A cutscene plays for almost every action in the game.

Below is the link to my game, as well as gameplay videos that cover the entire game.
%20-%20Copy.png)
General
My game follows the base rules of Battleship. You and your opponent take turns choosing a square on a radar and seeing if the square has a ship. The major difference with my version is that every ship has a different functionality. For example, Battleships hit five squares in a cross fashion and Destroyers hit three squares in a V fashion, but gives you a second turn. Also, instead of having to find and hit all squares that a ship occupies, you just have to reduce a ship's HP to zero. This means, if you hit a square occupied by a ship, you can keep targeting that square to damage the ship, unlike in the original. However, in this game, ships can only take one point of damage per turn, meaning hitting multiple squares that a ship occupies does not deal multiple points of damage. Allowing multiple points of damage per turn would make the game too easy, because you could potentially hit a ship like the Destroyer that has only three HP, like in the original, with the Battleship five hit shot, hit all the Destroyer's occupying squares and destroy it in one move.
The programming for this game was a lot more complex compared to making an action game surprisingly and is hard to summarize in short terms.
For the game's programming, I used Lists very extensively. I needed Lists mainly to play a collection of scenes. A scene plays for almost every action in the game. The following is the program that makes the scene sequences play. The code is comparable to a to do list that is done from the first task to the last for the game to do.
1.) I used an int List called scenes and a bool List called isDamaged. I need my game to play a scene of the attacking ship and then a scene for each ship that gets attacked by that ship during that turn. So I add an int that represents the scene where the selected ship attacks into scenes List and a bool based on whether the ship only has one HP left to isDamaged List. For example, if the attacking ship is the player's Battleship, I will add int 0 to scenes List. If the Battleship has 1 HP, I will add a true bool to isDamaged List, so that when the scene plays, the Battleship will be consumed in flame as it fires missiles.
​2.) Then if no ship is hit in the targeted squares, I add an int representing a scene of a missile hitting the ocean water. If more than one ship is hit, I add ints representing scenes of those ships getting hit and if they have been hit at 1 HP, I add true bools to isDamage List. This will make it so that the attacked ships with 1 HP will be consumed in flame and explode violently when they are struck by a missile in the scene, representing that they have been destroyed.
​3.) Finally, the method PlayNextScene will determine what scenes to play based on scenes List. Each time a scene plays, a static int, count that starts at 0, is incremented, and I use count to go down the scenes List. Once the last element of scenes List is reached, the game returns to the board and I clear scenes List and isDamaged List and reset count to 0.
​​
The game has a No Cutscene Mode that the players can turn on and the No Cutscene Mode doesn't use scenes List and isDamaged List.
​
The code process is pictured in the images below.
.png)
The order goes from AddHitShipScene, which adds to scenes List and isDamage List, to PlayNextScene
My second main objective was to program an enemy AI that has the exact same capabilities as the player. I programmed an easy, standard and hard difficulty. Easy difficulty has the enemy AI have a small chance of skipping a turn and it does everything randomly. Standard difficulty has the enemy AI never skips turns and for two of its ships, will track the player if they successfully hit a ship, making it more dangerous.
​
Hard difficulty has the enemy AI play like an advanced player by maximizing the capabilities of its ships and by using advanced tactics that I myself thought of for this game. This AI has full thinking. Anything an advanced player would do, the AI will do. It uses three Lists: a names list, a X-coordinate List, and a Y-coordinate List. When the AI finds a ship, it adds the name of the ship and its X and Y coordinates to the respective Lists. Then it calculates which ship to prioritize if its found multiple ships. It will then target an X and Y coordinate of the prioritized ship. If say, the Destroyer, Submarine and Carrier were found on the same turn by the enemy Submarine's whole row search, the AI will prioritize the Destroyer. If only one ship has been found so far, it will prioritize destroying it. If the AI destroys the current prioritized ship, it will remove all references of its name and X and Y coordinates from the Lists. If it misses, because the player has moved the prioritized ship to another location, it will remove that one reference to its name and X and Y coordinate. If there are other coordinates where that prioritized ship was found, it will target those coordinates next. Otherwise, it will move on to target other found ships. The AI will do a lot more besides this.
_edited.jpg)
_edited.jpg)
Hard Difficulty AI uses UsualStrategy() if names List is empty. If not, it uses PriorityCalculator()
My main inspirations for this game were Fire Emblem and Chess as well as a few Shooter games. For Fire Emblem, I was inspired by the turn based combat and how the game uses scenes for every moment of combat. For Chess, I made every piece have a different functionality. I took inspiration from realistic Shooter games like Call of Duty for visuals because I wanted to make the attack effects look more realistic, to represent more realistic warfare and to differentiate from my other games visually, but I still made them partially cartoony to make the game visually appealing.
​
_edited.jpg)
_edited.jpg)
Production Challenges
The biggest challenge in development was making a board game where the pieces take more than one space. Because the pieces take more than one space, I had to make multiple squares acknowledge that they are occupied by a ship. I also had to change the way you can move the ship on the board. Because it is all a coordinate system, I can't use colliders and such to prevent the pieces from moving off the board or moving into another ship on the board. What I did was design "pegs" underneath the ships that touch the board squares and tell the squares that a ship is occupying it. In the original game, pieces have pegs underneath that you use to stick into the board. Then I used the square occupied by the middle "peg" of the ship and a vertical bool to determine where the ship can move, up, down, left, or right. Then when a square is targeted and there is a ship occupying it, the square accesses the peg and then the ship to get the necessary calculations.
A general issue I had was the fact that the enemy AI has the same options as the player and the fact the game is turn based. It made the game much more error prone. In comparison, action games are easier to program for me because enemies don't have the same options as the player and because they are fast-paced, it is easier to test every variable.
_edited.jpg)
_edited.jpg)
Conclusion
This game was fun to program because it was fun to learn how to make scene sequences and to make advanced enemy AIs. This game is a valuable learning experience because my next game will be a 3D Fighter and I will need to program another game where the enemy has the same options as the player and another game where the hardest enemy AI will have the enemy AI play like an advanced player.
For revisions, I may use a single scene of all ships in one scene whenever a ship is attacked and have the camera move over to the attacked ship instead of having a separate scene for a ship being attacked, as pictured above. Doing this would help save on scenes, because there are at least 20 scenes in my game.