Game State

The Game State is a complete description of the current condition of the game. In Battlematica, Bots decide through their assigned AI what to do based on the State, that is updated at every tick. The State is a straightforward piece of data: it’s a nested dictionary with the following keys:

  • tick: the current tick (see Time and space)

  • score: the current score

  • bots: a list of the state of each Bot in the game. The state of the bots comprises both static properties (such as max shield, etc.) and their current condition (x, y, current action, target x, target y, current hp, etc.).

  • artifacts: a list of the Artifacts on the field (position, carry condition, which team touched it last, etc.)

  • drop_ports: a list of the Drop Ports on the field

  • bullets: a list of the bullets currently flying. This information is necessary to completely descrive the state of the Game, but is tipically not used inside AIs.

  • d_artifacts, d_bots, d_bullets: helper lists in which the relative object types are put if they disappeared in the last frame (a bot disappears when its HP reaches 0; an artifact disappears when it is dropped in a Drop Port; a bullet disappears when it reaches it target, exploding, or when it travels beyond the firing range of the bot that fired it, losing all it power).

Example:

{'tick': 14,
 'score': {1: 0, 2: 0},
 'artifacts': [{'hg': 1,
                'id': '5484cba4f16c4d278e26d384466b2327',
                'is_carried': False,
                'last_touch': None,
                'r': 45.0,
                'x': 400,
                'y': 600},
               {'hg': 2,
                'id': 'a2fff814dc754f2abc4e07d25b2ec816',
                'is_carried': False,
                'last_touch': None,
                'r': 45.0,
                'x': 400,
                'y': 100},
               {'hg': None,
                'id': 'b699b2c8930049aa9110e1c1dbfb6592',
                'is_carried': False,
                'last_touch': None,
                'r': 45.0,
                'x': 350,
                'y': 350},
               {'hg': None,
                'id': '48d6a4f7dff34c5a9f2e49a242596956',
                'is_carried': False,
                'last_touch': None,
                'r': 45.0,
                'x': 450,
                'y': 350}],
 'bots': [{'bullet_dmg': 70.0,
           'bullet_range': 800.0,
           'bullet_speed': 40.0,
           'bullet_spread': 7.0,
           'ca': 'shoot',
           'crawl_speed': 1.5,
           'dead': False,
           'firing_period': 10.0,
           'graphics': {'body_type': 2,
                        'bullet_blast_type': 1,
                        'bullet_size': 0.7,
                        'bullet_type': 3,
                        'size': 0.55},
           'health': 400.0,
           'hg': 1,
           'id': '4fa83b593169459f83ddaae3af745f61',
           'is_carrying': False,
           'max_health': 400.0,
           'max_shield': 200.0,
           'r': 36.86989764584401,
           'reload_time_pct': 0.5,
           'rotation_speed': 7.0,
           'shield': 200.0,
           'shield_dead_time_pct': 1.0,
           'shield_reload_dead_time': 40.0,
           'shield_reload_speed': 3.0,
           'tx': 578.4000000000002,
           'ty': 483.7999999999999,
           'walk_speed': 3.0,
           'x': 221.60000000000005,
           'y': 216.2000000000001},
          {'bullet_dmg': 60,
           'bullet_range': 800.0,
           'bullet_speed': 40.0,
           'bullet_spread': 7.0,
           'ca': 'shoot',
           'crawl_speed': 1.5,
           'dead': False,
           'firing_period': 2,
           'graphics': {'body_type': 2,
                        'bullet_blast_type': 1,
                        'bullet_size': 0.7,
                        'bullet_type': 3,
                        'size': 0.55},
           'health': 400.0,
           'hg': 2,
           'id': 'dadb4b005dba4aa69e4b5acf9fa19738',
           'is_carrying': False,
           'max_health': 400.0,
           'max_shield': 300.0,
           'r': 216.86989764584402,
           'reload_time_pct': 0.5,
           'rotation_speed': 7.0,
           'shield': 242.0,
           'shield_dead_time_pct': 1.0,
           'shield_reload_dead_time': 40.0,
           'shield_reload_speed': 3.0,
           'tx': 221.60000000000005,
           'ty': 216.2000000000001,
           'walk_speed': 3.0,
           'x': 578.4000000000002,
           'y': 483.7999999999999}],
 'bullets': [{'blast_sprite': 1,
              'dmg': 60,
              'hg': 2,
              'id': '81b484c3a2d44d71aff273ef02707213',
              'out_of_range': False,
              'r': -142.89476711106883,
              'range': 800.0,
              'size': 0.7,
              'speed': 40.0,
              'spread': 7.0,
              'sprite': 3,
              'target_reached': False,
              'tx': 216.891628871915,
              'ty': 210.34146063646952,
              'x': 514.5976932940079,
              'y': 435.53753364161247},
             {'blast_sprite': 1,
              'dmg': 60,
              'hg': 2,
              'id': 'cdd72fbc65eb481bb8832310521824a3',
              'out_of_range': False,
              'r': -143.6514648199243,
              'range': 800.0,
              'size': 0.7,
              'speed': 40.0,
              'spread': 7.0,
              'sprite': 3,
              'target_reached': False,
              'tx': 220.15101895653893,
              'ty': 220.17244500154527,
              'x': 578.4000000000002,
              'y': 483.7999999999999}],
 'drop_ports': [{'hg': None,
                 'id': 'b4ebe8677d7446659f82a74fbeffbfec',
                 'r': 0.0,
                 'x': 400,
                 'y': 350}],
 'd_artifacts': [],
 'd_bots': [],
 'd_bullets': []
 }