thegame API¶
For installation instructions, please follow: https://github.com/afg984/thegame
Client¶
-
class
thegame.
HeadlessClient
¶ -
init
()¶ This method is called when the client is constructed
If you want to initialize the client, put the code here.
To set the name of your hero, set it here like:
self.name = 'yo'
-
action
(hero, heroes, polygons, bullets)¶ Implement this method to decide what to do in a turn, given the environment. The arguments are passed as keyword arguments.
Parameters: - hero – your hero
- heroes (list) – list of heroes within the field of view, does not include yourself
- polygons (list) – list of polygons within the field of view
- bullets (list) – list of bullets within the field of view, including those shot from your hero
-
accelerate
(direction)¶ Accelerates to the direction (in radians) in the current turn.
In a turn, only the last call to
accelerate*
counts. Repeated calls overwrite previous ones.Parameters: direction (float) – The direction to accelerate to, in radians
-
accelerate_towards
(x, y)¶ Accelerates towards the point (x, y) in the current turn.
In a turn, only the last call to
accelerate*
counts. Repeated calls overwrite previous ones.Parameters: - x (float) – the absolute x axis
- y (float) – the absolute y axis
-
shoot
(direction, *, rotate_only=False)¶ Shoot a bullet in the current turn, aiming at the direction (in radians). If bullet is reloading, then nothing will happen.
In a turn, only the last call to
shoot*
counts. Repeated calls overwrite previous ones.Parameters: direction (float) – the direction to shoot to, in radians
-
shoot_at
(x, y, *, rotate_only=False)¶ Shoots a bullet in the current turn, aiming at the point (x, y). If bullet is reloading, then nothing will happen.
In a turn, only the last call to
shoot*
counts. Repeated calls overwrite previous ones.Parameters: - x (float) – the absolute x axis
- y (float) – the absolute y axis
-
level_up
(ability)¶ Level up the ability in the current turn. If there is no skill point available, nothing will happen. Repeated calls to this function in a turn will make the ability being leveled up multiple times.
Parameters: ability (thegame.Ability) – the ability to level up
-
classmethod
main
()¶ parse command line arguments and run the client
-
Polygon¶
-
class
thegame.
Polygon
(data)¶ The netural polygons.
-
edges
¶ How many edges does the polygon have
-
body_damage
¶ The body damage of the entity.
When two entities collide, they reduce each other’s health with their body damage.
-
health
¶ The health of the entity in a non-negative integer.
When a entity’s health is less than or equal to zero it dies. And the one dealing the killing blow is rewarded with
rewarding_experience
.
-
id
¶ The id of the entity
-
max_health
¶ The maximum health of this entity.
-
position
¶ The position of the entity in a 2-tuple (x, y).
-
radius
¶ The radius of the entity
-
rewarding_experience
¶ How much experience you will get if you kill this entity.
-
velocity
¶ The velocity of the entity in a 2-tuple (x, y).
-
Bullet¶
-
class
thegame.
Bullet
(data)¶ The bullet. Shot from a Hero.
-
owner_id
¶ The id of the hero owning the bullet
-
body_damage
¶ The body damage of the entity.
When two entities collide, they reduce each other’s health with their body damage.
-
health
¶ The health of the entity in a non-negative integer.
When a entity’s health is less than or equal to zero it dies. And the one dealing the killing blow is rewarded with
rewarding_experience
.
-
id
¶ The id of the entity
-
max_health
¶ The maximum health of this entity.
-
position
¶ The position of the entity in a 2-tuple (x, y).
-
radius
¶ The radius of the entity
-
rewarding_experience
¶ How much experience you will get if you kill this entity.
-
velocity
¶ The velocity of the entity in a 2-tuple (x, y).
-
Abilities¶
Hero¶
-
class
thegame.
Hero
(data)¶ A Hero is a player in thegame.
-
abilities
¶ returns a tuple of abilities.
Example:
hero.abilities[MaxHealth].value # get the hero's max health hero.abilities.max_health.value # the same thing hero.abilities[MaxHealth].level # get the ability level hero.abilities.max_health.level # the same thing again
-
orientation
¶ The orientation of the hero; the direction the barrel is facing at, in radians.
-
level
¶ The level of the hero
-
score
¶ The score of the hero
-
experience
¶ The experience the hero has
-
experience_to_level_up
¶ The experience required for the hero to level up
-
skill_points
¶ Number of skill points available to level up abilities
-
cooldown
¶ How many ticks until a bullet is ready. Increase the reload ability to reduce the cooldown.
shoot
andshoot_at
can still be called when on cooldown, but nothing will happen instead.
-
health_regen_cooldown
¶ How many ticks until the hero can start to regenerate health
-
name
¶ The name of the hero. Not guranteed to be unique
-
body_damage
¶ shortcut to
hero.abilities.body_damage.value
-
body_damage_level
¶ shortcut to
hero.abilities.body_damage.level
-
bullet_damage
¶ shortcut to
hero.abilities.bullet_damage.value
-
bullet_damage_level
¶ shortcut to
hero.abilities.bullet_damage.level
-
bullet_penetration
¶ shortcut to
hero.abilities.bullet_penetration.value
-
bullet_penetration_level
¶ shortcut to
hero.abilities.bullet_penetration.level
-
bullet_speed
¶ shortcut to
hero.abilities.bullet_speed.value
-
bullet_speed_level
¶ shortcut to
hero.abilities.bullet_speed.level
-
health
¶ The health of the entity in a non-negative integer.
When a entity’s health is less than or equal to zero it dies. And the one dealing the killing blow is rewarded with
rewarding_experience
.
-
health_regen
¶ shortcut to
hero.abilities.health_regen.value
-
health_regen_level
¶ shortcut to
hero.abilities.health_regen.level
-
id
¶ The id of the entity
-
max_health
¶ shortcut to
hero.abilities.max_health.value
-
max_health_level
¶ shortcut to
hero.abilities.max_health.level
-
movement_speed
¶ shortcut to
hero.abilities.movement_speed.value
-
movement_speed_level
¶ shortcut to
hero.abilities.movement_speed.level
-
position
¶ The position of the entity in a 2-tuple (x, y).
-
radius
¶ The radius of the entity
-
reload
¶ shortcut to
hero.abilities.reload.value
-
reload_level
¶ shortcut to
hero.abilities.reload.level
-
rewarding_experience
¶ How much experience you will get if you kill this entity.
-
velocity
¶ The velocity of the entity in a 2-tuple (x, y).
-