diff --git a/ai/strategies.lua b/ai/strategies.lua index 09a6181..1c532dc 100644 --- a/ai/strategies.lua +++ b/ai/strategies.lua @@ -28,9 +28,29 @@ local deepRun, resetting local level4Nidoran = true -- 57 vs 96 (d39) local yolo, riskGiovanni, maxEtherSkip --- Reset cutoff times +-- TIME CONSTRAINTS local timeRequirements = { + + nidoran = function() + local timeLimit = 6.25 + if (pokemon.inParty("spearow")) then + timeLimit = timeLimit + 0.67 + end + return timeLimit + end, + + mt_moon = function() + local timeLimit = 27 + if (nidoAttack > 15 and nidoSpeed > 14) then + timeLimit = timeLimit + 0.25 + end + if (pokemon.inParty("paras")) then + timeLimit = timeLimit + 0.75 + end + return timeLimit + end, + mankey = function() local timeLimit = 33 if (pokemon.inParty("paras")) then @@ -86,14 +106,7 @@ local timeRequirements = { end, } --- Reset - -local function initialize() - if (not initialized) then - initialized = true - return true - end -end +-- RISK/RESET local function hardReset(message, extra) resetting = true @@ -182,7 +195,14 @@ local function setYolo(name) return yolo end --- Local functions +-- PRIVATE + +local function initialize() + if (not initialized) then + initialized = true + return true + end +end local function hasHealthFor(opponent, extra) if (not extra) then @@ -505,7 +525,7 @@ strategyFunctions = { end, split = function(data) - bridge.split(control.encounters(), data and data.finished) + bridge.split(data and data.finished) return true end, @@ -848,10 +868,8 @@ strategyFunctions = { end noDSum = true end - local timeLimit = 6.25 - if (pokemon.inParty("spearow")) then - timeLimit = timeLimit + 0.67 - end + + local timeLimit = getTimeRequirement("nidoran") local resetMessage if (hasNidoran) then resetMessage = "get an experience kill before Brock" @@ -1058,6 +1076,9 @@ strategyFunctions = { if (def < 12) then statDiff = statDiff + 1 end + if (level4Nidoran) then + statDiff = statDiff - 1 + end local resets = att < 15 or spd < 14 or scl < 12 or statDiff > 3 if (not resets and att == 15 and spd == 14) then resets = true @@ -1091,7 +1112,7 @@ strategyFunctions = { superlative = " min stat" exclaim = "." end - nStatus = "Beat Brock with a"..superlative.." Nidoran"..exclaim.." "..nStatus + nStatus = "Beat Brock with a"..superlative.." Nidoran"..exclaim.." "..nStatus..", caught at lv. "..(level4Nidoran and "4" or "3") bridge.chat(nStatus) else tries = tries + 1 @@ -1322,13 +1343,7 @@ strategyFunctions = { strategies.moonEncounters = nil end - local timeLimit = 26 - if (nidoAttack > 15 and nidoSpeed > 14) then - timeLimit = timeLimit + 0.25 - end - if (pokemon.inParty("paras")) then - timeLimit = timeLimit + 1.0 - end + local timeLimit = getTimeRequirement("mt_moon") resetTime(timeLimit, "complete Mt. Moon", true) return true end, @@ -1680,6 +1695,7 @@ strategyFunctions = { return true end setYolo("trash") + local prefix local suffix = "!" if (tries < 2) then diff --git a/main.lua b/main.lua index e0b5203..e0124d5 100644 --- a/main.lua +++ b/main.lua @@ -1,4 +1,4 @@ --- Customization settings +-- SETTINGS GAME_NAME = "red" -- Only currently supported option RESET_FOR_TIME = true -- Set to false if you just want to see the bot finish a run @@ -6,7 +6,7 @@ RESET_FOR_TIME = true -- Set to false if you just want to see the bot finish a r local CUSTOM_SEED = nil -- Set to a known seed to replay it, or leave nil for random runs local PAINT_ON = true -- Display contextual information while the bot runs --- Start code (hard hats on) +-- START CODE (hard hats on) local START_WAIT = 99 local VERSION = "1.1" diff --git a/util/memory.lua b/util/memory.lua index 4923692..308b751 100644 --- a/util/memory.lua +++ b/util/memory.lua @@ -1,4 +1,9 @@ -local memory = {} +local Memory = {} + +-- memory.usememorydomain("ROM") +-- print(memory.getcurrentmemorydomain()) +-- print(memory.getcurrentmemorydomainsize()) +-- memory.usememorydomain("System Bus") local memoryNames = { setting = { @@ -53,7 +58,6 @@ local memoryNames = { exp3 = 0xD17B, }, battle = { - confused = 0x106B, turns = 0x1067, text = 0x1125, menu = 0x0C50, @@ -104,11 +108,11 @@ local doubleNames = { } local function raw(value) - return mainmemory.readbyte(value) + return memory.readbyte(value) end -memory.raw = raw +Memory.raw = raw -function memory.string(first, last) +function Memory.string(first, last) local a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ():;[]abcdefghijklmnopqrstuvwxyz?????????????????????????????????????????-???!.????????*?/.?0123456789" local str = "" while first <= last do @@ -122,12 +126,12 @@ function memory.string(first, last) return str end -function memory.double(section, key) +function Memory.double(section, key) local first = doubleNames[section][key] return raw(first) + raw(first + 1) end -function memory.value(section, key) +function Memory.value(section, key) local memoryAddress = memoryNames[section] if (key) then memoryAddress = memoryAddress[key] @@ -135,4 +139,4 @@ function memory.value(section, key) return raw(memoryAddress) end -return memory +return Memory diff --git a/util/utils.lua b/util/utils.lua index e3a39c2..af87e2e 100644 --- a/util/utils.lua +++ b/util/utils.lua @@ -32,6 +32,7 @@ function utils.match(needle, haystack) return true end end + return false end function utils.key(needle, haystack) @@ -40,6 +41,7 @@ function utils.key(needle, haystack) return key end end + return nil end function utils.igt()