diff --git a/ai/red/strategies.lua b/ai/red/strategies.lua index 6fea463..0cef655 100644 --- a/ai/red/strategies.lua +++ b/ai/red/strategies.lua @@ -25,6 +25,21 @@ local stats = Strategies.stats -- TIME CONSTRAINTS +local function timeForStats() + local timeBonus = (stats.nidoran.attack - 53) * 0.05 + if stats.nidoran.attack >= 55 then + timeBonus = timeBonus + 0.05 + end + + local maxSpeed = math.min(stats.nidoran.speed, 52) + timeBonus = timeBonus + (maxSpeed - 49) * 0.125 + + if stats.nidoran.special >= 45 then + timeBonus = timeBonus + 0.1 + end + return timeBonus +end + Strategies.timeRequirements = { bulbasaur = function() @@ -39,11 +54,9 @@ Strategies.timeRequirements = { return timeLimit end, - brock = function() - local timeLimit = 11 - if stats.nidoran.attack == 16 and stats.nidoran.speed == 15 and stats.nidoran.special == 13 then - timeLimit = timeLimit + 0.5 - end + shorts = function() + local timeLimit = 14 + timeLimit = timeLimit + (3 - stats.nidoran.rating) * 0.2 if Pokemon.inParty("spearow") then timeLimit = timeLimit + 0.5 end @@ -53,7 +66,7 @@ Strategies.timeRequirements = { mt_moon = function() local timeLimit = 26.75 if stats.nidoran.attack > 15 and stats.nidoran.speed > 14 then - timeLimit = timeLimit + 0.25 + timeLimit = timeLimit + 0.33 end if Pokemon.inParty("paras") then timeLimit = timeLimit + 0.75 @@ -70,7 +83,7 @@ Strategies.timeRequirements = { end, goldeen = function() - local timeLimit = 37.5 + local timeLimit = 37 + timeForStats() if Pokemon.inParty("paras") then timeLimit = timeLimit + 0.75 end @@ -78,7 +91,7 @@ Strategies.timeRequirements = { end, misty = function() - local timeLimit = 39.5 + local timeLimit = 39 + timeForStats() if Pokemon.inParty("paras") then timeLimit = timeLimit + 0.75 end @@ -86,25 +99,15 @@ Strategies.timeRequirements = { end, vermilion = function() - return 44 + return 43.5 + timeForStats() end, trash = function() - local timeLimit = 47 - if stats.nidoran.special > 44 then - timeLimit = timeLimit + 0.25 - end - if stats.nidoran.attack > 53 then - timeLimit = timeLimit + 0.25 - end - if stats.nidoran.attack >= 54 and stats.nidoran.special >= 45 then - timeLimit = timeLimit + 0.25 - end - return timeLimit + return 47 + timeForStats() end, safari_carbos = function() - return 70.5 + return 70 + timeForStats() end, victory_road = function() @@ -218,38 +221,51 @@ local strategyFunctions = Strategies.functions -- General -local function tweetBrock(statDiff) - if statDiff < 3 then - local timeLimit = Strategies.getTimeRequirement("brock") - if not Strategies.overMinute(timeLimit) then - Strategies.tweetProgress("On pace after Brock with a great Nidoran") +strategyFunctions.tweetAfterBrock = function() + if stats.nidoran.rating < 2 then + if not Strategies.overMinute("shorts") then + Strategies.updates.brock = true + Strategies.tweetProgress("On pace after Brock with a great Nidoran", "brock") end end + return true end strategyFunctions.tweetMisty = function() - if not Strategies.setYolo("misty") then + if not Strategies.updates.brock and not Strategies.setYolo("misty") then local timeLimit = Strategies.getTimeRequirement("misty") - if not Strategies.overMinute(timeLimit - 0.5) then + if not Strategies.overMinute(timeLimit - 0.25) then local pbn = "" if not Strategies.overMinute(timeLimit - 1) then pbn = " (PB pace)" end local elt = Utils.elapsedTime() - Strategies.tweetProgress("Got a run going, just beat Misty "..elt.." in"..pbn) + Strategies.tweetProgress("Got a run going, just beat Misty "..elt.." in"..pbn, "misty") end end return true end +strategyFunctions.tweetSurge = function() + if not Strategies.updates.misty and not Control.yolo then + local elt = Utils.elapsedTime() + local pbn = "" + if not Strategies.overMinute("surge") then + pbn = " (PB pace)" + end + Strategies.tweetProgress("Got a run going, just beat Surge "..elt.." in"..pbn, "surge") + end + return true +end + strategyFunctions.tweetVictoryRoad = function() local elt = Utils.elapsedTime() local pbn = "" - if not Strategies.overMinute(Strategies.getTimeRequirement("victory_road")) then + if not Strategies.overMinute("victory_road") then pbn = " (PB pace)" end local elt = Utils.elapsedTime() - Strategies.tweetProgress("Entering Victory Road at "..elt..pbn.." on our way to the Elite Four") + Strategies.tweetProgress("Entering Victory Road at "..elt..pbn.." on our way to the Elite Four", "victory") return true end @@ -286,7 +302,7 @@ strategyFunctions.fightBulbasaur = function() status.tries = status.tries + 1 end end - if Battle.isActive() and Memory.double("battle", "opponent_hp") > 0 and Strategies.resetTime(Strategies.getTimeRequirement("bulbasaur"), "kill Bulbasaur") then + if Battle.isActive() and Memory.double("battle", "opponent_hp") > 0 and Strategies.resetTime("bulbasaur", "kill Bulbasaur") then return true end return Strategies.buffTo("tail_whip", 6) @@ -2315,7 +2331,7 @@ strategyFunctions.champion = function() return Strategies.hardReset("Back to the grind - you can follow on Twitter for updates on our next good run! https://twitter.com/thepokebot") end if status.tries == 0 then - Strategies.tweetProgress("Beat Pokemon Red in "..status.canProgress.."!", true) + Strategies.tweetProgress("Beat Pokemon Red in "..status.canProgress.."!") if Strategies.seed then print("v"..VERSION..": "..Utils.frames().." frames, with seed "..Strategies.seed) print("Please save this seed number to share, if you would like proof of your run!") diff --git a/ai/strategies.lua b/ai/strategies.lua index cf35b3e..b2818a2 100644 --- a/ai/strategies.lua +++ b/ai/strategies.lua @@ -25,6 +25,7 @@ local status = {tries = 0, canProgress = nil, initialized = false} local stats = {} Strategies.status = status Strategies.stats = stats +Strategies.updates = {} Strategies.deepRun = false local strategyFunctions @@ -68,7 +69,7 @@ function Strategies.reset(reason, extra, wait) end resetMessage = resetMessage..separator.." "..reason if status.tweeted then - Strategies.tweetProgress(resetMessage, true) + Strategies.tweetProgress(resetMessage) end return Strategies.hardReset(resetMessage, extra, wait) end @@ -88,7 +89,10 @@ function Strategies.death(extra) end function Strategies.overMinute(min) - return Utils.igt() > min * 60 + if type(min) == "string" then + min = Strategies.getTimeRequirement(min) + end + return Utils.igt() > (min * 60) end function Strategies.resetTime(timeLimit, reason, once) @@ -125,9 +129,9 @@ end -- HELPERS -function Strategies.tweetProgress(message, finished) - if not finished then - status.tweeted = true +function Strategies.tweetProgress(message, progress) + if progress then + Strategies.updates[progress] = true message = message.." http://www.twitch.tv/thepokebot" end Bridge.tweet(message) @@ -890,8 +894,7 @@ Strategies.functions = { Control.moonEncounters = nil end - local timeLimit = Strategies.getTimeRequirement("mt_moon") - Strategies.resetTime(timeLimit, "complete Mt. Moon", true) + Strategies.resetTime("mt_moon", "complete Mt. Moon", true) return true end, @@ -976,6 +979,8 @@ function Strategies.softReset() Strategies.status = status stats = {} Strategies.stats = stats + Strategies.updates = {} + splitNumber, splitTime = 0, 0 resetting = nil Strategies.deepRun = false diff --git a/data/red/paths.lua b/data/red/paths.lua index e528222..24cdc75 100644 --- a/data/red/paths.lua +++ b/data/red/paths.lua @@ -68,7 +68,7 @@ local Paths = { -- Leaving Pewter City {2, {23,18}, {40,18}}, -- Route 3 - {14, {0,10}, {c="a",a="Route 3"}, {c="catchFlier"}, {c="pp",on=true}, {s="battleModeSet"}, {8,10}, {8,8}, {11,8}, {11,6}, {s="bugCatcher"}, {11,4}, {12,4}, {s="potion",hp=19}, {13,4}, {s="interact",dir="Right"}, {s="shortsKid"}, {13,5}, {s="potionBeforeCocoons"}, {18,5}, {s="interact",dir="Right"}, {s="swapHornAttack"}, {18,6}, {22,6}, {22,5}, {s="potion",hp=4}, {24,5}, {s="interact",dir="Down"}, {s="fightMetapod"}, {27,5}, {27,9}, {s="catchFlierBackup"}, {37,8}, {37,5}, {49,5}, {49,10}, {57,10}, {57,8}, {59,8}, {59,-1}}, + {14, {0,10}, {c="a",a="Route 3"}, {c="catchFlier"}, {c="pp",on=true}, {s="battleModeSet"}, {8,10}, {8,8}, {11,8}, {11,6}, {s="bugCatcher"}, {11,4}, {12,4}, {s="potion",hp=19}, {13,4}, {s="interact",dir="Right"}, {s="shortsKid"}, {s="tweetAfterBrock"}, {13,5}, {s="potionBeforeCocoons"}, {18,5}, {s="interact",dir="Right"}, {s="swapHornAttack"}, {18,6}, {22,6}, {22,5}, {s="potion",hp=4}, {24,5}, {s="interact",dir="Down"}, {s="fightMetapod"}, {27,5}, {27,9}, {s="catchFlierBackup"}, {37,8}, {37,5}, {49,5}, {49,10}, {57,10}, {57,8}, {59,8}, {59,-1}}, -- To the Center {15, {9,16}, {c="pp",on=false}, {12,16}, {12,6}, {11,6}, {11,5}}, -- PP up @@ -161,7 +161,7 @@ local Paths = { -- To Surge {5, {18,29}, {18,26}, {30,26}, {30,14}, {15,14}, {15,17}, {s="potionBeforeSurge"}, {s="swap",item="repel",dest=0,chain=true}, {s="teach",move="cut",poke="oddish",alt="paras",chain=true}, {s="teach",move="dig",poke="paras",alt="squirtle",chain=true}, {s="skill",move="cut",done=0x0D4D}, {15,20}, {12,20}, {12,19}}, -- Trashcans - {92, {4,17}, {c="a",a="Surge's Gym"}, {4,16}, {2,16}, {2,11}, {s="trashcans"}, {4,6}, {4,3}, {5,3}, {5,2}, {s="interact",dir="Up"}, {s="fightSurge"}, {s="split"}, {4,2}, {4,13}, {5,13}, {5,18}}, + {92, {4,17}, {c="a",a="Surge's Gym"}, {4,16}, {2,16}, {2,11}, {s="trashcans"}, {4,6}, {4,3}, {5,3}, {5,2}, {s="interact",dir="Up"}, {s="fightSurge"}, {s="split"}, {s="tweetSurge"}, {4,2}, {4,13}, {5,13}, {5,18}}, -- 8: SURGE @@ -360,6 +360,7 @@ local Paths = { -- F1 drop {165, {16,14}, {16,15}, {13,15}, {13,20}, {s="cinnabarCarbos"}, {21,23}}, -- B1 + --TODO menu cancel for RC {216, {23,22}, {23,15}, {21,15}, {s="item",item="super_repel",chain=true}, {s="item",item="carbos",poke="nidoking",close=true}, {17,15}, {17,19}, {18,19}, {18,23}, {17,23}, {17,26}, {18,26}, {s="confirm",dir="Up"}, {14,26}, {14,22}, {12,22}, {12,15}, {24,15}, {24,18}, {26,18}, {26,6}, {24,6}, {24,4}, {20,4}, {s="confirm",dir="Up"}, {24,4}, {24,6}, {12,6}, {12,2}, {11,2}, {s="interact",dir="Left"}, {12,2}, {12,7}, {4,7}, {4,9}, {2,9}, {s="interact",dir="Left"}, {5,9}, {5,10}, {s="teach",move="strength",poke="squirtle",replace="tackle",chain=true}, {s="item",item="rare_candy",amount=2,poke="nidoking",close=true}, {5,12}, {s="interact",dir="Down"}, {5,12}, {s="skill",move="dig",map=216}}, -- Celadon once again {6, {41,10}, {s="bicycle"}, {41,13}, {36,13}, {36,23}, {25,23}, {25,30}, {35,30}, {35,31}, {s="skill",move="cut",dir="Down",done=0x0D4D}, {35,34}, {5,34}, {5,29}, {12,29}, {12,27}},