No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download


Build Status


What is this?

It is a simple clone of battle city from NES. Video:


How does this work?

The game runs on a server with a game window and listens for two connections: player1 and player2. Each player is a separate client (tank) connected to the game server. The clients control their tanks by sending actions to the server. The game starts when both connections are established and greetings messages are send to both clients. The client's moves are defined once, and do not undergo any changes during the gameplay.

What is the goal?

There are two goals:

  1. SURVIVE in 2 minutes
  2. Get more points than the second player

How to achieve that?

In order to survive and score the biggest amount of points, you need to program the moves of your client with a thorough and clever approach.




  • 1 for each destroyed tiny-brick
  • 5 for each 'freeze' second player
  • 200 for each destroyed NPC tank
  • 100 for each coin

Protocol documentation

Is here.

How to install?

Clone This repo.

code works in Python 3.5, 3.6 and 3.7

remember about virtualenv or pipenv!

python develop

To get OpenGL support (mega boost!) please install pyglet (not required)

pip install pyglet

How to write first bot?

First, copy example code to main dir with game. Example codes are for:

(more examples are here)

remember about virtualenv or pipenv!

For linux/mingw/osx/wsl


./ --cmd-p1 "python"


./ --cmd-p1 "nodejs copied_client.js"


./ --cmd-p1 "ruby copied_client.rb"


oh my god, what a terrible language! You need a json-simple package

javac -cp /usr/share/java/json-simple.jar -d .
./ --cmd-p1 "java -cp /usr/share/java/json-simple.jar:. Game"

The color of your tank will be yellow.

maybe windows?

Omg why?

You have four options:

  1. Install and run bash shell
  2. WSL
  3. Virtualbox
  4. Run three scripts in seperate consoles:
    • python -m battle_city.server
    • python
    • python -m battle_city.examples.random

tmux version - more hackerable (with split screens in terminal)!

./ --cmd-p1 "python"

command would be a runner, example "python" - remember about quotes and command (python, nodejs, ruby or something else) to run your script!!

Another examples:

  • random - show logs and make random actions
  • boilerplate - empty client
  • window - client shows window and draw game from recevied data [OPTIONS...]
    --help                      print this text
    --cmd-p1 CMD_P1             command to run client as player1. Default is "python -m battle_city.examples.python.radom"
    --cmd-p2 CMD_P2             command to run client as player2. Default is "python -m battle_city.examples.python.radom"
    --cmd-p3 CMD_P3             command to run client as player3. Default is "python -m battle_city.examples.python.radom"
    --cmd-p4 CMD_P4             command to run client as player4. Default is "python -m battle_city.examples.python.radom"
    --map MAP                   select map to run game. Default is pilif
    --max-players NUM           number of bots in game. Max is 4. Default is 2
    --ip IP                     IP of server. Default is
    --port PORT                 PORT of server. Default is 8888
    --speed SPEED               tick speed of game. default is 1
    --hidden-window             don't show window with game, run only server
    --turn-off-after-end        turn off server when game is end. Good option for machine learning
    --show-collision-border     show borders with collisions

The script will run the whole game with two clients. There is no need to run anything else. The script includes a command for running server and commands for running two clients. The basic clients are dummy. They will just move randomly. If you want to start implementing your algorithms for moves, create your own client, based on the example example code, and after finishing, use it in script (examples are above).

Server script

python -m battle_city.server [--ip IP] [--port PORT] [--hide-window] [--speed SPEED]

Note that script runs the server as well as both clients by default. If you want to create your own configuration for running the game, use the command above in your own script.

Run tests

pip install -e '.[test]'
pytest tests/


  • Python >=3.5
  • Pygame
  • Pyglet
  • Asyncio
  • JSON
  • Love


  • Firemark - game logic and everything else
  • Socek - idea
  • Stachu - documentation improvment, beta testing
  • Noemi - beta testing
  • Prs - nice tips