[bfprog] autobalance
ScratchMonkey
ScratchMonkey at MatureAsskickers.net
Tue Jun 21 07:44:08 PDT 2005
Over on the Icculus server list was mention of a patch to
admin/standard_admin/autobalance.py to exclude squad members from the
autobalance decision:
diff -rw
bf2-linuxded-1.0.2442.0-ORIGINAL/admin/standard_admin/autobalance.py
bf2-linuxded-1.0.2442.0/admin/standard_admin/autobalance.py
35a36,40
> # Only balance with un-squadded players
> if p.isCommander(): return None
> if p.isSquadLeader(): return None
> if p.getSquadId() > 0: return None
>
I noticed in looking through the file that that balance policy is based on
player count, and that each routine separately counts players by iterating
over the player list. This seems like a good thing to factor. Any
pythonistas here who know an idiom for a routine that accumulates multiple
counts from some data and returns the collection? In Perl I'd accumulate
the team counts in a hash indexed by keys 'team1' and 'team2' and return a
reference to the hash. What's the Python equivalent?
I'd rather have a policy that balances based on score instead of team size.
If the weighted scores differ by more than some amount or ratio, the
balancer kicks in. That way one can always switch to the underdog team.
More information about the BFProg
mailing list