Question: I am providing the base zombie python code that i wrote please Do not make any changes to graphical implementation, nor to any of the
I am providing the base zombie python code that i wrote please Do not make any changes to graphical implementation, nor to any of the underlying data structure code and also I have provided some seperate extra codes which is to be used to in the zombie code for answering the question: Develop an agentbased simulation in a zombie scenario with two main tasks:
Initial Setup and Agent Behavior:
Simulation Space: A rectangular Cartesian plane with agents entering from either end aiming to cross to the opposite side.
Agent Types: Uninfected agents aim to cross the area; infected agents aim to infect others.
Infection Mechanics: Infection occurs by proximity; infected agents target uninfected ones. Infected agents have a limited lifespan.
Agent Arrival: Implement random arrival times for new agents at both ends of the area, with a certain percentage starting as infected.
Agent Movement: Agents request movement through specific methods without direct coordinate manipulation. Movement is straight across unless obstructed, with the option to sidestep.
Enhanced Behaviors and Strategies:
Basic Behavior: In Part uninfected agents move straight to the opposite end, sidestepping as needed. Infected agents prioritize uninfected targets.
Advanced Behavior: For Part implement either uninfected agents actively avoiding infection or infected agents cooperating to enhance infection rates.
Additional Requirements:
Agent Interactions: Use getnearestlist for detecting nearby agents and determining behavior based on infection status.
Decision Making: Agents' actions are determined by conditions related to their surroundings, using relative coordinates for movement and interaction.
Simulation Management: Implement the simulation's timestep activities in the runstep method without altering graphical routines.
Data Tracking: Monitor initial infection rate, new infection rate, and total infection rate, plus infection trends over time.
Technical Notes:
Agent EntryExit: Manage through enterarea and leavearea methods.
Occupancy Checks: Utilize isoccupied for determining available movement spaces.
Code Structure: Focus changes on the Person class's step function for behavior and the Area class for managing arrivals. Avoid modifying graphical code or underlying data structures.
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
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
