Question: Generate New Agent Arrivals: You need to implement the logic for generating new agents at random intervals on both ends of the simulation area. Agents

Generate New Agent Arrivals: You need to implement the logic for generating new agents at random intervals on both ends of the simulation area. Agents can enter the simulation at any point along the y-axis but only from the extreme left or right sides (x-axis).
Implement Agent Behavior:
Uninfected agents should try to cross the area from one side to the other without getting infected. When their path is blocked, they should attempt to sidestep the obstacle.
Infected agents, on the other hand, aim to infect uninfected agents. They should seek out the nearest uninfected agent and try to get as close as possible to them to infect them. Once an agent is infected, it turns its attention to another uninfected agent. Remember, infected agents have a limited lifespan in the simulation.
Aggregate Data: You should collect and report data on various aspects of the simulation, such as the initial infection rate, new infection rate, total infection rate, and possibly the infection rates over time.
Parts of the Assignment:
Part 1: Implement the basic behaviors described above. Ensure uninfected agents move towards their goal across the simulation area and infected agents focus on infecting others. Address scenarios where agents might block each other's path.
Part 2: Enhance the simulation by introducing additional strategies. This could involve uninfected agents actively avoiding infected ones or infected agents working together strategically to infect uninfected agents. The effectiveness and complexity of these behaviors will impact your marks for this part.
Technical Requirements:
Implement agent actions within the step() method of each agent, which defines what an individual agent does in each time step.
Agents interact with the simulation area through specific methods (attemptmove(), enter_area(), leave_area()) to ensure they do not directly modify their own coordinates or violate the simulation rules.
You must not alter the graphical implementation or underlying data structure code provided with the assignment. Do not make any changes tographical implementation, nor to any of the underlying data structure code. PLease use my zombie base code and to answer the questions use the extra codes i am providing in the screenshot.
Base Zombie Code:
import math
from matplotlib import pyplot as plt, colors
from matplotlib.animation import FuncAnimation
import random
rand = random.Random()
AREA_WIDTH =150
AREA_LENGTH =250
TRANSPROB =0.3
INFECTED_PROP =0.1
INFECTED_LIFE =100
INTERARRIVAL =3
colourmap = colors.ListedColormap(["lightgrey", "blue", "red", "yellow", "grey"])
normalizer = colors.Normalize(vmin=0.0, vmax=4.0)
class Person:
def __init__(self, id, area):
self.id = id
self.active = False
self.area = area
self.newlyinfected = False
self.infected = False
self.remaininglife = None
if rand.random() INFECTED_PROP:
self.infected = True
self.remaininglife = INFECTED_LIFE
if rand.choice([True, False]):
self.startx =0
self.direction =1
else:
self.startx = AREA_LENGTH -1
self.direction =-1
self.starty = self.y = rand.randint(0, AREA_WIDTH -1)
def enter_area(self, x, y):
if self.area.enter_area(self, x, y):
self.active = True
def step(self):
desiredx = self.x
desiredy = self.y
change = rand.choice([-1,1])
if rand.choice([True, False]):
desiredx = self.x + change
else:
desiredy = self.y + change
desiredx = max(min(desiredx, AREA_LENGTH -1),0)
desiredy = max(min(desiredy, AREA_WIDTH -1),0)
self.area.attemptmove(self, desiredx, desiredy)
def __str__(self):
return "id: %d x: %d y: %d"%(self.id, self.x, self.y)
class Area:
def __init__(self):
self.storage = AreaGrid()
self.bitmap =[[0.0 for i in range(AREA_LENGTH)] for j in range(AREA_WIDTH)]
def enter_area(self, person, x, y):
if x!=0 and x!=AREA_LENGTH-1:
print("Must start at an end!")
return False
if self.storage.isoccupied(x, y):
print("Move rejected: occupied")
return False
self.storage.add_item(x, y, person)
person.x = x
person.y = y
return True
def leave_area(self, person):
if person.x !=0 and person.x != AREA_LENGTH -1:
print("Must leave at an end!")
return False
self.storage.remove_item(person)
def attemptmove(self, person, x, y):
if (abs(person.x - x)+ abs(person.y - y))>1:
print("Attempt to move more than one square!")
return False
if x 0 or x >= AREA_LENGTH or y 0 or y >= AREA_WIDTH:
print("Move rejected: out of area!")
return False
if self.storage.isoccupied(x, y):
return False
person.x = x
person.y = y
self.storage.move_item(x, y, person)
return True
(Rest of the zombie base code and extra seperate codes which are to be integrated in the zombie base code to answer the question are in the image i am extremely sorry because chegg is not allowing me to upload all of it which is why i had to upload like this) lastly please make it so the code runs and shows the simulation happening becasue i used chegg the other day and got an expert verified solution and unfortunately it dosent even run the simulation.
 Generate New Agent Arrivals: You need to implement the logic for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!