22
33
44class Beneficiary (CellAgent ):
5- """
6- Simulates a person with dynamic needs (water and food).
5+ """Simulates a person with dynamic needs (water and food).
76
87 The agent follows a Needs-Based Architecture:
98 1. Biological drives (hunger/thirst) increase over time.
@@ -21,8 +20,7 @@ class Beneficiary(CellAgent):
2120 def __init__ (
2221 self , model , cell , water_decay = 2 , food_decay = 1 , critical_days_threshold = 5
2322 ):
24- """
25- Create a new Beneficiary agent.
23+ """Create a new Beneficiary agent.
2624
2725 Args:
2826 model: The Mesa model instance.
@@ -49,9 +47,7 @@ def __init__(
4947 CRITICAL = 90 # "Emergency"
5048
5149 def move_towards (self , target_pos ):
52- """
53- Moves the agent one step closer to the target position.
54- """
50+ """Moves the agent one step closer to the target position."""
5551 current_x , current_y = self .cell .coordinate
5652 target_x , target_y = target_pos
5753
@@ -72,8 +68,7 @@ def move_towards(self, target_pos):
7268 self .cell = self .model .grid [(next_x , next_y )]
7369
7470 def step (self ):
75- """
76- Advance the agent by one step.
71+ """Advance the agent by one step.
7772
7873 Lifecycle:
7974 1. Biological Decay: Needs increase naturally.
@@ -151,9 +146,9 @@ def wander(self):
151146 self .cell = self .cell .neighborhood .select_random_cell ()
152147
153148 def find_nearest_truck (self , radius = None ):
154- """
155- Scans the neighborhood for a Truck agent.
149+ """Scans the neighborhood for a Truck agent.
156150 Returns the nearest Truck agent or None.
151+
157152 Args:
158153 radius (int, optional): limit search to this distance. None = global.
159154 """
@@ -184,8 +179,7 @@ def get_dist(t):
184179
185180
186181class Truck (CellAgent ):
187- """
188- A delivery agent that distributes supplies to Beneficiaries.
182+ """A delivery agent that distributes supplies to Beneficiaries.
189183
190184 Behavior:
191185 - Scans for beneficiaries with high needs.
@@ -206,7 +200,6 @@ def __init__(self, model, cell):
206200
207201 def distribute_aid (self , beneficiary , amount = 10 ):
208202 """Split aid proportionally to need intensity"""
209-
210203 total_need = beneficiary .water_urgency + beneficiary .food_urgency
211204
212205 if total_need == 0 :
@@ -231,9 +224,7 @@ def distribute_aid(self, beneficiary, amount=10):
231224 return water_satisfied + food_satisfied
232225
233226 def move_towards (self , target_pos ):
234- """
235- Moves the agent one step closer to the target position.
236- """
227+ """Moves the agent one step closer to the target position."""
237228 current_x , current_y = self .cell .coordinate
238229 target_x , target_y = target_pos
239230
@@ -255,8 +246,7 @@ def get_distance(self, pos):
255246 return abs (x1 - x2 ) + abs (y1 - y2 )
256247
257248 def step (self ):
258- """
259- Advance the truck by one step.
249+ """Advance the truck by one step.
260250
261251 Lifecycle:
262252 1. Logistics: Refill if empty.
0 commit comments