Ejemplo n.º 1
0
def GatherInfo(s):
    """Gather necessary info"""

    min_speed = 1400 if s.pB > 30 else 999
    min_speed = ((2300 - s.pvd) + dist3d(s.pV, s.bV)) * abs(s.ba) * 2 + 100

    # Opponent info

    iState = PhysicsLib.intercept2(s.bL, s.bV, s.baV, s.oL, s.oV, s.obd / min_speed, 30, g=s.G)

    s.otL = a3(iState.Ball.Location)
    s.otV = a3(iState.Ball.Velocity)
    s.ofL = a3(iState.Car.Location)
    s.odT = iState.dt

    s.ofd = dist3d(s.otL, s.ofL)
    s.odT += s.ofd / (dist3d(s.oV) * 0.5 + 0.5 * 2300)
    s.otL[1] = Range(s.otL[1], abs(s.ogoal[1]))

    s.ooglinex = line_intersect(([0, s.ogoal[1]], [1, s.ogoal[1]]), (s.ofL * .5 + .5 * s.oL, s.otL))[0]

    # s.obd = dist3d(s.oL, s.bL)
    s.obfd = dist3d(s.ofL, s.otL)

    # player info

    s.prd = turning_radius(s.pvd)

    iState = PhysicsLib.intercept2(s.bL, s.bV, s.baV, s.pL, s.pV, s.bd / min_speed, 60, g=s.G)

    s.ptL = a3(iState.Ball.Location)
    s.ptV = a3(iState.Ball.Velocity)
    s.ptaV = a3(iState.Ball.AngularVelocity)
    s.pfL = a3(iState.Car.Location)
    s.pfV = a3(iState.Car.Velocity)
    s.pdT = iState.dt

    s.pfd = dist3d(s.pfL, s.ptL)
    s.pdT += s.pfd / (s.pvd * 0.5 + 0.5 * 2300)
    s.otL[1] = Range(s.ptL[1], abs(s.ogoal[1]))

    s.glinex = line_intersect(([0, s.goal[1]], [1, s.goal[1]]), (s.pL, s.ptL))[0]

    s.oglinex = line_intersect(([0, s.ogoal[1]], [1, s.ogoal[1]]), (s.pL, s.ptL))[0]

    s.obglinex = line_intersect(([0, s.ogoal[1]], [1, s.ogoal[1]]),
                                ([s.bL[0], s.bL[1]], [s.bL[0] + s.bV[0], s.bL[1] + s.bV[1]]))[0]

    # goal location related

    s.gaimdx = abs(s.goal[0] - s.glinex)

    s.gtL = s.ptL - s.goal
    s.gpL = s.pL - s.goal

    s.gtd, s.gta, s.gti = spherical(*s.gtL, 0)
    s.gpd, s.gpa, s.gpi = spherical(*s.gpL, 0)

    s.gtd = dist3d(s.goal, s.ptL)
    s.gpd = dist3d(s.goal, s.pL)
    s.ogtd = dist3d(s.ogoal, s.ptL)
    s.ogpd = dist3d(s.ogoal, s.pL)

    s.o_gtd = dist3d(s.ogoal, s.otL)
    s.o_gpd = dist3d(s.ogoal, s.oL)
    s.o_ogtd = dist3d(s.goal, s.otL)
    s.o_ogpd = dist3d(s.goal, s.oL)

    # TODO: shot angle possible

    # game state info

    s.aerialing = not s.poG and (s.airtime > .2 and s.pL[2] + s.pV[2] / 2 > 150 or s.jumper)
    s.behind = s.gpd < s.gtd or s.ogpd > s.ogtd
    s.offense = s.gpd > s.gtd or dist3d(s.ptL, s.goal) < 3500
    s.infront = s.ptL[1] * s.color + 90 > s.pL[1] * s.color

    s.obehind = s.o_gpd < s.o_gtd or s.o_ogpd > s.o_ogtd

    s.kickoff = not s.bH and dist3d(s.bL) < 99
