/Battleship

Battleship using Scala

Primary LanguageScala

Battleship - A simple battleship game in Scala 🚢

Battleship

I developed this game during my 5th year at Polytech Montpellier, in CS & Management. Built with Scala (v2.12.6), SBT and uses ScalaTest and TypeSafe Config. I tried as much as possible to maintain a RT-friendly code, with pure functions in order to test it easily.

⚠️ The user interface is graphically optimised for Linux (usage of console colors, tested), it should be ok for MacOS (need to be tested) but it doesn't work on Windows.

How to use it?

With SBT

Open a terminal, cd to the project folder and then run the sbt run command. You wil be asked to chose between 2 main classes: BattleShipGame and TestAI (see below, "Main classes" section).

.jar file

You can also generate the .jar file and specify in the MANIFEST.MF file which main class you want to use.

Config file

You can specify the number of games to play when you are testing AIs in the application.conf file (default: 100).

Main classes

BattleShipGame 👨 ⚔️ 👩 👨 ⚔️ 🤖

Player a game versus a friend or an AI (low, medium and hard).

TestAI ☑️

Launch multiple games (default: 100) between the 3 AI and get the final result printed or written in a CSV file. For example, I got the following results with 20 000 games played between each AI (low VS medium, low VS hard, medium VS hard):

AI Name Score AI Name2 Score2
AI Level Beginner 5 AI Level Medium 19995
AI Level Beginner 0 AI Level Hard 20000
AI Level Medium 274 AI Level Hard 19726

Author

Clément ROIG