예제 #1
0
class EvoLife6DExperiment(RegularExperiment):
    """
    Generic experiment for 6D EvoLife: 2 spatial, 4 micro-dimensions.

    WARNING: to run this model you need at least 9GB GPU RAM free.

    """

    word = "SP1RALS 1N HYPERSP@CE"
    size = (640, 380, 7, 5, 3, 3)
    pos = [50, 50, 0, 0, 0, 0]
    death_speed = 64
    max_genes = 13
    mutation_prob = 0.0001
    fade_in = 63
    fade_out = 18
    mask_random = RandInt(0, 2 ** 26 - 1, constant=True)
    seed_bang = seeds.patterns.BigBang(
        pos=(0, 0, 0, 0, 0, 0),
        size=(100, 100, 1, 1, 1, 1),
        vals={
            "energy": RandInt(0, 1) * 255,
            "rule": RandInt(0, 2 ** 26 - 1) & mask_random,
            "rng": RandInt(0, 2 ** 16 - 1)
        }
    )
    seed_rng = seeds.patterns.PrimordialSoup(
        vals={
            "rng": RandInt(0, 2 ** 16 - 1)
        }
    )
    seed = seed_rng + seed_bang
예제 #2
0
class CrossbreedingExperiment(RegularExperiment):
    """Classic experiment for legacy EvoLife, where 'Bliambas' may form."""

    word = "FUTURE BREEDING MACHINE 2041"
    size = (1920, 1080)
    zoom = 1
    fade_in = 18
    fade_out = 3
    seed_diamoeba = seeds.patterns.BigBang(
        pos=(380, 280),
        size=(440, 340),
        vals={
            "energy": 0,
            "rule": LifeLike.golly2int("B35678/S5678") * RandInt(0, 1),
            "rng": RandInt(0, 2 ** 16 - 1)
        }
    )
    seed_conway = seeds.patterns.BigBang(
        pos=(0, 0),
        size=(1280, 720),
        vals={
            "energy": 0,
            # you may use unary operators
            "rule": +RandInt(0, 1) * LifeLike.golly2int("B3/S23"),
            # as well as reflected expressions
            "rng": 0 + RandInt(0, 2 ** 16 - 1)
        }
    )
    seed_rng = seeds.patterns.PrimordialSoup(
        vals={
            "rng": RandInt(0, 2 ** 16 - 1)
        }
    )
    # chain ordering matters, since areas are rewriting each other in order
    seed = seed_rng + seed_conway + seed_diamoeba