Ejemplo n.º 2
0
def GatherInfo(s):
    """Gather necessary info"""

    min_speed = 1400 if s.pB > 30 else 999
    min_speed = ((2300 - s.pvd) + dist3d(s.pV, s.bV)) * abs(s.ba) * 2 + 100

    # Opponent info

    s.obd = dist3d(s.oL, s.bL)

    iState = PhysicsLib.intercept2(s.bL, s.bV, s.baV, s.oL, s.oV,
                                   s.obd / min_speed, 30)

    s.otL = a3(iState.Ball.Location)
    s.otV = a3(iState.Ball.Velocity)
    s.ofL = a3(iState.Car.Location)
    s.odT = iState.dt

    s.ofd = dist3d(s.otL, s.ofL)

    s.ooglinex = line_intersect(
        ([0, -Ph.wy * s.color], [1, -Ph.wy * s.color]),
        (s.ofL * .8 + .2 * s.oL, s.otL * .8 + .2 * s.bL))[0]

    # s.ooglinez = line_intersect(([0, -Ph.wy * s.color], [1, -Ph.wy * s.color]),
    #                             ([s.ofL[2], s.ofL[1]], [s.otL[2], s.otL[1]]))[0]

    # s.obd = dist3d(s.oL, s.bL)
    s.obfd = dist3d(s.ofL, s.otL)

    # player info

    s.prd = turning_radius(s.pvd)

    iState = PhysicsLib.intercept2(s.bL, s.bV, s.baV, s.pL, s.pV,
                                   s.bd / min_speed, 60)

    s.ptL = a3(iState.Ball.Location)
    s.ptV = a3(iState.Ball.Velocity)
    s.ptaV = a3(iState.Ball.AngularVelocity)
    s.pfL = a3(iState.Car.Location)
    s.pfV = a3(iState.Car.Velocity)
    s.pdT = iState.dt

    s.glinex = line_intersect(
        ([0, Ph.wy * s.color], [1, Ph.wy * s.color]),
        (s.pfL * .5 + .5 * s.pL, s.ptL * .8 + .2 * s.bL))[0]

    # s.glinez = line_intersect(([0, Ph.wy * s.color], [1, Ph.wy * s.color]),
    #                           ([s.pL[2], s.pL[1]], [s.ptL[2], s.ptL[1]]))[0]

    s.oglinex = line_intersect(
        ([0, -Ph.wy * s.color], [1, -Ph.wy * s.color]),
        (s.pfL * .8 + .2 * s.pL, s.ptL * .8 + .2 * s.bL))[0]

    # s.oglinez = line_intersect(([0, -Ph.wy * s.color], [1, -Ph.wy * s.color]),
    #                            ([s.pfL[2], s.pL[1]], [s.pftL[2], s.ptL[1]]))[0]

    s.bfd = dist3d(s.pfL, s.ptL)

    # goal location related

    s.goal = a3([
        -Range(s.glinex, 600) / 2,
        max(Ph.wy,
            abs(s.ptL[1]) + 1) * s.color, 300
    ])

    s.ogoal = a3([
        Range(s.ooglinex * .8, 900), -max(Ph.wy,
                                          abs(s.ptL[1]) + 1) * s.color, 300
    ])

    s.gaimdx = abs(s.goal[0] - s.glinex)
    # s.gaimdz = abs(s.goal[2] - s.glinez)

    # s.gx, s.gy, s.gz = local(s.goal, s.pL, s.pR)
    # s.gd, s.ga, s.gi = spherical(s.gx, s.gy, s.gz)

    # s.ogx, s.ogy, s.ogz = local(s.ogoal, s.pL, s.pR)
    # s.ogd, s.oga, s.ogi = spherical(s.ogx, s.ogy, s.ogz)

    s.gtL = s.ptL - s.goal
    s.gpL = s.pL - s.goal

    s.gtd, s.gta, s.gti = spherical(*s.gtL, 0)
    s.gpd, s.gpa, s.gpi = spherical(*s.gpL, 0)

    s.gtd = dist3d(s.goal, s.ptL)
    s.gpd = dist3d(s.goal, s.pL)
    s.ogtd = dist3d(s.ogoal, s.ptL)
    s.ogpd = dist3d(s.ogoal, s.pL)

    # near_post = (gx / 2 * sign(s.bL[0]), s.goal[1])
    # tangent = tangent_point(near_post, R, s.bL, s.color * sign(s.bL[0]))

    # s.x_point = line_intersect([(1, near_post[1]), (-1, near_post[1])], [s.bL, tangent])[0]

    # States

    s.aerialing = not s.poG and s.pL[2] > 150 and s.airtime > .25
    s.kickoff = not s.bH and dist3d(s.bL) < 99
    s.behind = s.gpd < s.gtd or s.ogpd > s.ogtd
    s.offense = s.ogtd + 70 > s.ogpd

    # Other
    s.tLb = set_dist(s.ptL, s.goal, -92)
