Here is a Python script I wrote to randomly generate a map rotation for our Call of Duty: World at War server. It outputs the “set sv_mapRotation” line that you should copy & paste into your server’s config file. Our gaming clan mainly plays TDM, but we got a second server to try out the other objective-based game types. Not knowing which map combinations were the best, I simply wrote a script to generate a random rotation of the non-TDM and non-DM gametypes. Unfortunately, I found out later that there is a 1024 character line length limit in the config file (boo!). So I later modified the script to observe this unfortunate limit. This means you can’t have very large map rotations.
Here are some notes about the script.
"""
map_rotate.py
Generate map rotation for COD:W@W.
25 June 2009 - Brian Neal
"""
import random
maps = """\
mp_airfield mp_asylum mp_castle mp_shrine mp_courtyard mp_dome mp_downfall
mp_hangar mp_kneedeep mp_makin mp_nachtfeuer mp_outskirts mp_roundhouse
mp_seelow mp_subway mp_suburban mp_makin_day
mp_docks mp_kwai mp_stalingrad
""".split()
gametypes = ('dom', 'koth', 'sab', 'sd', 'ctf', 'twar')
combos = []
for gametype in gametypes:
for map in maps:
combos.append((gametype, map))
random.shuffle(combos)
# There is a 1024 character limit for lines from the config file...damn.
s = 'set sv_mapRotation "'
for game in combos:
ss = 'gametype %s map %s ' % (game[0], game[1])
if len(s) + len(ss) > 1024:
break
s += ss
s = s.rstrip()
s += '"'
print s
Remember that the script is random, so you may get the same map back-to-back, and/or some maps may be missing due to the stupid 1024 character limit. I run it a few times, saving the result into a file, until I get one that looks good. If you are ambitious, you could modify it a bit to prevent these issues, although the code for doing something like that starts to get very complicated.
I hope some people find this useful!