Refactor stats storage, increase Misty potion risking

This commit is contained in:
Kyle Coburn 2015-04-07 14:35:50 -07:00
parent 029db5e8f2
commit bf42c278a7
3 changed files with 65 additions and 53 deletions

View File

@ -18,12 +18,10 @@ local Utils = require "util.utils"
local Inventory = require "storage.inventory" local Inventory = require "storage.inventory"
local Pokemon = require "storage.pokemon" local Pokemon = require "storage.pokemon"
local level4Nidoran = true -- 57 vs 96 (d39)
local nidoAttack, nidoSpeed, nidoSpecial = 0, 0, 0
local squirtleAtt, squirtleDef, squirtleSpd, squirtleScl
local riskGiovanni, maxEtherSkip local riskGiovanni, maxEtherSkip
local status = Strategies.status local status = Strategies.status
local stats = Strategies.stats
-- TIME CONSTRAINTS -- TIME CONSTRAINTS
@ -38,6 +36,8 @@ Strategies.timeRequirements = {
if Pokemon.inParty("spearow") then if Pokemon.inParty("spearow") then
timeLimit = timeLimit + 0.67 timeLimit = timeLimit + 0.67
end end
if stats.nidoran.attack == 16 and stats.nidoran.speed > 14 then
return timeLimit return timeLimit
end, end,
@ -51,7 +51,7 @@ Strategies.timeRequirements = {
mt_moon = function() mt_moon = function()
local timeLimit = 26.75 local timeLimit = 26.75
if nidoAttack > 15 and nidoSpeed > 14 then if stats.nidoran.attack > 15 and stats.nidoran.speed > 14 then
timeLimit = timeLimit + 0.25 timeLimit = timeLimit + 0.25
end end
if Pokemon.inParty("paras") then if Pokemon.inParty("paras") then
@ -90,13 +90,13 @@ Strategies.timeRequirements = {
trash = function() trash = function()
local timeLimit = 47 local timeLimit = 47
if nidoSpecial > 44 then if stats.nidoran.special > 44 then
timeLimit = timeLimit + 0.25 timeLimit = timeLimit + 0.25
end end
if nidoAttack > 53 then if stats.nidoran.attack > 53 then
timeLimit = timeLimit + 0.25 timeLimit = timeLimit + 0.25
end end
if nidoAttack >= 54 and nidoSpecial >= 45 then if stats.nidoran.attack >= 54 and stats.nidoran.special >= 45 then
timeLimit = timeLimit + 0.25 timeLimit = timeLimit + 0.25
end end
return timeLimit return timeLimit
@ -234,12 +234,14 @@ end
strategyFunctions.fightBulbasaur = function() strategyFunctions.fightBulbasaur = function()
if status.tries < 9000 and Pokemon.index(0, "level") == 6 then if status.tries < 9000 and Pokemon.index(0, "level") == 6 then
if status.tries > 200 then if status.tries > 200 then
squirtleAtt = Pokemon.index(0, "attack") stats.squirtle = {
squirtleDef = Pokemon.index(0, "defense") attack = Pokemon.index(0, "attack"),
squirtleSpd = Pokemon.index(0, "speed") defense = Pokemon.index(0, "defense"),
squirtleScl = Pokemon.index(0, "special") speed = Pokemon.index(0, "speed"),
if squirtleAtt < 11 and squirtleScl < 12 then special = Pokemon.index(0, "special"),
return Strategies.reset("Bad Squirtle - "..squirtleAtt.." attack, "..squirtleScl.." special") }
if stats.squirtle.attack < 11 and stats.squirtle.special < 12 then
return Strategies.reset("Bad Squirtle - "..stats.squirtle.attack.." attack, "..stats.squirtle.special.." special")
end end
status.tries = 9001 status.tries = 9001
else else
@ -302,7 +304,7 @@ strategyFunctions.catchNidoran = function()
end end
end end
if gotExperience then if gotExperience then
level4Nidoran = Pokemon.info("nidoran", "level") == 4 stats.nidoran = {level4 = (Pokemon.info("nidoran", "level") == 4)}
return true return true
end end
noDSum = true noDSum = true
@ -513,12 +515,16 @@ strategyFunctions.fightBrock = function()
local spd = Pokemon.index(nidx, "speed") local spd = Pokemon.index(nidx, "speed")
local scl = Pokemon.index(nidx, "special") local scl = Pokemon.index(nidx, "special")
Bridge.stats(att.." "..def.." "..spd.." "..scl) Bridge.stats(att.." "..def.." "..spd.." "..scl)
nidoAttack = att stats.nidoran = {
nidoSpeed = spd attack = att,
nidoSpecial = scl defense = def,
speed = spd,
special = scl,
level4 = stats.nidoran.level4
}
if status.tries > 300 then if status.tries > 300 then
local statDiff = (16 - att) + (15 - spd) + (13 - scl) local statDiff = (16 - att) + (15 - spd) + (13 - scl)
if not level4Nidoran then if not stats.nidoran.level4 then
statDiff = statDiff + 1 statDiff = statDiff + 1
end end
local resets = att < 15 or spd < 14 or scl < 12 or (att == 15 and spd == 14) local resets = att < 15 or spd < 14 or scl < 12 or (att == 15 and spd == 14)
@ -561,7 +567,7 @@ strategyFunctions.fightBrock = function()
superlative = " min stat" superlative = " min stat"
exclaim = "." exclaim = "."
end end
nStatus = "Beat Brock with a"..superlative.." Nidoran"..exclaim.." "..nStatus..", caught at level "..(level4Nidoran and "4" or "3").."." nStatus = "Beat Brock with a"..superlative.." Nidoran"..exclaim.." "..nStatus..", caught at level "..(stats.nidoran.level4 and "4" or "3").."."
Bridge.chat(nStatus) Bridge.chat(nStatus)
else else
status.tries = status.tries + 1 status.tries = status.tries + 1
@ -614,7 +620,7 @@ strategyFunctions.bugCatcher = function()
end end
secondCaterpie = status.tempDir secondCaterpie = status.tempDir
if not isWeedle and secondCaterpie then if not isWeedle and secondCaterpie then
if level4Nidoran and nidoSpeed >= 14 and Pokemon.index(0, "attack") >= 19 then if stats.nidoran.level4 and stats.nidoran.speed >= 14 and Pokemon.index(0, "attack") >= 19 then
-- print("IA "..Pokemon.index(0, "attack")) -- print("IA "..Pokemon.index(0, "attack"))
Battle.automate() Battle.automate()
return return
@ -651,7 +657,7 @@ strategyFunctions.shortsKid = function()
end end
strategyFunctions.potionBeforeCocoons = function() strategyFunctions.potionBeforeCocoons = function()
if nidoSpeed >= 15 then if stats.nidoran.speed >= 15 then
return true return true
end end
return Strategies.functions.potion({hp=6, yolo=3}) return Strategies.functions.potion({hp=6, yolo=3})
@ -750,9 +756,13 @@ strategyFunctions.teachThrash = function()
local spd = Pokemon.index(0, "speed") local spd = Pokemon.index(0, "speed")
local scl = Pokemon.index(0, "special") local scl = Pokemon.index(0, "special")
local statDesc = att.." "..def.." "..spd.." "..scl local statDesc = att.." "..def.." "..spd.." "..scl
nidoAttack = att stats.nidoran = {
nidoSpeed = spd attack = att,
nidoSpecial = scl defense = def,
speed = spd,
special = scl,
level4 = stats.nidoran.level4
}
Bridge.stats(statDesc) Bridge.stats(statDesc)
print(statDesc) print(statDesc)
return true return true
@ -830,16 +840,18 @@ end
strategyFunctions.potionBeforeMisty = function() strategyFunctions.potionBeforeMisty = function()
local healAmount = 70 local healAmount = 70
local hasEnoughAttack = stats.nidoran.attack >= (yolo and 52 or 53)
local canSpeedTie = stats.nidoran.speed > 50
if Control.yolo then if Control.yolo then
if nidoAttack > 53 and nidoSpeed > 50 then if hasEnoughAttack and hasEnoughSpeed then
healAmount = 45 healAmount = 45
elseif nidoAttack > 53 then elseif hasEnoughAttack or canSpeedTie then
healAmount = 65 healAmount = 65
end end
else else
if nidoAttack > 53 and nidoSpeed > 51 then -- RISK if hasEnoughAttack and stats.nidoran.speed > 51 then
healAmount = 45 healAmount = 45
elseif nidoAttack > 53 and nidoSpeed > 50 then elseif hasEnoughAttack and canSpeedTie then
healAmount = 65 healAmount = 65
end end
end end
@ -890,7 +902,7 @@ strategyFunctions.potionBeforeRocket = function()
if Control.yolo then if Control.yolo then
minAttack = minAttack - 1 minAttack = minAttack - 1
end end
if nidoAttack >= minAttack then if stats.nidoran.attack >= minAttack then
return true return true
end end
return Strategies.functions.potion({hp=10}) return Strategies.functions.potion({hp=10})
@ -1242,7 +1254,7 @@ strategyFunctions.shopBuffs = function()
if Control.yolo then if Control.yolo then
minSpecial = minSpecial - 1 minSpecial = minSpecial - 1
end end
if nidoAttack >= 54 and nidoSpecial >= minSpecial then if stats.nidoran.attack >= 54 and stats.nidoran.special >= minSpecial then
riskGiovanni = true riskGiovanni = true
print("Giovanni skip strats!") print("Giovanni skip strats!")
end end
@ -1251,7 +1263,7 @@ strategyFunctions.shopBuffs = function()
local xspecAmt = 4 local xspecAmt = 4
if riskGiovanni then if riskGiovanni then
xspecAmt = xspecAmt + 1 xspecAmt = xspecAmt + 1
elseif nidoSpecial < 46 then elseif stats.nidoran.special < 46 then
-- xspecAmt = xspecAmt - 1 -- xspecAmt = xspecAmt - 1
end end
return Shop.transaction{ return Shop.transaction{
@ -1304,7 +1316,7 @@ strategyFunctions.lavenderRival = function()
if Battle.isActive() then if Battle.isActive() then
status.canProgress = true status.canProgress = true
local forced local forced
if nidoSpecial > 44 then -- RISK if stats.nidoran.special > 44 then -- RISK
local __, enemyTurns = Combat.enemyAttack() local __, enemyTurns = Combat.enemyAttack()
if enemyTurns and enemyTurns < 2 and Pokemon.isOpponent("pidgeotto", "gyarados") then if enemyTurns and enemyTurns < 2 and Pokemon.isOpponent("pidgeotto", "gyarados") then
Battle.automate() Battle.automate()
@ -1398,10 +1410,7 @@ strategyFunctions.safariCarbos = function()
Strategies.setYolo("safari_carbos") Strategies.setYolo("safari_carbos")
end end
local minSpeed = 50 local minSpeed = 50
if Control.yolo then if stats.nidoran.speed >= minSpeed then
minSpeed = minSpeed - 1
end
if nidoSpeed >= minSpeed then
return true return true
end end
if Inventory.contains("carbos") then if Inventory.contains("carbos") then
@ -1453,7 +1462,7 @@ end
strategyFunctions.fightSilphMachoke = function() strategyFunctions.fightSilphMachoke = function()
if Battle.isActive() then if Battle.isActive() then
status.canProgress = true status.canProgress = true
if nidoSpecial > 44 then if stats.nidoran.special > 44 then
return Strategies.prepare("x_accuracy") return Strategies.prepare("x_accuracy")
end end
Battle.automate("thrash") Battle.automate("thrash")
@ -1465,7 +1474,7 @@ strategyFunctions.fightSilphMachoke = function()
end end
strategyFunctions.silphCarbos = function() strategyFunctions.silphCarbos = function()
if nidoSpeed > 50 then if stats.nidoran.speed >= 51 then
return true return true
end end
return Strategies.functions.interact({dir="Left"}) return Strategies.functions.interact({dir="Left"})
@ -1505,7 +1514,7 @@ strategyFunctions.silphRival = function()
end end
elseif Strategies.prepare("x_accuracy", "x_speed") then elseif Strategies.prepare("x_accuracy", "x_speed") then
if opName == "pidgeot" then if opName == "pidgeot" then
if nidoSpecial < 45 or Strategies.hasHealthFor("KogaWeezing", 10) then --TODO remove for red bar if stats.nidoran.special < 45 or Strategies.hasHealthFor("KogaWeezing", 10) then --TODO remove for red bar
forced = "thunderbolt" forced = "thunderbolt"
end end
elseif opponentName == "alakazam" or opponentName == "growlithe" then elseif opponentName == "alakazam" or opponentName == "growlithe" then
@ -1665,11 +1674,11 @@ strategyFunctions.cinnabarCarbos = function()
if px == 21 then if px == 21 then
return true return true
end end
local minSpeed = 51 local minSpeed = 52
if Control.yolo then if Control.yolo then
minSpeed = minSpeed - 1 minSpeed = minSpeed - 1
end end
if nidoSpeed > minSpeed then -- TODO >= if stats.nidoran.speed >= minSpeed then
Walk.step(21, 20) Walk.step(21, 20)
else else
if py == 20 then if py == 20 then
@ -1693,7 +1702,7 @@ strategyFunctions.fightErika = function()
if curr_hp > razorDamage and curr_hp - razorDamage < red_hp then if curr_hp > razorDamage and curr_hp - razorDamage < red_hp then
if Strategies.opponentDamaged() then if Strategies.opponentDamaged() then
forced = "thunderbolt" forced = "thunderbolt"
elseif nidoSpecial < 45 then elseif stats.nidoran.special < 45 then
forced = "ice_beam" forced = "ice_beam"
else else
forced = "thunderbolt" forced = "thunderbolt"
@ -1742,8 +1751,8 @@ end
strategyFunctions.fightGiovanniMachoke = function() strategyFunctions.fightGiovanniMachoke = function()
if Strategies.initialize() then if Strategies.initialize() then
if nidoAttack >= 55 then if stats.nidoran.attack >= 55 then
local eqPpRequired = nidoSpecial >= 47 and 7 or 8 local eqPpRequired = stats.nidoran.special >= 47 and 7 or 8
if Battle.pp("earthquake") >= eqPpRequired then if Battle.pp("earthquake") >= eqPpRequired then
Bridge.chat("Using Earthquake strats on the Machokes") Bridge.chat("Using Earthquake strats on the Machokes")
return true return true
@ -1818,7 +1827,7 @@ end
strategyFunctions.viridianRival = function() strategyFunctions.viridianRival = function()
if Battle.isActive() then if Battle.isActive() then
if not status.canProgress then if not status.canProgress then
if riskGiovanni or nidoSpecial < 45 or Pokemon.index(0, "speed") < 134 then if riskGiovanni or stats.nidoran.special < 45 or Pokemon.index(0, "speed") < 134 then
status.tempDir = "x_special" status.tempDir = "x_special"
else else
print("Skip X Special strats!") print("Skip X Special strats!")
@ -1858,7 +1867,7 @@ strategyFunctions.ether = function(data)
if not status.tempDir then if not status.tempDir then
if data.max then if data.max then
-- TODO don't skip center if not in redbar -- TODO don't skip center if not in redbar
maxEtherSkip = nidoAttack > 53 and Battle.pp("earthquake") > 0 and Battle.pp("horn_drill") > 3 maxEtherSkip = stats.nidoran.attack > 53 and Battle.pp("earthquake") > 0 and Battle.pp("horn_drill") > 3
if maxEtherSkip then if maxEtherSkip then
return true return true
end end

View File

@ -20,15 +20,16 @@ local Pokemon = require "storage.pokemon"
local yellow = YELLOW local yellow = YELLOW
local splitNumber, splitTime = 0, 0 local splitNumber, splitTime = 0, 0
local resetting local resetting
local strategyFunctions
local status = {tries = 0, tempDir = nil, canProgress = nil, initialized = false} local status = {tries = 0, tempDir = nil, canProgress = nil, initialized = false}
local stats = {}
Strategies.status = status Strategies.status = status
Strategies.stats = stats
Strategies.deepRun = false Strategies.deepRun = false
-- RISK/RESET local strategyFunctions
Strategies.timeRequirements = {} -- RISK/RESET
function Strategies.getTimeRequirement(name) function Strategies.getTimeRequirement(name)
return Strategies.timeRequirements[name]() return Strategies.timeRequirements[name]()
@ -46,8 +47,9 @@ function Strategies.hardReset(message, extra, wait)
Bridge.chat(message, extra) Bridge.chat(message, extra)
if wait and INTERNAL and not STREAMING_MODE then if wait and INTERNAL and not STREAMING_MODE then
strategyFunctions.wait() strategyFunctions.wait()
else
client.reboot_core()
end end
client.reboot_core()
return true return true
end end
@ -565,7 +567,7 @@ Strategies.functions = {
wait = function() wait = function()
print("Please save state") print("Please save state")
Input.press("Start", 9001) Input.press("Start", 999999999)
end, end,
emuSpeed = function(data) emuSpeed = function(data)
@ -638,7 +640,7 @@ Strategies.functions = {
for i,poke in ipairs(data) do for i,poke in ipairs(data) do
if opp == poke[1] then if opp == poke[1] then
local minimumAttack = poke[3] local minimumAttack = poke[3]
if not minimumAttack or nidoAttack > minimumAttack then if not minimumAttack or stats.nidoran.attack > minimumAttack then
defLimit = poke[2] defLimit = poke[2]
end end
break break
@ -931,6 +933,7 @@ end
function Strategies.softReset() function Strategies.softReset()
status = {tries=0} status = {tries=0}
Strategies.status = status Strategies.status = status
Strategies.stats = {}
splitNumber, splitTime = 0, 0 splitNumber, splitTime = 0, 0
resetting = nil resetting = nil
Strategies.deepRun = false Strategies.deepRun = false

View File

@ -45,7 +45,7 @@ function Utils.key(needle, haystack)
end end
function Utils.capitalize(string) function Utils.capitalize(string)
return string:sub(1, 1):toUpperCase()..string:sub(1) return string:sub(1, 1):upper()..string:sub(1)
end end
-- GAME -- GAME