Beispiel #1
0
 def test_sensor_cells(self):
     beer = beerworld.Beer()
     cells = beer.sensor_cells()
     print
     if 1 in cells:
         for x in beer.board:
             print x
         print cells
Beispiel #2
0
    def test_spawn_agent(self):
        beer = beerworld.Beer()

        counter = 0
        for x in beer.board:
            for y in x:
                if y == "A":
                    counter += 1
        assert counter == 5
Beispiel #3
0
    def test_spawn_object(self):
        beer = beerworld.Beer()

        counter = 0
        for x in beer.board:
            for y in x:
                if y in "SB":
                    counter += 1
        assert 0 < counter < 7
Beispiel #4
0
    def test_modify_on_action(self):
        beer = beerworld.Beer()
        beer.modify_on_action(-4)

        counter = 0
        for x in beer.board:
            for y in x:
                if y == "A":
                    counter += 1
        assert counter == 5
Beispiel #5
0
def simulate(generation):
    nn = NeuralNet(generation.best_parameters)
    beer = beerworld.Beer()

    for _ in range(generation.timesteps):
        stim = beer.sensor_cells()
        output = nn.act_on_input(stim)
        output = int(round((output[0] - output[1]) * 4.0))
        beer.modify_on_action(output)
        yield beer.board
Beispiel #6
0
 def __init__(self, candidate, size, timesteps, max_generations,
              probability, num_elites, run_type):
     self.candidate = candidate
     self.size = size
     self.timesteps = timesteps
     self.max_generations = max_generations
     self.population = self.initialize_population()
     self.probability = probability
     self.num_elites = num_elites
     self.run_type = run_type
     self.beer = beerworld.Beer()
Beispiel #7
0
 def test_graphics_from_beerworld(self):
     beer = beerworld.Beer()
Beispiel #8
0
 def test_fall(self):
     beer = beerworld.Beer()
     beer.fall()
     assert "S" in beer.board[1] or "B" in beer.board[1]