Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- behaviors/attack.py +4 -9
- behaviors/movement.py +4 -9
behaviors/attack.py
CHANGED
|
@@ -1822,7 +1822,6 @@ class ConflictBehavior(Behavior):
|
|
| 1822 |
class AttackBehavior(ConflictBehavior):
|
| 1823 |
"""Apply a generic attack or pressure effect to a target agent."""
|
| 1824 |
|
| 1825 |
-
name: ClassVar[str] = "attack"
|
| 1826 |
|
| 1827 |
def _check_preconditions(self, agent: Agent, world: WorldProtocol) -> bool:
|
| 1828 |
"""Check attack-specific preconditions."""
|
|
@@ -1971,15 +1970,12 @@ class AttackBehavior(ConflictBehavior):
|
|
| 1971 |
class HuntBehavior(AttackBehavior):
|
| 1972 |
"""Compatibility alias for model-generated hunting behavior."""
|
| 1973 |
|
| 1974 |
-
name: ClassVar[str] = "hunt"
|
| 1975 |
|
| 1976 |
|
| 1977 |
@dataclass(slots=True)
|
| 1978 |
class DefendBehavior(ConflictBehavior):
|
| 1979 |
"""Increase or set a defensive state value."""
|
| 1980 |
|
| 1981 |
-
name: ClassVar[str] = "defend"
|
| 1982 |
-
|
| 1983 |
def _check_preconditions(self, agent: Agent, world: WorldProtocol) -> bool:
|
| 1984 |
"""Check defend-specific preconditions."""
|
| 1985 |
|
|
@@ -2188,7 +2184,6 @@ class DefendBehavior(ConflictBehavior):
|
|
| 2188 |
class RaidBehavior(ConflictBehavior):
|
| 2189 |
"""Transfer assets from a target to the acting agent."""
|
| 2190 |
|
| 2191 |
-
name: ClassVar[str] = "raid"
|
| 2192 |
|
| 2193 |
def _check_preconditions(self, agent: Agent, world: WorldProtocol) -> bool:
|
| 2194 |
"""Check raid-specific preconditions."""
|
|
@@ -2510,10 +2505,10 @@ Raid = RaidBehavior
|
|
| 2510 |
|
| 2511 |
BEHAVIOR_REGISTRY: Mapping[str, type[Behavior]] = MappingProxyType(
|
| 2512 |
{
|
| 2513 |
-
|
| 2514 |
-
|
| 2515 |
-
|
| 2516 |
-
|
| 2517 |
}
|
| 2518 |
)
|
| 2519 |
|
|
|
|
| 1822 |
class AttackBehavior(ConflictBehavior):
|
| 1823 |
"""Apply a generic attack or pressure effect to a target agent."""
|
| 1824 |
|
|
|
|
| 1825 |
|
| 1826 |
def _check_preconditions(self, agent: Agent, world: WorldProtocol) -> bool:
|
| 1827 |
"""Check attack-specific preconditions."""
|
|
|
|
| 1970 |
class HuntBehavior(AttackBehavior):
|
| 1971 |
"""Compatibility alias for model-generated hunting behavior."""
|
| 1972 |
|
|
|
|
| 1973 |
|
| 1974 |
|
| 1975 |
@dataclass(slots=True)
|
| 1976 |
class DefendBehavior(ConflictBehavior):
|
| 1977 |
"""Increase or set a defensive state value."""
|
| 1978 |
|
|
|
|
|
|
|
| 1979 |
def _check_preconditions(self, agent: Agent, world: WorldProtocol) -> bool:
|
| 1980 |
"""Check defend-specific preconditions."""
|
| 1981 |
|
|
|
|
| 2184 |
class RaidBehavior(ConflictBehavior):
|
| 2185 |
"""Transfer assets from a target to the acting agent."""
|
| 2186 |
|
|
|
|
| 2187 |
|
| 2188 |
def _check_preconditions(self, agent: Agent, world: WorldProtocol) -> bool:
|
| 2189 |
"""Check raid-specific preconditions."""
|
|
|
|
| 2505 |
|
| 2506 |
BEHAVIOR_REGISTRY: Mapping[str, type[Behavior]] = MappingProxyType(
|
| 2507 |
{
|
| 2508 |
+
"attack": AttackBehavior,
|
| 2509 |
+
"hunt": HuntBehavior,
|
| 2510 |
+
"defend": DefendBehavior,
|
| 2511 |
+
"raid": RaidBehavior,
|
| 2512 |
}
|
| 2513 |
)
|
| 2514 |
|
behaviors/movement.py
CHANGED
|
@@ -1238,8 +1238,6 @@ class MovementBehavior(Behavior):
|
|
| 1238 |
class MoveBehavior(MovementBehavior):
|
| 1239 |
"""Move an agent by a delta, direction, or target position."""
|
| 1240 |
|
| 1241 |
-
name: ClassVar[str] = "move"
|
| 1242 |
-
|
| 1243 |
def _check_preconditions(self, agent: Agent, world: WorldProtocol) -> bool:
|
| 1244 |
"""Check whether the behavior has a movement specification and budget."""
|
| 1245 |
|
|
@@ -1393,7 +1391,6 @@ class MoveBehavior(MovementBehavior):
|
|
| 1393 |
class WanderBehavior(MovementBehavior):
|
| 1394 |
"""Move an agent in a random direction."""
|
| 1395 |
|
| 1396 |
-
name: ClassVar[str] = "wander"
|
| 1397 |
|
| 1398 |
def execute(self, agent: Agent, world: WorldProtocol) -> BehaviorResult:
|
| 1399 |
"""Execute random movement."""
|
|
@@ -1428,7 +1425,6 @@ class WanderBehavior(MovementBehavior):
|
|
| 1428 |
class SeekBehavior(MovementBehavior):
|
| 1429 |
"""Move an agent toward a target position, agent, or resource."""
|
| 1430 |
|
| 1431 |
-
name: ClassVar[str] = "seek"
|
| 1432 |
|
| 1433 |
def execute(self, agent: Agent, world: WorldProtocol) -> BehaviorResult:
|
| 1434 |
"""Execute seek movement."""
|
|
@@ -1494,7 +1490,6 @@ class SeekBehavior(MovementBehavior):
|
|
| 1494 |
class FleeBehavior(MovementBehavior):
|
| 1495 |
"""Move an agent away from a threat position, agent, or resource."""
|
| 1496 |
|
| 1497 |
-
name: ClassVar[str] = "flee"
|
| 1498 |
|
| 1499 |
def execute(self, agent: Agent, world: WorldProtocol) -> BehaviorResult:
|
| 1500 |
"""Execute flee movement."""
|
|
@@ -1577,10 +1572,10 @@ Flee = FleeBehavior
|
|
| 1577 |
|
| 1578 |
BEHAVIOR_REGISTRY: Mapping[str, type[Behavior]] = MappingProxyType(
|
| 1579 |
{
|
| 1580 |
-
|
| 1581 |
-
|
| 1582 |
-
|
| 1583 |
-
|
| 1584 |
}
|
| 1585 |
)
|
| 1586 |
|
|
|
|
| 1238 |
class MoveBehavior(MovementBehavior):
|
| 1239 |
"""Move an agent by a delta, direction, or target position."""
|
| 1240 |
|
|
|
|
|
|
|
| 1241 |
def _check_preconditions(self, agent: Agent, world: WorldProtocol) -> bool:
|
| 1242 |
"""Check whether the behavior has a movement specification and budget."""
|
| 1243 |
|
|
|
|
| 1391 |
class WanderBehavior(MovementBehavior):
|
| 1392 |
"""Move an agent in a random direction."""
|
| 1393 |
|
|
|
|
| 1394 |
|
| 1395 |
def execute(self, agent: Agent, world: WorldProtocol) -> BehaviorResult:
|
| 1396 |
"""Execute random movement."""
|
|
|
|
| 1425 |
class SeekBehavior(MovementBehavior):
|
| 1426 |
"""Move an agent toward a target position, agent, or resource."""
|
| 1427 |
|
|
|
|
| 1428 |
|
| 1429 |
def execute(self, agent: Agent, world: WorldProtocol) -> BehaviorResult:
|
| 1430 |
"""Execute seek movement."""
|
|
|
|
| 1490 |
class FleeBehavior(MovementBehavior):
|
| 1491 |
"""Move an agent away from a threat position, agent, or resource."""
|
| 1492 |
|
|
|
|
| 1493 |
|
| 1494 |
def execute(self, agent: Agent, world: WorldProtocol) -> BehaviorResult:
|
| 1495 |
"""Execute flee movement."""
|
|
|
|
| 1572 |
|
| 1573 |
BEHAVIOR_REGISTRY: Mapping[str, type[Behavior]] = MappingProxyType(
|
| 1574 |
{
|
| 1575 |
+
"move": MoveBehavior,
|
| 1576 |
+
"wander": WanderBehavior,
|
| 1577 |
+
"seek": SeekBehavior,
|
| 1578 |
+
"flee": FleeBehavior,
|
| 1579 |
}
|
| 1580 |
)
|
| 1581 |
|