I have already released Salvo on the rift and am now rebuilding it for the Go. I released Salvo Rift edition my first ever game nearly two years ago and have learnt a lot since. I also wanted some more experience building for the Go. Particularly working within the technical limitations, as such this required a complete rebuild with some sharing of assets. So far I'm getting a good frame rate between 60fps and 72fps
I have just completed building the AI for the computer and thought I would share some test results
I wanted to make sure that easy, medium and hard difficulty settings were different enough as to provide a good experience for all player levels.
It was also extremely important to me that the computer never understands any more than a human player can work out i.e NOT CHEATING
The variables Salvo AI can understand
Largest and smallest ships remaining
Number of ships remaining
If a ship has been sunk
If a location has been Hit, Missed or not yet targeted
Using those variables it can establish if it needs to be in one of two modes, with different difficulty levels
Target mode - It knows that a ship has been hit but it hasn't sunk it yet. Hunt mode - It hasn't hit a ship so needs to fire until it finds another ship before entering target mode
Results for 1000 games Easy Quickest game: 30 moves Slowest game: 100 moves Average game: 62 moves
Medium Quickest game: 26 moves Slowest game: 92 moves Average game: 55 moves
Hard Quickest game: 24 moves Slowest game: 70 moves Average game: 45 moves
Thanks for watching Mike
Extra info for those interested - Below is a bit more info and each mode and difficulty setting - and some findings I found battleships AI far more in depth than I thought it would be, getting the individual levels to play correctly without appearing too stupid or too clever while not using the easy option of cheating was a fun exercise.
Within each of the modes, hunt and target the AI makes slightly better choices
Target mode Easy mode targets the adjacent squares to any hit squares where it hasn't been notified it has sunk a ship providing those squares have not been targeted yet Medium mode will calculate if the smallest ship remaining can fit in the spaces both vertically and horizontally, if it can't it doesn't try to target that space Hard mode calculates medium mode and then will try to establish the direction of a ship based on how many hits have been performed vertically or horizontally
Hunt mode Easy mode randomly targets all available targets on the board Medium mode: calculates the probability of a ship being in each square based on the remaining ships then takes a percentage of the higher probability squares Hard mode: does the same probability check from medium mode but will only select a random target out of the targets with the same highest probability
Some interesting outcomes Some interesting things arose from this type of probability check
At the start of a game the center squares are always the highest probability to contain part of ship, just leaving the computer like that doesn't make it feel like a human player, it always follows the same pattern until it hits something, knowing this would mean a human could place their ships around the edges and the computer wouldn't find them for quite a few moves giving you an early game advantage against hard mode, although this advantage quickly evaporates as the AI gets more information to work with. I solved this by at the start of each game each mode will randomly select targets to fire upon unless it hits at which point it enters target mode. This makes the following probability calculations completely random and more human feeling.
Parity arose. While testing in hard mode I started to see the AI following some form of parity (I'm not a mathematician so don't kill me here) but simply put, for battleships anyway, the smallest ship is a 2 so the most efficient way of hunting for ships is to not fire on touching target squares by targeting odd or even squares and sticking to that pattern. The obvious exception being when you hit a ship it's most efficient to hit the spaces next to the ships and then return to your parity targeting. I found this interesting because I had considered evolving the AI to understand parity and target either odd or even squares and then it naturally arose from the probability calculations anyway so happy days.
Potential improvements The only way I can see from here is to try minimize the gap between quickest and slowest games, but this would require something like if you have taken X moves then be a little bit more stupid or a bit smarter depending on the number of moves taken, but this feels to me like it would give an unnatural feeling the the progress of the game. The current process allows for luck to play a part, if the computer totally by luck manages to hit a ship in the first few shots then it should have a higher chance of winning than if it didn't.
I realise this level of detail won't be for everyone but I had a lot of fun building the system to be the best battleships player I could.
Pretty much completed building all the features, optimising and testing. Everything is working well and running at a pretty steady 72fps
Features Single player - Multiple difficulties - Easy - Regular - Hard Leader boards for each difficulty Multiplayer - Play against other people on the Oculus Go. Android Companion app - Play against friends, one in the headset the other on their mobile phone.
Now started work on the art work for the game. What do you think?