Ejemplo n.º 3
0
def GatherInfo(s):
    """Gather necessary info"""

    min_speed = 800

    # player info

    s.prd = turning_radius(s.pvd)

    iState = PhysicsLib.intercept2(s.bL, s.bV, s.baV, s.pL, s.pV,
                                   s.bd / min_speed, 60)

    s.ptL = a3(iState.Ball.Location)
    s.ptV = a3(iState.Ball.Velocity)
    s.ptaV = a3(iState.Ball.AngularVelocity)
    s.pfL = a3(iState.Car.Location)
    s.pfV = a3(iState.Car.Velocity)
    s.pdT = iState.dt

    s.bfd = dist3d(s.pfL, s.ptL)

    s.glinex = line_intersect(([0, Ph.wy * s.color], [1, Ph.wy * s.color]),
                              ([s.pL[0], s.pL[1]], [s.ptL[0], s.ptL[1]]))[0]

    s.glinez = line_intersect(([0, Ph.wy * s.color], [1, Ph.wy * s.color]),
                              ([s.pL[2], s.pL[1]], [s.ptL[2], s.ptL[1]]))[0]

    s.oglinex = line_intersect(([0, -Ph.wy * s.color], [1, -Ph.wy * s.color]),
                               ([s.pL[0], s.pL[1]], [s.ptL[0], s.ptL[1]]))[0]

    # s.oglinez = line_intersect(([0, -Ph.wy * s.color], [1, -Ph.wy * s.color]),
    #                            ([s.pL[2], s.pL[1]], [s.ptL[2], s.ptL[1]]))[0]

    # Opponent info

    s.obd = dist3d(s.oL, s.bL)

    iState = PhysicsLib.intercept2(s.bL, s.bV, s.baV, s.oL, s.oV,
                                   s.obd / min_speed, 30)

    s.otL = a3(iState.Ball.Location)
    s.otV = a3(iState.Ball.Velocity)
    s.ofL = a3(iState.Car.Location)
    s.odT = iState.dt

    s.ofd = dist3d(s.otL, s.ofL)

    # s.obd = dist3d(s.oL, s.bL)
    s.obfd = dist3d(s.ofL, s.otL)

    s.ooglinex = line_intersect(([0, -Ph.wy * s.color], [1, -Ph.wy * s.color]),
                                ([s.oL[0], s.oL[1]], [s.otL[0], s.otL[1]]))[0]

    s.ooglinez = line_intersect(([0, -Ph.wy * s.color], [1, -Ph.wy * s.color]),
                                ([s.oL[2], s.oL[1]], [s.otL[2], s.otL[1]]))[0]

    # other

    s.goal = a3([
        -Range(s.glinex, 600) / 2,
        max(Ph.wy,
            abs(s.ptL[1]) + 1) * s.color, 300
    ])

    s.ogoal = a3([
        Range(s.ooglinex * .8, 900), -max(Ph.wy,
                                          abs(s.ptL[1]) + 1) * s.color, 300
    ])

    s.gaimdx = abs(s.goal[0] - s.glinex)
    s.gaimdz = abs(s.goal[2] - s.glinez)

    s.gx, s.gy, s.gz = local(s.goal, s.pL, s.pR)
    s.gd, s.ga, s.gi = spherical(s.gx, s.gy, s.gz)

    s.ogx, s.ogy, s.ogz = local(s.ogoal, s.pL, s.pR)
    s.ogd, s.oga, s.ogi = spherical(s.ogx, s.ogy, s.ogz)

    s.gtL = s.ptL - s.goal
    s.gpL = s.pL - s.goal

    s.gtd, s.gta, s.gti = spherical(*s.gtL, 0)
    s.gpd, s.gpa, s.gpi = spherical(*s.gpL, 0)

    s.gtd = dist3d(s.goal, s.ptL)
    s.gpd = dist3d(s.goal, s.pL)
    s.ogtd = dist3d(s.ogoal, s.ptL)
    s.ogpd = dist3d(s.ogoal, s.pL)

    # States

    s.aerialing = not s.poG and s.pL[2] > 150 and s.airtime > .25
    s.kickoff = not s.bH and dist3d(s.bL) < 99
    s.offense = s.ogtd + 70 > s.ogpd
    s.behind = s.gpd < s.gtd or s.ogpd > s.ogtd