Пример #1
0
def test_solve_boost_min_dmg_neg_viz():
    K = motion.strafe_K(30, 0.001, 320, 100)
    dv = motion.solve_boost_min_dmg([0, -600], K, 300, -200, 800)
    assert dv[0] == approx(51.986602324707007)
    assert dv[1] == approx(511.7601499627252)
    tx = motion.strafe_time(300, dv[0], K)
    tz = motion.gravity_time_speediz_z(-600 + dv[1], -200, 800)
    assert tx == approx(tz[1])

    K = motion.strafe_K(30, 0.001, 320, 10)
    dv = motion.solve_boost_min_dmg([0, -600], K, 1000, 500, 800)
    assert dv[0] == approx(520.92144757654194)
    assert dv[1] == approx(1545.1246586237653)
    tx = motion.strafe_time(1000, dv[0], K)
    tz = motion.gravity_time_speediz_z(-600 + dv[1], 500, 800)
    assert tx == approx(tz[1])
Пример #2
0
def test_strafe_solve_speedxi_curve_shape():
    K = motion.strafe_K(30, 0.001, 320, 10)
    xs = range(1, 10000, 500)
    zs = range(1, 601, 100)
    for x, z in itertools.product(xs, zs):
        vix = motion.strafe_solve_speedxi(1000, K, x, z, 800)
        tx = motion.strafe_time(x, vix, K)
        tz = motion.gravity_time_speediz_z(1000, z, 800)
        if not math.isclose(tx, tz[0], abs_tol=1e-6):
            assert tx <= tz[0]
Пример #3
0
def test_solve_boost_min_dmg():
    K = motion.strafe_K(30, 0.001, 320, 10)
    with raises(ValueError):
        motion.solve_boost_min_dmg([0, 0], -K, 400, 400, 800)

    dv = motion.solve_boost_min_dmg([0, 0], K, 400, 400, 800)
    assert dv[0] == approx(79.399032802535118, 1e-4)
    assert dv[1] == approx(816.5301806366407, 1e-4)
    t = motion.gravity_time_speediz_z(dv[1], 400, 800)
    assert t[1] == approx(motion.strafe_time(400, dv[0], K))
    assert dv[1] - 800 * t[1] <= 0
Пример #4
0
def test_gravity_time_speediz_z_curve_shape():
    vs = range(-1000, 1001, 50)
    zs = range(-10000, 10000, 100)
    for v, z in itertools.product(vs, zs):
        try:
            t = motion.gravity_time_speediz_z(v, z, 800)
        except (ZeroDivisionError, ValueError):
            continue
        if math.isclose(t[0], t[1]):
            continue
        assert v - 800 * t[0] > 0
        assert v - 800 * t[1] < 0
Пример #5
0
def test_solve_boost_min_dmg_range():
    K = motion.strafe_K(30, 0.001, 320, 10)
    for d in itertools.chain(range(-10000, 10001, 100),
                             np.arange(-100, 100, 0.5)):
        dv = motion.solve_boost_min_dmg([0, 0], K, d, d, 800)
        assert dv[0] < 1e4 and dv[1] < 1e4
        assert dv[0] >= 0 and dv[1] >= 0
        t = motion.gravity_time_speediz_z(dv[1], d, 800)
        assert dv[1] - 800 * t[1] <= 0
        strafe_t = motion.strafe_time(d, dv[0], K)
        if not math.isclose(t[1], strafe_t):
            assert t[1] > strafe_t
        if not math.isclose(t[0], strafe_t):
            assert t[0] < strafe_t

        dv = motion.solve_boost_min_dmg(dv, K, d, d, 800)
        assert dv[0] == approx(0, abs=1e-5)
        assert dv[1] == approx(0, abs=1e-5)

        dv = motion.solve_boost_min_dmg([0, 0], K, 400, d, 800)
        assert dv[0] < 1e4 and dv[1] < 1e4
Пример #6
0
def test_gravity_time_speediz_z():
    assert motion.gravity_time_speediz_z(10, 10, 0) == (1, 1)
    with raises(ZeroDivisionError):
        motion.gravity_time_speediz_z(0, 10, 0)
    assert motion.gravity_time_speediz_z(0, 0, 800) == (0, 0)
    with raises(ValueError):
        motion.gravity_time_speediz_z(0, 10, 800)
    ret = motion.gravity_time_speediz_z(0, 10, -800)
    assert ret[0] == approx(0.15811388300841897)
    assert ret[1] == approx(-0.15811388300841897)
    ret = motion.gravity_time_speediz_z(0, -10, 800)
    assert ret[0] == approx(-0.15811388300841897)
    assert ret[1] == approx(0.15811388300841897)
    ret = motion.gravity_time_speediz_z(-100, 6.25, 800)
    assert ret[0] == approx(-0.125)
    assert ret[0] == approx(ret[1])
    ret = motion.gravity_time_speediz_z(268, 20, 800)
    assert ret[0] == approx(0.085550606334671569)
    assert ret[1] == approx(0.58444939366532844)
    ret = motion.gravity_time_speediz_z(268, -20, 560)
    assert ret[0] == approx(-0.069570144084276309)
    assert ret[1] == approx(1.0267130012271333)