Exemplo n.º 1
0
def test_solve_boost_min_dmg_no_dv():
    K = motion.strafe_K(30, 0.001, 320, 10)
    dv = motion.solve_boost_min_dmg([0, 0], K, 100, -100000, 800)
    assert dv[0] == approx(0, abs=1e-5)
    dv = motion.solve_boost_min_dmg([10000, 0], K, 1000, -10, 800)
    assert dv[0] == approx(0, abs=1e-5)
    assert dv[1] == approx(0, abs=1e-5)
    dv = motion.solve_boost_min_dmg([0, 1500], K, 500, 1000, 800)
    assert dv[0] == approx(0, abs=1e-5)
    assert dv[1] == approx(0, abs=1e-5)
Exemplo n.º 2
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
Exemplo n.º 3
0
def test_solve_boost_min_dmg_zero_pos():
    np.warnings.filterwarnings('ignore')
    K = motion.strafe_K(30, 0.001, 320, 10)
    dv = motion.solve_boost_min_dmg([400, 0], K, 0, -1, 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, 0, 1, 800)
    assert dv[1] >= 1e4
    dv = motion.solve_boost_min_dmg([200, 200], K, 0, 0, 800)
    assert dv[0] == approx(0, abs=1e-5)
    assert dv[1] == approx(0, abs=1e-5)
    np.warnings.filterwarnings('default')
Exemplo n.º 4
0
def test_solve_boost_min_dmg_neg_z():
    K = motion.strafe_K(30, 0.001, 320, 10)
    dv = motion.solve_boost_min_dmg([400, 268], K, 1500, -200, 800)
    assert dv[0] == approx(298.46589871993854, 1e-4)
    assert dv[1] == approx(366.81197893286605, 1e-4)
    K = motion.strafe_K(30, 0.001, 320, 100)
    dv = motion.solve_boost_min_dmg([400, 268], K, 1500, -200, 800)
    assert dv[0] == approx(77.238561539572189, 1e-4)
    assert dv[1] == approx(241.47957829048562, 1e-4)
    dv = motion.solve_boost_min_dmg([0, 0], K, 0, -200, 800)
    assert dv[0] == approx(0)
    assert dv[1] == approx(0)
Exemplo n.º 5
0
def test_solve_boost_min_dmg_inc_v():
    K = motion.strafe_K(30, 0.001, 320, 10)
    prev = math.inf
    for vx in range(0, 10000, 100):
        dv = motion.solve_boost_min_dmg([vx, 0], K, 1500, -200, 800)
        mag = math.hypot(dv[0], dv[1])
        assert mag <= prev
        prev = mag

    prev = math.inf
    for vy in range(0, 10000, 100):
        dv = motion.solve_boost_min_dmg([0, vy], K, 1500, -200, 800)
        mag = math.hypot(dv[0], dv[1])
        assert mag <= prev
        prev = mag
Exemplo n.º 6
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])
Exemplo n.º 7
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
Exemplo n.º 8
0
def test_solve_boost_min_dmg_neg_x():
    K = motion.strafe_K(30, 0.001, 320, 10)
    dv1 = motion.solve_boost_min_dmg([0, 0], K, -400, 500, 800)
    dv2 = motion.solve_boost_min_dmg([0, 0], K, 400, 500, 800)
    assert dv1 == dv2