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
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
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
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
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
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()
def test_graphics_from_beerworld(self): beer = beerworld.Beer()
def test_fall(self): beer = beerworld.Beer() beer.fall() assert "S" in beer.board[1] or "B" in beer.board[1]