This file is indexed.

/usr/share/games/balder2d/scripts/balderai.py is in balder2d-data 1.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import balder
from balderutil import entity, probe
import math, random
try:
  import psyco
except ImportError:
  # no psyco, so don't use it
  pass
else:
  psyco.full()

controlled_probes = {}

class probe_tracker:
    def __init__(self):
        self.lastfire = 0
        self.pushtimer = 0
        self.fireAtTarget = True
    def incrementFrame(self):
        self.lastfire += 1

def DestroyClosestProbe(probe_id, probe_dict):
    inputs = 0
    # first, lets find out where we are and where we are aiming
    xloc = probe_dict[probe_id]['x']
    yloc = probe_dict[probe_id]['y']
    aiming = probe_dict[probe_id]['rotation_angle']
    # aim for the closest probe
    target = entity.FindClosestProbe(probe_id, probe_dict)
    if not target in probe_dict:
        return balder.INPUT_STICK
    xtarget = probe_dict[target]['x']
    ytarget = probe_dict[target]['y']
    inputs = probe.AimProbeAt(probe_dict[probe_id], xtarget, ytarget)
    if inputs == 0 and balder.IsLineOfSight((xloc,yloc),(xtarget,ytarget)):
        inputs = balder.INPUT_FIRE
    return inputs

def DoProbeControl(probe_id, probe_dict, projectile_list, powerup_list):
    # don't try to do AI for non existant probes
    if not probe_id in probe_dict:
        return 0
    global controlled_probes
    if not probe_id in controlled_probes:
       controlled_probes[probe_id] = probe_tracker()
    closestprobe_id = entity.FindClosestProbe(probe_id, probe_dict)
    thisprobe = controlled_probes[probe_id]
    thisprobe.incrementFrame()
    inputs = 0
    # first, lets find out where we are and where we are aiming
    xloc = probe_dict[probe_id]['x']
    yloc = probe_dict[probe_id]['y']
    aiming = probe_dict[probe_id]['rotation_angle']
    # first look for powerups
    if len(powerup_list) and probe_dict[probe_id]['stuck']:
        thisprobe.fireAtTarget = False
        xtarget, ytarget = entity.FindClosestEntity(xloc, yloc, powerup_list)
        if not balder.IsLineOfSight((xloc,yloc),(xtarget,ytarget)):
            thisprobe.fireAtTarget = True
            inputs = DestroyClosestProbe(probe_id, probe_dict)
        else:
            inputs = probe.AimProbeAt(probe_dict[probe_id],xtarget, ytarget)
    else:
        # aim for the closest probe
        thisprobe.fireAtTarget = True
        inputs = DestroyClosestProbe(probe_id, probe_dict)
    if inputs == balder.INPUT_FIRE:
        if closestprobe_id in probe_dict:
            closestprobe = probe_dict[closestprobe_id]
            distance = entity.DistanceTo(xloc, yloc, closestprobe)
            if (distance/10 - thisprobe.lastfire) < 0 \
            and thisprobe.fireAtTarget:
                thisprobe.lastfire = 0
        else:
            inputs = balder.INPUT_STICK
    if probe_dict[probe_id]['stuck']:
        if not thisprobe.pushtimer == 0:
            inputs = inputs | balder.INPUT_STICK
        thisprobe.pushtimer += 1
        # push off after 20 frames
        if thisprobe.pushtimer == 20:
            thisprobe.pushtimer = 0
    else:
        inputs = inputs | balder.INPUT_STICK
    return inputs