예제 #3
0
class BigBangExperiment4D(RegularExperiment):
    """Experiment in 4D space."""
    size = (640, 360, 3, 3)
    death_speed = 1
    full_treshold = 16
    max_genes = 5
    fade_in = 1
    fade_out = 1
    smooth_ratio = 10
    rule_back = LifeLike.golly2int("B12/S124")
    seed = seeds.patterns.PrimordialSoup(
        vals={
            "energy": 2,
            "new_energy": 2,
            "rule": rule_back,
            "rng": RandInt(0, 2**16 - 1),
        })
    for i in range(6 * 3):
        add_rule = str(random.randint(4, 4)).replace("2", "")
        rule_area = LifeLike.golly2int("B12/S12" + add_rule)
        seed += seeds.patterns.BigBang(pos=(30 + (i % 6) * 100,
                                            40 + (i // 6) * 100, 0, 0),
                                       size=(80, 80, 1, 1),
                                       vals={
                                           "energy": 1 * 273 * RandInt(0, 1),
                                           "new_energy":
                                           1 * 273 * RandInt(0, 1),
                                           "rule": rule_area,
                                           "rng": RandInt(0, 2**16 - 1),
                                       })
예제 #4
0
class BigBangExperiment(RegularExperiment):
    """Experiment, with smaller field, for quicker benchmark."""
    death_speed = 1
    full_treshold = 16
    max_genes = 13
    fade_in = 255
    fade_out = 255
    smooth_ratio = 1
    rule_mask = LifeLike.golly2int("B12345678/S12345678")
    seed = seeds.patterns.PrimordialSoup(
        vals={
            "energy": 0,
            "new_energy": 0,
            "rule": random.randint(0, 2**18 - 1) & rule_mask,
            "rng": RandInt(0, 2**16 - 1),
        })
    for i in range(6 * 3):
        seed += seeds.patterns.BigBang(
            pos=(30 + (i % 6) * 100, 40 + (i // 6) * 100),
            size=(80, 80),
            vals={
                "energy": 16 * RandInt(0, 1),
                "new_energy": 16 * RandInt(0, 1),
                "rule": random.randint(0, 2**18 - 1) & rule_mask,
                "rng": RandInt(0, 2**16 - 1),
            })
예제 #5
0
 def test_interval(self):
     """Test generated values are in valid range."""
     holder = RandomHolder()
     holder.__class__.rand_val = RandInt(11, 23)
     for _ in range(10):
         self.assertGreaterEqual(holder.rand_val, 11, "Wrong random value.")
         self.assertLessEqual(holder.rand_val, 23, "Wrong random value.")
예제 #6
0
 def test_seed(self):
     """Test correct sequence in generated with a seed."""
     holder = RandomHolder(TEST_SEED)
     holder.__class__.rand_val = RandInt(11, 23)
     sequence_valid = [22, 15, 21, 23, 14, 14, 11, 20, 17, 23]
     sequence_generated = [holder.rand_val for i in range(10)]
     self.assertListEqual(sequence_valid, sequence_generated,
                          "Wrong sequence for seed '%s'." % TEST_SEED)
예제 #7
0
 def test_multiple_values(self):
     """Test multiple values storing."""
     val_dict = ValDict({'a': 2, 's': RandInt(11, 23), 'd': 3.3})
     self.assertEqual(val_dict['a'], 2, "Wrong first constant value.")
     for _ in range(10):
         self.assertGreaterEqual(val_dict['s'], 11, "Wrong random value.")
         self.assertLessEqual(val_dict['s'], 23, "Wrong random value.")
     self.assertEqual(val_dict['d'], 3.3, "Wrong second constant value.")
예제 #8
0
 def test_random_full(self):
     """Test omitted size and position behavior."""
     bsca = GameOfLife(TestExperiment)
     vals = {'state': RandInt(0, 1)}
     pattern = BigBang(vals=vals)
     cells = np.zeros((10000, ), dtype=np.int32)
     pattern.generate(cells, bsca)
     self.assertGreater(np.sum(cells), 0, "Empty board.")
예제 #9
0
 def test_items(self):
     """Test iteration over items."""
     val_dict = ValDict({'a': 2, 's': RandInt(11, 23), 'd': 3.3})
     for key, val in val_dict.items():
         if key == 'a':
             self.assertEqual(val, 2, "Wrong constant value.")
         elif key == 's':
             self.assertGreaterEqual(val, 11, "Wrong random value.")
             self.assertLessEqual(val, 23, "Wrong random value.")
예제 #10
0
 def test_multiple_dicts(self):
     """Test different dicts keeping different values."""
     val_dict1 = ValDict({'s': 2})
     val_dict2 = ValDict({'s': RandInt(11, 23)})
     self.assertEqual(val_dict1['s'], 2, "Wrong first ValDict.")
     for _ in range(10):
         self.assertGreaterEqual(val_dict2['s'], 11,
                                 "Wrong second ValDict.")
         self.assertLessEqual(val_dict2['s'], 23, "Wrong second ValDict.")
예제 #11
0
 def test_wrong_pos(self):
     """Test position auto-correction to make area fit to field."""
     bsca = GameOfLife(TestExperiment)
     vals = {'state': RandInt(0, 1)}
     pattern = BigBang(pos=(90, 90), size=(20, 20), vals=vals)
     cells = np.zeros((10000, ), dtype=np.int32)
     pattern.generate(cells, bsca)
     self.assertEqual(pattern.pos[0], 80, "Wrong X position.")
     self.assertEqual(pattern.pos[1], 80, "Wrong Y position.")
예제 #12
0
 def test_2d(self):
     """Test same field is generated with same seed."""
     bsca = GameOfLife(TestExperiment)
     vals = {'state': RandInt(0, 1)}
     seed = PrimordialSoup(vals=vals)
     cells = np.zeros((10000, ), dtype=np.int32)
     seed.random = LocalRandom("test")
     seed.generate(cells, bsca)
     self.assertEqual(binascii.crc32(cells[:10000]), 1648433356,
                      "Wrong field checksum.")
예제 #13
0
class BigBangExperiment(RegularExperiment):
    """Experiment, with smaller field, for quicker benchmark."""
    death_speed = 0
    max_genes = 9
    seed_bang = seeds.patterns.BigBang(
        pos=(0, 0),
        size=(100, 100),
        vals={
            "energy": RandInt(0, 255),
            "rule": RandInt(0, 2 ** 18 - 1) & 0b111111110111111110,
            "rng": RandInt(0, 2 ** 16 - 1)
        }
    )
    seed_rng = seeds.patterns.PrimordialSoup(
        vals={
            "rng": RandInt(0, 2 ** 16 - 1)
        }
    )
    seed = seed_rng + seed_bang
예제 #14
0
class TestExperiment(GOLExperiment):
    """Regular experiment for tests."""
    size = (
        100,
        100,
    )
    seed = BigBang(pos=(32, 20),
                   size=(10, 10),
                   vals={
                       "state": RandInt(0, 1),
                   })
예제 #15
0
 def test_random_value(self):
     """Test random value storing."""
     val_dict = ValDict({'s': RandInt(11, 23)})
     for _ in range(10):
         self.assertGreaterEqual(val_dict['s'], 11, "Wrong random value.")
         self.assertLessEqual(val_dict['s'], 23, "Wrong random value.")
예제 #16
0
class NoiseTVExperiment(RegularExperiment):
    """Default experiment filling the whole board with a noise."""

    word = "PSHSHSHSH!"
    seed = seeds.patterns.PrimordialSoup(vals={"rng": RandInt(0, 2**16 - 1)})