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 yaxis but only from the extreme left or right sides xaxis
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 : 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 : 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 enterarea leavearea 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
AREAWIDTH
AREALENGTH
TRANSPROB
INFECTEDPROP
INFECTEDLIFE
INTERARRIVAL
colourmap colors.ListedColormaplightgrey "blue", "red", "yellow", "grey"
normalizer colors.Normalizevmin vmax
class Person:
def initself id area:
self.id id
self.active False
self.area area
self.newlyinfected False
self.infected False
self.remaininglife None
if rand.random INFECTEDPROP:
self.infected True
self.remaininglife INFECTEDLIFE
if rand.choiceTrue False:
self.startx
self.direction
else:
self.startx AREALENGTH
self.direction
self.starty self.y rand.randint AREAWIDTH
def enterareaself x y:
if self.area.enterareaself x y:
self.active True
def stepself:
desiredx self.x
desiredy self.y
change rand.choice
if rand.choiceTrue False:
desiredx self.x change
else:
desiredy self.y change
desiredx maxmindesiredx AREALENGTH
desiredy maxmindesiredy AREAWIDTH
self.area.attemptmoveself desiredx, desiredy
def strself:
return id: d x: d y: dselfid self.x self.y
class Area:
def initself:
self.storage AreaGrid
self.bitmap for i in rangeAREALENGTH for j in rangeAREAWIDTH
def enterareaself person, x y:
if x and xAREALENGTH:
printMust start at an end!"
return False
if self.storage.isoccupiedx y:
printMove rejected: occupied"
return False
self.storage.additemx y person
person.x x
person.y y
return True
def leaveareaself person:
if person.x and person.x AREALENGTH :
printMust leave at an end!"
return False
self.storage.removeitemperson
def attemptmoveself person, x y:
if abspersonx x abspersony y:
printAttempt to move more than one square!"
return False
if x or x AREALENGTH or y or y AREAWIDTH:
printMove rejected: out of area!"
return False
if self.storage.isoccupiedx y:
return False
person.x x
person.y y
self.storage.moveitemx 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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
