A demo game in python using tkinter.
More screenshots here.
- Python 3.+.
- PNG viewing in the GUI: Python Imaging Library (PIL) ImageTk.
Can be installed using command
sudo apt-get install python-imaging-tk
for linux. It is optional. If you don't want the cool image background as shown above, you can skip this.
- Download or import the project.
- Open
main.py
file (if you don't have installed PIL you should openmain_without_image.py
). - Run and enjoy the game.
If someone wants to create own bot and play agains it, it is possible to create and integrate a custom bot. Sees the instruction how to do that, below.
- It must be a class
- It must have a function
say(value: str)
that returns tuple of Integers, coordinates of the field where the bot wants to shoot(x, y)
. There,value
is a string which can be only one of these three values:- "shoot" - means, the player missed, and bot's turn.
- "hit" - means, bot's previous shoot was successful, but didn't destroy the player's ship complataly.
- "destroyed" - means, bot's previous shoot was successful, and destroyed the player's ship complataly.
As an example open
bots.py
file, and see the bot Fati.
- Open
bots.py
file. - Paste implementation of a custom bot class bellow the bot Fati class.
- Open 'main.py` file.
- Go to
class Main
>def __init__(self):
. - Find the line
self.__bot = bots.Fati()
. - Change it to
self.__bot = bots.CustomBot()
(here "CustomBot" is a created bot's name). - Go to
class Main
>def on_game_back_button_pressed(self):
, - Change the line
self.__bot = bots.Fati()
toself.__bot = bots.CustomBot()
(here "CustomBot" the same as within step 5)
If you have any questions, feel free to ask chorobaev.nurbol@gmail.com =)
Copyright (c) 2018 Nurbol Chorobaev