2023-11-22 15:55:42 (UTC-03:00)
Marcel Rodrigues <marcelgmr@gmail.com>
bot: change strategy over time + other tweaks
diff --git a/yacht.lua b/yacht.lua index 3653be9..b8916bb 100644 --- a/yacht.lua +++ b/yacht.lua @@ -404,10 +404,24 @@ end function Bob:select(sheet, dice, roll) local sum, hist, min_count, max_count = calc_data(dice) + local round = 1 + for _, cat in ipairs(cats) do + if sheet[cat] ~= nil then + round = round + 1 + end + end + local min_fh, min_st, min_yt, min_rp, min_4k + if round <= 4 then + min_fh, min_st, min_yt, min_rp, min_4k = 3, 4, 4, 3, 3 + elseif round <= 8 then + min_fh, min_st, min_yt, min_rp, min_4k = 2, 3, 3, 2, 2 + else -- round > 8 + min_fh, min_st, min_yt, min_rp, min_4k = 1, 3, 3, 1, 1 + end local sel = {} if sheet["full-house"] == nil then local rep = {} - for i = 3, 6 do + for i = min_fh, 6 do if hist[i] >= 2 then table.insert(rep, i) end @@ -420,13 +434,6 @@ function Bob:select(sheet, dice, roll) return sel end end - if sheet["yacht"] == nil and max_count >= 4 then - for i = 1, 5 do - sel[i] = hist[dice[i]] >= 4 - end - log("yacht") - return sel - end if sheet["little-straight"] == nil or sheet["big-straight"] == nil then local little_match, big_match little_match = (hist[1] > 0) and 1 or 0 @@ -439,14 +446,14 @@ function Bob:select(sheet, dice, roll) end local cat if sheet["little-straight"] ~= nil then - if big_match >= 4 then + if big_match >= min_st then cat = "big-straight" end elseif sheet["big-straight"] ~= nil then - if little_match >= 4 then + if little_match >= min_st then cat = "little-straight" end - elseif math.max(big_match, little_match) >= 4 then + elseif math.max(big_match, little_match) >= min_st then if big_match > little_match then cat = "big-straight" else @@ -471,16 +478,22 @@ function Bob:select(sheet, dice, roll) return sel end end - if max_count >= 3 or sheet["choice"] ~= nil or sum < 12 then + if sheet["yacht"] == nil and max_count >= min_yt then + for i = 1, 5 do + sel[i] = hist[dice[i]] == max_count + end + log("yacht") + return sel + end + if max_count >= min_rp or sheet["choice"] ~= nil or sum < 12 then local d for i = 1, 6 do if hist[i] == max_count then d = i - break end end local cat = cats[d+6] - if sheet[cat] == nil or (sheet["four-of-a-kind"] == nil and d > 3) then + if sheet[cat] == nil or (sheet["four-of-a-kind"] == nil and d >= min_4k) then for i = 1, 5 do sel[i] = dice[i] == d end