defaultData = ["AFRICA",
  "AGENT",
  "AIR",
  "ALIEN",
  "ALPS",
  "AMAZON",
  "AMBULANCE",
  "AMERICA",
  "ANGEL",
  "ANTARCTICA",
  "APPLE",
  "ARM",
  "ATLANTIS",
  "AUSTRALIA",
  "AZTEC",
  "BACK",
  "BALL",
  "BAND",
  "BANK",
  "BAR",
  "BARK",
  "BAT",
  "BATTERY",
  "BEACH",
  "BEAR",
  "BEAT",
  "BED",
  "BEIJING",
  "BELL",
  "BELT",
  "BERLIN",
  "BERMUDA",
  "BERRY",
  "BILL",
  "BLOCK",
  "BOARD",
  "BOLT",
  "BOMB",
  "BOND",
  "BOOM",
  "BOOT",
  "BOTTLE",
  "BOW",
  "BOX",
  "BRIDGE",
  "BRUSH",
  "BUCK",
  "BUFFALO",
  "BUG",
  "BUGLE",
  "BUTTON",
  "CALF",
  "CANADA",
  "CAP",
  "CAPITAL",
  "CAR",
  "CARD",
  "CARROT",
  "CASINO",
  "CAST",
  "CAT",
  "CELL",
  "CENTAUR",
  "CENTER",
  "CHAIR",
  "CHANGE",
  "CHARGE",
  "CHECK",
  "CHEST",
  "CHICK",
  "CHINA",
  "CHOCOLATE",
  "CHURCH",
  "CIRCLE",
  "CLIFF",
  "CLOAK",
  "CLUB",
  "CODE",
  "COLD",
  "COMIC",
  "COMPOUND",
  "CONCERT",
  "CONDUCTOR",
  "CONTRACT",
  "COOK",
  "COPPER",
  "COTTON",
  "COURT",
  "COVER",
  "CRANE",
  "CRASH",
  "CRICKET",
  "CROSS",
  "CROWN",
  "CYCLE",
  "CZECH",
  "DANCE",
  "DATE",
  "DAY",
  "DEATH",
  "DECK",
  "DEGREE",
  "DIAMOND",
  "DICE",
  "DINOSAUR",
  "DISEASE",
  "DOCTOR",
  "DOG",
  "DRAFT",
  "DRAGON",
  "DRESS",
  "DRILL",
  "DROP",
  "DUCK",
  "DWARF",
  "EAGLE",
  "EGYPT",
  "EMBASSY",
  "ENGINE",
  "ENGLAND",
  "EUROPE",
  "EYE",
  "FACE",
  "FAIR",
  "FALL",
  "FAN",
  "FENCE",
  "FIELD",
  "FIGHTER",
  "FIGURE",
  "FILE",
  "FILM",
  "FIRE",
  "FISH",
  "FLUTE",
  "FLY",
  "FOOT",
  "FORCE",
  "FOREST",
  "FORK",
  "FRANCE",
  "GAME",
  "GAS",
  "GENIUS",
  "GERMANY",
  "GHOST",
  "GIANT",
  "GLASS",
  "GLOVE",
  "GOLD",
  "GRACE",
  "GRASS",
  "GREECE",
  "GREEN",
  "GROUND",
  "HAM",
  "HAND",
  "HAWK",
  "HEAD",
  "HEART",
  "HELICOPTER",
  "HIMALAYAS",
  "HOLE",
  "HOLLYWOOD",
  "HONEY",
  "HOOD",
  "HOOK",
  "HORN",
  "HORSE",
  "HORSESHOE",
  "HOSPITAL",
  "HOTEL",
  "ICE",
  "ICE CREAM",
  "INDIA",
  "IRON",
  "IVORY",
  "JACK",
  "JAM",
  "JET",
  "JUPITER",
  "KANGAROO",
  "KETCHUP",
  "KEY",
  "KID",
  "KING",
  "KIWI",
  "KNIFE",
  "KNIGHT",
  "LAB",
  "LAP",
  "LASER",
  "LAWYER",
  "LEAD",
  "LEMON",
  "LEPRECHAUN",
  "LIFE",
  "LIGHT",
  "LIMOUSINE",
  "LINE",
  "LINK",
  "LION",
  "LITTER",
  "LOCH NESS",
  "LOCK",
  "LOG",
  "LONDON",
  "LUCK",
  "MAIL",
  "MAMMOTH",
  "MAPLE",
  "MARBLE",
  "MARCH",
  "MASS",
  "MATCH",
  "MERCURY",
  "MEXICO",
  "MICROSCOPE",
  "MILLIONAIRE",
  "MINE",
  "MINT",
  "MISSILE",
  "MODEL",
  "MOLE",
  "MOON",
  "MOSCOW",
  "MOUNT",
  "MOUSE",
  "MOUTH",
  "MUG",
  "NAIL",
  "NEEDLE",
  "NET",
  "NEW YORK",
  "NIGHT",
  "NINJA",
  "NOTE",
  "NOVEL",
  "NURSE",
  "NUT",
  "OCTOPUS",
  "OIL",
  "OLIVE",
  "OLYMPUS",
  "OPERA",
  "ORANGE",
  "ORGAN",
  "PALM",
  "PAN",
  "PANTS",
  "PAPER",
  "PARACHUTE",
  "PARK",
  "PART",
  "PASS",
  "PASTE",
  "PENGUIN",
  "PHOENIX",
  "PIANO",
  "PIE",
  "PILOT",
  "PIN",
  "PIPE",
  "PIRATE",
  "PISTOL",
  "PIT",
  "PITCH",
  "PLANE",
  "PLASTIC",
  "PLATE",
  "PLATYPUS",
  "PLAY",
  "PLOT",
  "POINT",
  "POISON",
  "POLE",
  "POLICE",
  "POOL",
  "PORT",
  "POST",
  "POUND",
  "PRESS",
  "PRINCESS",
  "PUMPKIN",
  "PUPIL",
  "PYRAMID",
  "QUEEN",
  "RABBIT",
  "RACKET",
  "RAY",
  "REVOLUTION",
  "RING",
  "ROBIN",
  "ROBOT",
  "ROCK",
  "ROME",
  "ROOT",
  "ROSE",
  "ROULETTE",
  "ROUND",
  "ROW",
  "RULER",
  "SATELLITE",
  "SATURN",
  "SCALE",
  "SCHOOL",
  "SCIENTIST",
  "SCORPION",
  "SCREEN",
  "SCUBA DIVER",
  "SEAL",
  "SERVER",
  "SHADOW",
  "SHAKESPEARE",
  "SHARK",
  "SHIP",
  "SHOE",
  "SHOP",
  "SHOT",
  "SINK",
  "SKYSCRAPER",
  "SLIP",
  "SLUG",
  "SMUGGLER",
  "SNOW",
  "SNOWMAN",
  "SOCK",
  "SOLDIER",
  "SOUL",
  "SOUND",
  "SPACE",
  "SPELL",
  "SPIDER",
  "SPIKE",
  "SPINE",
  "SPOT",
  "SPRING",
  "SPY",
  "SQUARE",
  "STADIUM",
  "STAFF",
  "STAR",
  "STATE",
  "STICK",
  "STOCK",
  "STRAW",
  "STREAM",
  "STRIKE",
  "STRING",
  "SUB",
  "SUIT",
  "SUPERHERO",
  "SWING",
  "SWITCH",
  "TABLE",
  "TABLET",
  "TAG",
  "TAIL",
  "TAP",
  "TEACHER",
  "TELESCOPE",
  "TEMPLE",
  "THEATER",
  "THIEF",
  "THUMB",
  "TICK",
  "TIE",
  "TIME",
  "TOKYO",
  "TOOTH",
  "TORCH",
  "TOWER",
  "TRACK",
  "TRAIN",
  "TRIANGLE",
  "TRIP",
  "TRUNK",
  "TUBE",
  "TURKEY",
  "UNDERTAKER",
  "UNICORN",
  "VACUUM",
  "VAN",
  "VET",
  "WAKE",
  "WALL",
  "WAR",
  "WASHER",
  "WASHINGTON",
  "WATCH",
  "WATER",
  "WAVE",
  "WEB",
  "WELL",
  "WHALE",
  "WHIP",
  "WIND",
  "WITCH",
  "WORM",
  "YARD"
];

