Spaces:
Sleeping
Sleeping
File size: 2,092 Bytes
f72fde9 acb2712 f72fde9 046ac0f acb2712 f72fde9 acb2712 f72fde9 acb2712 046ac0f acb2712 046ac0f acb2712 f72fde9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | """Equal-split baseline: even share of the discretionary pool."""
from collections.abc import Iterable
from agents.base import PolicyAdapter
from agents.rule_based.discretionary import discretionary_pool
from agents.rule_based.voting import first_vote_target
from schemas.actions import (
Action,
ActionType,
DebateAction,
ProposeBudgetAction,
VoteAction,
VoteChoice,
)
from schemas.departments import DEFAULT_DEPARTMENT_NAMES
from schemas.observations import Observation
class EqualSplitAdapter(PolicyAdapter):
def __init__(self, department_count: int = len(DEFAULT_DEPARTMENT_NAMES)) -> None:
if department_count <= 0:
raise ValueError("department_count must be positive.")
self.department_count = department_count
def act(
self,
observation: Observation,
valid_actions: Iterable[str],
agent_id: str,
) -> Action:
valid_action_set = set(valid_actions)
if ActionType.PROPOSE_BUDGET.value in valid_action_set:
pool = discretionary_pool(observation)
share = pool / self.department_count
return ProposeBudgetAction(
type=ActionType.PROPOSE_BUDGET,
department=observation.own_department.name,
amount=share,
justification="Request an equal share of the discretionary treasury pool.",
)
vote_target = first_vote_target(observation.proposals, agent_id)
if ActionType.VOTE.value in valid_action_set and vote_target is not None:
return VoteAction(
type=ActionType.VOTE,
proposal_id=vote_target.proposal_id,
vote=VoteChoice.YES,
)
if ActionType.DEBATE.value in valid_action_set:
return DebateAction(
type=ActionType.DEBATE,
message=f"{agent_id} supports equal treasury distribution.",
)
return DebateAction(
type=ActionType.DEBATE,
message=f"{agent_id} (equal split) idle.",
)
|