Beispiel #1
0
def test_without_sharks_fish_overbreed():
    nfish = 16
    wator = WaTor(shape=(32, 8), nsharks=0, nfish=nfish)
    assert wator.count_fish() == nfish
    while wator.count_fish() < wator.creatures.size:
        wator.tick()
        assert wator.count_fish() >= nfish
        nfish = wator.count_fish()
Beispiel #2
0
def test_shape():
    shape = (16, 16)
    wator = WaTor(shape=shape, nfish=16, nsharks=4)
    print(wator.creatures)
    assert wator.creatures.shape == shape
    assert wator.count_fish() == 16
    assert wator.count_sharks() == 4
    assert ((wator.creatures >= -10) & (wator.creatures <= 5)).all()
Beispiel #3
0
def test_creatures():
    creatures = numpy.zeros((8, 8))
    creatures[2, 4] = 3
    creatures[1, :] = -5
    wator = WaTor(creatures)
    print(wator.creatures)
    assert (creatures == wator.creatures).all()
    assert wator.count_fish() == 1
    assert wator.count_sharks() == 8
Beispiel #4
0
def test_shape_full_of_something():
    shape = (16, 16)
    total = 16 * 16
    nfish = total // 5
    nsharks = total - nfish
    wator = WaTor(shape=shape, nfish=nfish, nsharks=nsharks)
    print(wator.creatures)
    assert wator.count_fish() == nfish
    assert wator.count_sharks() == nsharks
Beispiel #5
0
def test_shape_custom_age():
    shape = (16, 16)
    age_fish = 2
    age_shark = 20
    wator = WaTor(shape=shape,
                  nfish=16,
                  nsharks=4,
                  age_fish=age_fish,
                  age_shark=age_shark)
    print(wator.creatures)
    assert wator.creatures.shape == shape
    assert wator.count_fish() == 16
    assert wator.count_sharks() == 4
    assert ((wator.creatures >= -age_shark) &
            (wator.creatures <= age_fish)).all()
Beispiel #6
0
def test_random_geenerator_speed():
    for i in range(20):
        wator = WaTor(shape=SHAPE, nfish=N, nsharks=N)
        print(i)
        assert wator.count_fish() == N
        assert wator.count_sharks() == N
Beispiel #7
0
def test_shape_full_of_shark():
    shape = (16, 16)
    wator = WaTor(shape=shape, nfish=0, nsharks=16 * 16)
    print(wator.creatures)
    assert wator.count_fish() == 0
    assert wator.count_sharks() == 16 * 16