Creating Battleship AI?

Hey, and thanks for reading in advance.

Purely out of boredom, I decided to cobble together a literal Roblox-dedicated Battleship game (obviously naming it something else to avoid copyright) but I’m wondering how to proceed now that the admittedly minimal framework is together enough for me to start coding in game logic.

I’ll be playing against the server in the testing phase, but I’m curious as to what mathematics I could use to create a more skilled AI to play against - possibly for the implementation of difficulty levels. The PVP framework is already in place, but for now I want to focus on creating a believable artificial opponent.

For starters, how would I have the AI decide where to place ships? I’ve already created a module that simply requires a vector to locate a tile and determine each tile’s contents - but what algorithm would I use for placing ships? I’d suppose an Easy AI would simply place ships at random and declare attacks on spaces much the same, but what could I do to make playing against the AI more difficult aside from literal clairvoyance?

Help or advice is appreciated.

You could just pick random cells until a hit.

Presumably you will also have a list of possible ship configurations. Use these plus some filtering to pick the most likely ship to be set in the randomly chosen cell and use that for your subsequent cell decisions.

To add on, when the random shell hits a ship, the randomizer should have a bias to picking cells that are adjacent to the one that registered a hit

Furthermore it should prioritise cells that increase the length of lines of hit cells (upto the largest ship length), i.e; one cell behind of or in front of two adjacent hit cells as opposed to randomly selecting an adjacent cell.