- What is this?
- How does this work?
- What is the goal?
- Protocol Documentation
- How to Install?
- How to write first bot?
- Server script
- Run tests
- Technology
- Contributors
It is a simple clone of battle city from NES. Video: https://www.youtube.com/watch?v=KwnwKErXGrI
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.
There are two goals:
- SURVIVE in 2 minutes
- Get more points than the second player
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.
TODO
- 1 for each destroyed tiny-brick
- 5 for each 'freeze' second player
- 200 for each destroyed NPC tank
- 100 for each coin
Is here.
- General rules of game
- Types in game
- Collision
- General Protocol
- Player actions
- Unit's messages
- Game's messages
Clone This repo.
code works in Python 3.5, 3.6 and 3.7
remember about virtualenv or pipenv!
- https://docs.python.org/3/tutorial/venv.html
- https://pipenv.readthedocs.io/en/latest/
- when you are not-pythonic programmer then I have cheat sheet for you:
- create:
virtualenv -ppython3 venv
- set virtual enviroment:
source venv/bin/active
- create:
python setup.py develop
To get OpenGL support (mega boost!) please install pyglet (not required)
pip install pyglet
First, copy example code to main dir with game. Example codes are for:
(more examples are here)
remember about virtualenv or pipenv!
./run_game.sh --cmd-p1 "python copied_client.py"
./run_game.sh --cmd-p1 "nodejs copied_client.js"
./run_game.sh --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 Game.java -d .
./run_game.sh --cmd-p1 "java -cp /usr/share/java/json-simple.jar:. Game"
The color of your tank will be yellow.
Omg why?
You have four options:
- Install http://www.mingw.org/ and run bash shell
- WSL https://docs.microsoft.com/en-us/windows/wsl/install-win10
- Virtualbox https://www.osboxes.org/ubuntu/
- Run three scripts in seperate consoles:
python -m battle_city.server
python client_a.py
python -m battle_city.examples.random
./run_game_tmux.sh --cmd-p1 "python copied_client.py"
command would be a runner, example "python copied_client.py"
- 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
run_game.sh [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 127.0.0.1
--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 run_game.sh
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 run_game.sh
script (examples are above).
python -m battle_city.server [--ip IP] [--port PORT] [--hide-window] [--speed SPEED]
Note that run_game.sh
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.
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