pyagar¶
pyagar
is a python client for the popular online game at http://agar.io.
Warning
This software is not the official client and is not associated in any manner with the original website.
This package allows you to play the game, see the gameplay as an spectator, record and replay games and also develop your own bot.
Please, checkout the documentation for further instructions.
Enjoy!
User documentation¶
Installation¶
Dependencies¶
You’ll need some software in order to run pyagar
.
- Python >= 3.4
- libsdl2
- libsdl2-gfx
- libsdl2-ttf
Command Line Interface¶
usage: pyagar [-h] [--disable-hw] [-n NICK] [-d] [-r REGION] [-s SAVE] [--version] [--create-party | --join-party JOIN_PARTY] {list-regions,play,spectate,bot,replay} ...
- Options:
--disable-hw=False disable hardware acceleration -n=pyagar, --nick=pyagar player cell’s nickname -d, --debug enable debug mode; use multiple times to increase the debug level -r=EU-London, --region=EU-London the region you want to connect to -s, --save save the gameplay in a file; you can replay it later using the ``replay`` command --version show program’s version number and exit --create-party=False create a new party and print the shared token --join-party join an already created party - Sub-commands:
- list-regions
print a table with the list of available regions
usage: pyagar list-regions [-h]
- play
start a new game
usage: pyagar play [-h]
- spectate
connect to the server in spectator mode
usage: pyagar spectate [-h]
- bot
like ``play`` mode but the cell is controlled by a ``Controller`` class
usage: pyagar bot [-h] (--list-types | --type TYPE | --from-file FROM_FILE)
- Options:
--list-types=False print a table with the available ``Controllers`` --type type of controller to use --from-file use a controller from a python file
- replay
play back a recorded gameplay
usage: pyagar replay [-h] gameplay_file
- Positional arguments:
gameplay_file full path to the record file
Controls¶
Action | Peripheral | Detail |
---|---|---|
Eject | Keyboard | W |
Exit | Keyboard | ESC |
Fullscreen | Keyboard | F |
Move | Mouse | |
Split | Keyboard | Space |
Start | Mouse | Left |
Zoom | Mouse | Wheel |
Developer documentation¶
pyagar.client
¶
This module contains the Client class.
pyagar.cmdline
¶
Provides the cmdline facility.
pyagar.controller
¶
Some very simple bots.
-
class
pyagar.control.
Controller
(client)[source]¶ All bots should inherit from this class.
-
edible
¶ You can eat cells 10% smaller than you.
-
opponents
¶ Return list of other cells.
-
player
¶ Returns the player main cell. None if not exists.
-
predators
¶ Cells that can eat me.
-
viruses
¶ Returns a list of visible viruses.
-
-
class
pyagar.control.
EatWhenNoPredators
(client)[source]¶ Only eats when all visible cells are smaller then itself.
pyagar.log
Contains the logger.
pyagar.messages
¶
Protocol implementation.
-
class
pyagar.messages.
BaseMSG
(buf, offset=0)[source]¶ All messages inherits from this class.
Contains utility methods for unpack the data.
-
class
pyagar.messages.
Camera
(x, y, zoom)¶ -
x
¶ Alias for field number 0
-
y
¶ Alias for field number 1
-
zoom
¶ Alias for field number 2
-
-
class
pyagar.messages.
CameraPosition
(buf, offset=0)[source]¶ Change in the camera position and/or the zoom.
Only received in
Spectate
mode.
-
class
pyagar.messages.
Cell
(id, x, y, size, color, is_virus, name)¶ -
color
¶ Alias for field number 4
-
id
¶ Alias for field number 0
-
is_virus
¶ Alias for field number 5
-
name
¶ Alias for field number 6
-
size
¶ Alias for field number 3
-
x
¶ Alias for field number 1
-
y
¶ Alias for field number 2
-
-
class
pyagar.messages.
Eat
(eater, eatee)¶ -
eatee
¶ Alias for field number 1
-
eater
¶ Alias for field number 0
-
-
class
pyagar.messages.
Leaderboard
(buf, offset=0)[source]¶ The
Leaderboard
.The top bigger cells in descending order.
This message is only received in
FFA
andExperimental
mode.
-
class
pyagar.messages.
MSG
(buf, offset=0)[source]¶ All messages.
This class identify the specific message type and calls the proper parser.
-
class
pyagar.messages.
MSGType
[source]¶ This enum contains the identifier of each message along with the name of the class which parses it.
-
cls
¶ Returns the parser class of this enum.
-
-
class
pyagar.messages.
ResetSomething
(buf, offset=0)[source]¶ This message is present in the code but never seen.
-
class
pyagar.messages.
Screen
(x1, y1, x2, y2)¶ -
x1
¶ Alias for field number 0
-
x2
¶ Alias for field number 2
-
y1
¶ Alias for field number 1
-
y2
¶ Alias for field number 3
-
-
class
pyagar.messages.
ScreenAndCamera
(buf, offset=0)[source]¶ Screen and Camera position, all in one.
This message is the first message in the stream.
-
class
pyagar.messages.
SetQARA
(buf, offset=0)[source]¶ This message is present in the code but never seen.
pyagar.utils
¶
Non categorized stuff.
-
class
pyagar.utils.
GameplaySaver
(filename)[source]¶ Store the gameplay messages in a file with a timestamp.
pyagar.visual
¶
Provides the default visualizer.
-
class
pyagar.visual.
Visualizer
(client, view_only=False, hardware=True)[source]¶ SDL based visualizer.
-
refresh
()[source]¶ Draw the current status of the game in
window
.The overall process is:
- The server send information about the board size and status.
1.1. We keep the information about the board in
gamescreen
.- We draw the game in the texture
stage
. This texture can be smaller thangamescreen
. - The rectangle
camera
(in game coordinates) is copied fromstage
towindow
.
-
stage
= None¶ The texture we draw to.
-
window
= None¶ The window where we show the game.
-
0.0.8¶
- Party mode implementation (creation and joining).
- Better mouse control.
- Game recording and replaying.
- Documentation.
- Leaderboard.
- Windows installer.
0.0.3¶
- Documenting pyagar module.