def __init__(self): self.grid = Grid(cfg.get("width"), cfg.get("height"), cfg.get("radius"), plane_type=cfg.get("map_type")) self.society = Society() self.grid.insert_population(self.society)
def __init__(self, population_size: int = -1, initial_infected_num: int = -1): if population_size == -1: population_size = cfg.get('population_size') if initial_infected_num == -1: initial_infected_num = cfg.get('initial_infected_number') self.null_person = Person(0, State.Deceased) self.population = [] self.make_population_great_again(population_size, initial_infected_num)
def __init__(self, population_size: int = -1, initial_infected_num: int = -1): if population_size == -1: population_size = cfg.get('population_size') if initial_infected_num == -1: initial_infected_num = cfg.get('initial_infected_number') self.null_person = Being(0, State.Inactive) self.__population_hashmap = {} self.susceptible_count = 0 self.infectious_count = 0 self.deceased_count = 0 self.recovered_count = 0 self.__make_population_great_again(population_size, initial_infected_num)
def __init__(self): self.iteration = 0 cfg.load() self.plane = Plane(cfg.get("width"), cfg.get("height"), cfg.get("radius"), cfg.get("map_type")) self.population = Population() self.population.scatter(self.plane) self.drawer = Drawer() print(len(self.plane.hexagons)) pass
def get_cartesian_coordinates(self): x = cfg.get("hex_size") * (np.sqrt(3) * self.coordinates.i + np.sqrt(3) / 2 * self.coordinates.j) y = cfg.get("hex_size") * (3. / 2 * self.coordinates.j) return x, y
def draw_from_grid_WIP(grid, society): hex_size = cfg.get('hex_size') fig, ax = plt.subplots() xmax = 0 xmin = 0 ymax = 0 ymin = 0 grid_listed = grid.get_grid_in_cartesian() for x, y, value in grid_listed: xmax = max(xmax, x) xmin = min(xmin, x) ymax = max(ymax, y) ymin = min(ymin, y) if society.get_being(value['person']).state == State.Inactive: hexes = RegularPolygon((x, y), numVertices=6, radius=hex_size, alpha=1, edgecolor='k', facecolor='w') ax.add_patch(hexes) elif society.get_being(value['person']).state == State.Susceptible: hexes = RegularPolygon((x, y), numVertices=6, radius=hex_size, alpha=1, edgecolor='k', facecolor='b') ax.add_patch(hexes) elif society.get_being(value['person']).state == State.Infectious: hexes = RegularPolygon((x, y), numVertices=6, radius=hex_size, alpha=1, edgecolor='k', facecolor='r') ax.add_patch(hexes) elif society.get_being(value['person']).state == State.Deceased: hexes = RegularPolygon((x, y), numVertices=6, radius=hex_size, alpha=1, edgecolor='k', facecolor='0.5') ax.add_patch(hexes) elif society.get_being(value['person']).state == State.Recovered: hexes = RegularPolygon((x, y), numVertices=6, radius=hex_size, alpha=1, edgecolor='k', facecolor='g') ax.add_patch(hexes) plot_border = 10 ax.set_xlim([xmin - plot_border, xmax + plot_border]) ax.set_ylim([ymin - plot_border, ymax + plot_border]) plt.grid(False) plt.axis('off') susceptible = Patch(color='b', label='Susceptible') infectious = Patch(color='r', label='Infectious') deceased = Patch(color='0.5', label='Deceased') recovered = Patch(color='g', label='Recovered') plt.legend(handles=[susceptible, infectious, deceased, recovered]) plt.show()
def get_cartesian_coordinates(i, j): x = cfg.get("hex_size") * (np.sqrt(3) * i + np.sqrt(3) / 2 * j) y = cfg.get("hex_size") * (3. / 2 * j) return x, y