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 agent-based 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 1, uninfected agents move straight to the opposite end, sidestepping as needed. Infected agents prioritize uninfected targets.
Advanced Behavior: For Part 2, implement either uninfected agents actively avoiding infection or infected agents cooperating to enhance infection rates.
Additional Requirements:
Agent Interactions: Use get_nearest_list() 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 run_step() 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 Entry/Exit: Manage through enter_area() and leave_area() 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()
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)
 I am providing the base zombie python code that i wrote

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!