def _get_seird_counts( self, env: Environment ) -> Tuple[int, int, int, int, int]: """ env の s, e, i, r, d のカウント結果を取得 """ s = env.count_agent(Status.SUSCEPTABLE) e = env.count_agent(Status.EXPOSED) i = env.count_agent(Status.INFECTED) r = env.count_agent(Status.RECOVERED) d = env.count_agent(Status.DEATH) return s, e, i, r, d
def init_world(self): """ World の初期化 """ # 各ノードの Environment を初期化 self.all_agents = [] for node in self.world_graph.nodes(data=True): idx, data = node env_setting = self.env_settings[idx] data["env"] = Environment( infection_model=self.infection_model, agent_setting=self.agent_setting, **env_setting ) agents = data["env"].get_agents() self.all_agents.extend(agents) logger.info( "Worldクラスを初期化しました。ノード数:{}, 総人口:{}".format( self.node_num, len(self.all_agents) ) )
def run(index): EnvironmentParameters.playround_with = 600 EnvironmentParameters.playround_height = 600 EnvironmentParameters.food_count = index // 4 EnvironmentParameters.landmark_count = index SimulationParameters.ant_count = 25 SimulationParameters.move_speed = 1 SimulationParameters.move_angle = 15 / 180 * np.pi SimulationParameters.traceback_angle = 5 / 180 * np.pi SimulationParameters.vision_range = 25 e = Environment().generate_environment( [], [(250, 0)], [(100, 0), (-100, 0), (0, 100), (0, -100), (200, 200), (200, -200), (-200, -200), (-200, 200)]) s = Simulation(e) return s.simulateAll()
def _simulate(args=None): # Read control panel values SimulationParameters.ant_count = count_scale.get() SimulationParameters.move_speed = speed_scale.get() / 100 SimulationParameters.move_angle = angle_scale.get() / 180 * np.pi SimulationParameters.traceback_angle = traceback_angle_scale.get() / 180 * np.pi SimulationParameters.vision_range = vision_scale.get() plt.clf() # clears previous graph plt.axis("off") plt.tight_layout(0) e = Environment().generate_random_environment() s = Simulation(e) result = s.simulateAll() if result is None: return drawPaths(canvas, result.getAll()) drawEnvironment(canvas, e) canvas.draw()
def setUpClass(cls): envi = Environment() cls.driver = envi.create_browser_instance() envi.navigate_to_home() cls.username = envi.username cls.password = envi.password
import numpy as np import random import sys sys.path.append("..") from matplotlib import pyplot as plt from matplotlib import animation from pylab import * from Animat import Animat from Environment.Environment import Environment # Initialize an Animat xMax = 20 yMax = 20 env = Environment(xMax, yMax, 10, 10) animat = Animat(10, 10, xMax, yMax, env) env.initializeWeb() env.generateFood(5, 3, 12, 7, 17) env.generateFood(5, 13, 3, 18, 7) foodList = [] for e in env.foodList: foodList.append((e.x, e.y)) #print 'Food list : {}'.format(foodList) foodList = zip(*foodList) #print 'Modified : {}'.format(foodList) # First set up the figure, the axis, and the plot element we want to animate fig = plt.figure() ax = plt.axes(xlim=(0, xMax), ylim=(0, yMax)) #---
def runSimulation() -> None: camera = Camera(CAMERA_SLACK) environment = Environment() environment.buildWalls() robot = Robot(ROBOSIZE, HALF_WINWIDTH, HALF_WINHEIGHT) ##Init Renderers environmentRenderer = EnvironmentRenderer(environment, camera, DISPLAY) randomRenderer = RandomRenderer(environment, camera, robot, DISPLAY) robotViewRenderer = RobotViewRenderer(robot, camera, DISPLAY) ## ##Add sensors to the robot ultrasonic = Ultrasonic(350) robot.attachUltrasonic(ultrasonic) hall = Hall() robot.attachHall(hall) magnetometer = Magnetometer() robot.attachMagnetometer(magnetometer) ## ##Add robot to the environment environment.addRobot(robot) ## while True: camera.adjustCamera(DISPLAY, robot) ## Render Stuff environmentRenderer.render(getColor('white'), getColor('white'), getColor('red')) randomRenderer.render() robotViewRenderer.render(getColor('blue'), getColor('white'), getColor('black'), True) ## ##Handle key presses for event in pygame.event.get(): robot.moveDown, robot.moveUp, robot.rotateRight, robot.rotateLeft, robot.rotate, doScan, robot.servoLeft, robot.servoRight = RobotActionHandler( event, robot) doTerminate = TerminateHandler(event) if doTerminate: terminate() if doScan: robot.scan(environment) ## ##handle robot movement robot.handleMovementCommands() environment.triggerRobotRotation() environment.triggerRobotMovement() ## pygame.display.update() FPSCLOCK.tick(FPS)
import numpy as np import random import sys sys.path.append("..") from matplotlib import pyplot as plt from matplotlib import animation from pylab import * from Animat import Animat from Environment.Environment import Environment # Initialize an Animat xMax = 20 yMax = 20 env = Environment(xMax, yMax, 10, 10) animat = Animat(10, 10, xMax, yMax, env) env.initializeWeb() env.generateFood(15, 10, 4, 16, 16) foodList = [] for e in env.foodList: foodList.append((e.x, e.y)) #print 'Food list : {}'.format(foodList) foodList = zip(*foodList) #print 'Modified : {}'.format(foodList) # First set up the figure, the axis, and the plot element we want to animate fig = plt.figure() ax = plt.axes(xlim=(0, xMax), ylim=(0, yMax))
import numpy as np import random import sys sys.path.append("..") from matplotlib import pyplot as plt from matplotlib import animation from pylab import * from Animat import Animat from Environment.Environment import Environment # Initialize an Animat xMax = 20 yMax = 20 env = Environment(xMax, yMax, 10, 10) animat = Animat(10, 10, xMax, yMax,env) env.initializeWeb() env.generateFood(15, 0 ,0,20 ,20) foodList =[] for e in env.foodList: foodList.append((e.x,e.y)) #print 'Food list : {}'.format(foodList) foodList = zip(*foodList) #print 'Modified : {}'.format(foodList) # First set up the figure, the axis, and the plot element we want to animate fig = plt.figure() ax = plt.axes(xlim=(0, xMax), ylim=(0, yMax))
def _get_average_income(self, env: Environment) -> float: """ 平均所得を取得 """ return env.get_average_income()
def _get_tax_revenue(self, env: Environment) -> float: """ Environment の税収を取得 """ return env.get_tax_revenue()
def _get_finance(self, env: Environment) -> float: """ Environment の経済力を取得 """ return env.get_finance()
def _get_average_mental_strength(self, env: Environment) -> float: """ 平均メンタル値を取得 """ return env.get_average_mental_strength()
import numpy as np import random import sys sys.path.append("..") from matplotlib import pyplot as plt from matplotlib import animation from pylab import * from Animat import Animat from Environment.Environment import Environment # Initialize an Animat xMax = 20 yMax = 20 env = Environment(xMax, yMax, 10, 10) animat = Animat(10, 10, xMax, yMax,env) env.initializeWeb() env.generateFood(15, 10,4,16,16) foodList =[] for e in env.foodList: foodList.append((e.x,e.y)) #print 'Food list : {}'.format(foodList) foodList = zip(*foodList) #print 'Modified : {}'.format(foodList) # First set up the figure, the axis, and the plot element we want to animate fig = plt.figure() ax = plt.axes(xlim=(0, xMax), ylim=(0, yMax))
import numpy as np import random import sys sys.path.append("..") from matplotlib import pyplot as plt from matplotlib import animation from pylab import * from Animat import Animat from Environment.Environment import Environment # Initialize an Animat xMax = 20 yMax = 20 env = Environment(xMax, yMax, 10, 10) animat = Animat(10, 10, xMax, yMax,env) env.initializeWeb() env.generateFood(5, 3,12,7,17) env.generateFood(5,13,3,18,7) foodList =[] for e in env.foodList: foodList.append((e.x,e.y)) #print 'Food list : {}'.format(foodList) foodList = zip(*foodList) #print 'Modified : {}'.format(foodList) # First set up the figure, the axis, and the plot element we want to animate fig = plt.figure() ax = plt.axes(xlim=(0, xMax), ylim=(0, yMax))