width = 256
chunks = 6
digits = 52
startdenom = width**chunks
significance = 2**digits
overflow = significance * 2
mask = width - 1

class ARC4:
  def __init__(self, key):
    if not key: key = [0]
    
    self.i = self.j = 0
    self.s = list(range(width)) 
    
    j = 0
    for i in range(width):
      j = mask & (j + key[i % len(key)] + self.s[i])
      self.s[i], self.s[j] = self.s[j], self.s[i]

    self.g(width)

  def g(self, count):
    r = 0

    for x in range(count):
      self.i = mask & (self.i + 1)
      self.j = mask & (self.j + self.s[self.i])
      self.s[self.i], self.s[self.j] = self.s[self.j], self.s[self.i]
      r = r * width + self.s[mask & (self.s[self.i] + self.s[self.j])]

    return r

def mixkey(seed):
  smear = 0
  key = [0] * min(width, len(seed))
  for j in range(len(seed)):
    smear ^= key[mask & j] * 19
    key[mask & j] = mask & (smear + ord(seed[j]))
  return key

class SeedRandom:
  def __init__(self, seed):
    key = mixkey(seed)
    self.arc4 = ARC4(key)

  def random(self):
    n = self.arc4.g(chunks)
    d = startdenom
    x = 0

    while n < significance:
      n = (n+x) * width
      d *= width
      x = self.arc4.g(1)

    while n >= overflow:
      n /= 2
      d /= 2
      x >>= 1

    return float((n+x)) / d


NUMBER_OF_WORDS = 25
COLOR_RED = "#ff0000"
COLOR_YELLOW = "#ffff00"
COLOR_BLUE = "#00eeee"
COLOR_BLACK = "#808080"
COLOR_GREEN = "#009000"

def shuffle(array, rnd):
  currentIndex = len(array)

  while currentIndex:
    randomIndex = int(rnd.random() * currentIndex);
    currentIndex -= 1
    array[currentIndex],array[randomIndex] = array[randomIndex],array[currentIndex]
    

def createNewGame(seed):
  rnd = SeedRandom(seed.lower())
  sessionData = defaultData[:]
  wordsSelected = []
  teams = []

  for i in range(NUMBER_OF_WORDS):
    randomIndex = int(rnd.random() * len(sessionData))
    wordsSelected.append(sessionData.pop(randomIndex))

  for i in range(8):
    teams.append(COLOR_RED)
    teams.append(COLOR_BLUE)

  ret = ""
  if (int(rnd.random() * 980) % 2 == 0):
    ret = COLOR_RED + ",";
    teams.append(COLOR_RED);
  else:
    ret = COLOR_BLUE + ",";
    teams.append(COLOR_BLUE);
 
  for i in range(7):
    teams.append(COLOR_YELLOW)

  teams.append(COLOR_BLACK)

  shuffle(teams, rnd);

  for i in range(NUMBER_OF_WORDS):
    ret = ret + wordsSelected[i] + ",";
  for i in range(NUMBER_OF_WORDS):
    ret = ret + teams[i] + ",";
  
  return ret;