Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A strategy game for Python bots with replaceable front ends

Project Description

[![Alt text](](


A simple strategy game played by Python bots.

The project is still in development, but if you checkout everything and follow this README it is supposed to work just fine.

Pull requests are welcomed, expecially if you want to submit your own bot. Bear in mind the the BaseBot API is not final yet and it might change quite often.

Game rules

Each player controls a set amount of cells in a grid. The behaviour of these cells is defined by a Bot that implements a specific interface; each cell of the player is represented by an instance of the Bot class.

The game ends when only one player has still cells alive in the grid.
A cell is killed if in the 9-cells subgrid centered on itself the number of the cells belonging to enemy players is more then the cells belonging to the owner of the cell.

Have a look at if you want to change some of the game basic settings.


Javascript Frontend:


System dependencies: python2.7 or python3.4

* ```git clone```
* ```pip install -e .```

**NOTE**: You should be able to install strategypy directly from pypi via ```pip install strategypy```, but it's not fully supported.


To run an example game (output is json):
* ```./```

To run a game with simple console-based front-end:
* ```./```

To run a game with a PyGame front-end (Requires and its dependencies):
* ```./```

To run a game with a Javascript front-end on Firefox (Requires, its dependencies and Firefox to be installed):
* ```./```

To run a game with a console front-end (Requires
* ```./```

General usage

* ```strategypy <name_of_bot_one> <<name_of_bot_two> ...```

The result of the script is a JSON file that contains all the information necessary for any front-end to play it.

The name of the bot must be a name of a python module in /bots/. It currently supports a URL of a web service that returns moves, but that is very experimental.

This JSON result can be saved on a file so that it can be loaded later by a FE:
* ```strategypy killer prey prey > example.json```

or it can be piped it directly into a FE, for example:
* ```strategypy killer prey prey | python strategypy/```

See for a PyGame FE.
See for a Javascript FE.
See for a Console FE.


To run all the tests:
* ```pip install tox```
* ```tox```


The current way to build a bot is to create a python file (e.g. in the bots directory. The python file must have a function called action.

The function "action" takes one argument, the context of the game and returns one of the five possible moves: 'move up', 'move left', 'move right', 'move down', None.

def action(ctx):
return 'move down'

Then you can play a game by running:
```strategypy mybot <<name_of_bot_two> ...```

The context given to the action function represents the state of the game when action is required for one of your units. It is a dictionary with the following keys:

(int) player_pk
(int) pk
(bool) respawn
(int, int) grid_size
(int, int) position
(list) has_killed
(list) was_killed_by
(dict) current_data

TODO / Improvements

* Better API for Bots
* Security in local mode
* Anti-cheating in local mode
* Numpy / Performance improvements
* Performance tracking/acceptance on build
* Rework game rules and engine to make it more interesting
* More and better unit tests

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(16.4 kB) Copy SHA256 Hash SHA256
Source None Mar 19, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate