Battleships Python Demo Client Quick Start Guide

Setting Up Python

Python

First, if you haven't already, you need to install python on your machine. Head over to https://www.python.org/downloads/ and download the latest version of Python 3 for your OS (as of writing, it's Python 3.6.3).

Pip

This should come with the latest version of python 3 in the link above but if not check out https://packaging.python.org/tutorials/installing-packages/ for instructions on how install pip. If you downloaded the latest version of python 3 using the link from the previous paragraph, you should already be good to go.

Packages

Now we have installed pip we can install the additional packages we require:

For windows terminal: pip install package-name
For macOS and Linux terminal: pip3 install package-name

Running The Client

This bit is really easy! Download the client from here, unzip the folder and then just pass the battleships_layout.py file to the python interpreter!

For windows terminal:

python path-to-battleships_layout.py

For macOS and Linux terminal:

python3 path-to-battleships_layout.py

Adding Logic

Coming up with the logic might not be easy, but adding it to your bot sure is! The only file you need to change is battleships_move.py. In there you should see the calculateMove() method. This is called by the client every time the server wants you to make a move. Start adding your own code here! We provide you with a random guessing bot to get you started. See our Quick Reference Guide for more details.

(Recommended) Setting up Your Development Environment

Now we have everything in place, all that is left is to set up our development environment. This really comes down to personal preference, some like to do all their coding in a lightweight text editor, and others like to use a fully featured IDE. A great IDE (that is also completely free) is PyCharm from JetBrains. Head over to https://www.jetbrains.com/pycharm and download the Commuunity Edition of PyCharm which is the free version. The IDE is fairly easy to use, but be sure to check out https://www.jetbrains.com/help/pycharm/quick-start-guide.html for some introductory material to get you started.

Final Remarks

Hopefully now you're in place to get picking through the demo code. This should help you figure out how the API works, and ultimately starting work on your army of intelligent bots! We look forward to seeing what you build!

iconBattleshipsBlack.png
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License