[INCLUDE: common/tyre_patterns.ini]

[]
@GENERATOR = $'
  local year = read("meta/year", 2000)
  local rnd = read("fixed_random/generic_rain_tyres_0", 1)  -- fixed random remains the same between runs for a given car, parameter used as a random seed

  function choose(list)
    for i = 1, #list - 1 do if rnd < list[i][1] then return list[i][2] end end
    return list[#list]
  end

  if year < 1980 then 
    return choose{ 
      {0.3, "TyresPattern_StyleRain80s"}, 
      "TyresPattern_StyleRain70s"
    }
  end

  if year < 1990 then 
    return choose{ 
      {0.1, "TyresPattern_StyleRain70s"}, 
      {0.2, "TyresPattern_StyleRainStrange"}, 
      {0.3, "TyresPattern_StyleF1RainMI"}, 
      "TyresPattern_StyleRain80s"
    }
  end

  if year < 2000 then 
    return choose{ 
      {0.2, "TyresPattern_StyleRainStrange"}, 
      {0.4, "TyresPattern_StyleF1RainMI"}, 
      {0.6, "TyresPattern_StyleF1RainBS"}, 
      "TyresPattern_StyleRain80s"
    }
  end

  if read("meta/open_wheeler", false) then
    return choose{ 
      {0.2, "TyresPattern_StyleF1RainMI"}, 
      {0.4, "TyresPattern_StyleF1RainBS"}, 
      {0.5, "TyresPattern_StyleRainRace"}, 
      "TyresPattern_StyleRainF1"
    }
  end

  return choose{ 
    {0.15, "TyresPattern_StyleRainStrange"}, 
    {0.30, "TyresPattern_StyleF1RainMI"}, 
    {0.45, "TyresPattern_StyleF1RainBS"}, 
    {0.60, "TyresPattern_StyleRain80s"}, 
    {0.75, "TyresPattern_StyleRainRace"}, 
    "TyresPattern_StyleRainF1"
  }
'

