[bfprog] autobalance
Forrest Thiessen
thiessen at cyberscapearena.com
Tue Jun 21 12:43:27 PDT 2005
Well, I was right--there is a MUCH better way to do this!
The playerManager object has a method that does all the work for you:
bf2.playerManager.getNumberOfPlayersInTeam(team)
--Forrest
Forrest Thiessen wrote:
>That's an interesting idea to balance based on score; seems like it
>might be unstable, though (lots of team switching) early in games, but
>then would stabilize later on. Maybe some hysteresis could be added to
>stabilize it, so that score-based switching only takes effect when the
>*difference* between the scores of the two teams exceeds some threshold?
>
>Python has hashes, just like Perl--it just calls them "dictionaries",
>instead, and uses slightly different syntax, but they are the same
>ever-useful animal. Here's a nasty-looking link to the documentation on
>how to use them:
> http://python.org/doc/2.3.5/tut/node7.html#SECTION007400000000000000000
>
>I haven't tried this (and haven't given it much thought, either, so
>there's probably a better way to to do it), but something like this
>probably does what you want:
>
>for player in bf2.playerManager.getPlayers():
> playerCount[player.getTeam()] += 1
>
>--Forrest
>
>
>ScratchMonkey wrote:
>
>
>
>>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.
>>_______________________________________________
>>BFProg mailing list
>>BFProg at lists.matureasskickers.net
>>http://lists.matureasskickers.net/mailman/listinfo/bfprog
>>
>>
>
>
>_______________________________________________
>BFProg mailing list
>BFProg at lists.matureasskickers.net
>http://lists.matureasskickers.net/mailman/listinfo/bfprog
>
>
More information about the BFProg
mailing list