mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-12-23 05:37:10 +00:00
fixes the collection algorithm
This commit is contained in:
parent
9f189ea869
commit
a3431e2fc6
|
@ -44,12 +44,12 @@ local function _itemData()
|
||||||
polarStar1 = {
|
polarStar1 = {
|
||||||
name = "Polar Star",
|
name = "Polar Star",
|
||||||
script = "<EVE0002",
|
script = "<EVE0002",
|
||||||
attributes = {"weaponBoss", "weaponSN", "polarStar"}
|
attributes = {"weaponBoss", "weaponSN", "polarStar", "mandatory"}
|
||||||
},
|
},
|
||||||
polarStar2 = {
|
polarStar2 = {
|
||||||
name = "Polar Star",
|
name = "Polar Star",
|
||||||
script = "<EVE0002",
|
script = "<EVE0002",
|
||||||
attributes = {"weaponBoss", "weaponSN", "polarStar"}
|
attributes = {"weaponBoss", "weaponSN", "polarStar", "mandatory"}
|
||||||
},
|
},
|
||||||
missileLauncher = {
|
missileLauncher = {
|
||||||
name = "Missile Launcher",
|
name = "Missile Launcher",
|
||||||
|
@ -64,7 +64,7 @@ local function _itemData()
|
||||||
fireball = {
|
fireball = {
|
||||||
name = "Fireball",
|
name = "Fireball",
|
||||||
script = "<EVE0004",
|
script = "<EVE0004",
|
||||||
attributes = {"weaponBoss"}
|
attributes = {"weaponBoss", "mandatory"}
|
||||||
},
|
},
|
||||||
snake = {
|
snake = {
|
||||||
name = "Snake",
|
name = "Snake",
|
||||||
|
@ -79,12 +79,12 @@ local function _itemData()
|
||||||
machineGun = {
|
machineGun = {
|
||||||
name = "Machine Gun",
|
name = "Machine Gun",
|
||||||
script = "<EVE0008",
|
script = "<EVE0008",
|
||||||
attributes = {"weaponBoss", "flight"}
|
attributes = {"weaponBoss", "flight", "mandatory"}
|
||||||
},
|
},
|
||||||
blade = {
|
blade = {
|
||||||
name = "Blade",
|
name = "Blade",
|
||||||
script = "<EVE0009",
|
script = "<EVE0009",
|
||||||
attributes = {"weaponBoss", "weaponSN"}
|
attributes = {"weaponBoss", "weaponSN", "mandatory"}
|
||||||
},
|
},
|
||||||
nemesis = {
|
nemesis = {
|
||||||
name = "Nemesis",
|
name = "Nemesis",
|
||||||
|
@ -102,19 +102,23 @@ local function _itemData()
|
||||||
},
|
},
|
||||||
locket = {
|
locket = {
|
||||||
name = "Silver Locket",
|
name = "Silver Locket",
|
||||||
script = "<EVE0054"
|
script = "<EVE0054",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
arthurKey = {
|
arthurKey = {
|
||||||
name = "Arthur's Key",
|
name = "Arthur's Key",
|
||||||
script = "<EVE0051"
|
script = "<EVE0051",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
idCard = {
|
idCard = {
|
||||||
name = "ID Card",
|
name = "ID Card",
|
||||||
script = "<EVE0057"
|
script = "<EVE0057",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
santaKey = {
|
santaKey = {
|
||||||
name = "Santa's Key",
|
name = "Santa's Key",
|
||||||
script = "<EVE0053"
|
script = "<EVE0053",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
lipstick = {
|
lipstick = {
|
||||||
name = "Chaco's Lipstick",
|
name = "Chaco's Lipstick",
|
||||||
|
@ -123,27 +127,33 @@ local function _itemData()
|
||||||
},
|
},
|
||||||
juice = {
|
juice = {
|
||||||
name = "Jellyfish Juice",
|
name = "Jellyfish Juice",
|
||||||
script = "<EVE0058"
|
script = "<EVE0058",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
charcoal = {
|
charcoal = {
|
||||||
name = "Charcoal",
|
name = "Charcoal",
|
||||||
script = "<EVE0062"
|
script = "<EVE0062",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
rustyKey = {
|
rustyKey = {
|
||||||
name = "Rusty Key",
|
name = "Rusty Key",
|
||||||
script = "<EVE0039"
|
script = "<EVE0039",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
gumKey = {
|
gumKey = {
|
||||||
name = "Gum Key",
|
name = "Gum Key",
|
||||||
script = "<EVE0060"
|
script = "<EVE0060",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
gumBase = {
|
gumBase = {
|
||||||
name = "Gum Base",
|
name = "Gum Base",
|
||||||
script = "<EVE0061"
|
script = "<EVE0061",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
bomb = {
|
bomb = {
|
||||||
name = "Bomb",
|
name = "Bomb",
|
||||||
script = "<EVE0063"
|
script = "<EVE0063",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
panties = {
|
panties = {
|
||||||
name = "Curly's Panties",
|
name = "Curly's Panties",
|
||||||
|
@ -187,7 +197,8 @@ local function _itemData()
|
||||||
},
|
},
|
||||||
clinicKey = {
|
clinicKey = {
|
||||||
name = "Clinic Key",
|
name = "Clinic Key",
|
||||||
script = "<EVE0067"
|
script = "<EVE0067",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
armsBarrier = {
|
armsBarrier = {
|
||||||
name = "Arms Barrier",
|
name = "Arms Barrier",
|
||||||
|
@ -196,25 +207,28 @@ local function _itemData()
|
||||||
},
|
},
|
||||||
cureAll = {
|
cureAll = {
|
||||||
name = "Cure-All",
|
name = "Cure-All",
|
||||||
script = "<EVE0066"
|
script = "<EVE0066",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
booster1 = {
|
booster1 = {
|
||||||
name = "Booster",
|
name = "Booster",
|
||||||
script = "<EVE0068",
|
script = "<EVE0068",
|
||||||
attributes = {"flight", "booster"}
|
attributes = {"flight", "booster", "mandatory"}
|
||||||
},
|
},
|
||||||
booster2 = {
|
booster2 = {
|
||||||
name = "Booster",
|
name = "Booster",
|
||||||
script = "<EVE0068",
|
script = "<EVE0068",
|
||||||
attributes = {"flight", "booster"}
|
attributes = {"flight", "booster", "mandatory"}
|
||||||
},
|
},
|
||||||
towRope = {
|
towRope = {
|
||||||
name = "Tow Rope",
|
name = "Tow Rope",
|
||||||
script = "<EVE0080"
|
script = "<EVE0080",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
airTank = {
|
airTank = {
|
||||||
name = "Curly's Air Tank",
|
name = "Curly's Air Tank",
|
||||||
script = "<EVE0071"
|
script = "<EVE0071",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
alienMedal = {
|
alienMedal = {
|
||||||
name = "Alien Medal",
|
name = "Alien Medal",
|
||||||
|
@ -233,35 +247,43 @@ local function _itemData()
|
||||||
},
|
},
|
||||||
teleportKey = {
|
teleportKey = {
|
||||||
name = "Teleporter Room Key",
|
name = "Teleporter Room Key",
|
||||||
script = "<EVE0075"
|
script = "<EVE0075",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
letter = {
|
letter = {
|
||||||
name = "Sue's Letter",
|
name = "Sue's Letter",
|
||||||
script = "<EVE0076"
|
script = "<EVE0076",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
mask = {
|
mask = {
|
||||||
name = "Mimiga Mask",
|
name = "Mimiga Mask",
|
||||||
script = "<EVE0074"
|
script = "<EVE0074",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
brokenSprinkler = {
|
brokenSprinkler = {
|
||||||
name = "Broken Sprinkler",
|
name = "Broken Sprinkler",
|
||||||
script = "<EVE0078"
|
script = "<EVE0078",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
newSprinkler = {
|
newSprinkler = {
|
||||||
name = "Sprinkler",
|
name = "Sprinkler",
|
||||||
script = "<EVE0079"
|
script = "<EVE0079",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
controller = {
|
controller = {
|
||||||
name = "Controller",
|
name = "Controller",
|
||||||
script = "<EVE0077"
|
script = "<EVE0077",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
mushroomBadge = {
|
mushroomBadge = {
|
||||||
name = "Mushroom Badge",
|
name = "Mushroom Badge",
|
||||||
script = "<EVE0083"
|
script = "<EVE0083",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
maPignon = {
|
maPignon = {
|
||||||
name = "Ma Pignon",
|
name = "Ma Pignon",
|
||||||
script = "<EVE0084"
|
script = "<EVE0084",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
mrLittle = {
|
mrLittle = {
|
||||||
name = "Little Man",
|
name = "Little Man",
|
||||||
|
@ -271,7 +293,8 @@ local function _itemData()
|
||||||
},
|
},
|
||||||
ironBond = {
|
ironBond = {
|
||||||
name = "Iron Bond",
|
name = "Iron Bond",
|
||||||
script = "<EVE0089"
|
script = "<EVE0089",
|
||||||
|
attributes = {"mandatory"}
|
||||||
},
|
},
|
||||||
clayMedal = {
|
clayMedal = {
|
||||||
name = "Clay Figure Medal",
|
name = "Clay Figure Medal",
|
||||||
|
@ -364,9 +387,7 @@ function C:getOptionalItems()
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:getMandatoryItems()
|
function C:getMandatoryItems()
|
||||||
return self:_getItems(function(k,v)
|
return self:getItemsByAttribute("mandatory")
|
||||||
return not (_.contains(v.attributes, "event") or _.contains(v.attributes, "nonProgressive") or _.contains(v.attributes, "puppy"))
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:getMandatory()
|
function C:getMandatory()
|
||||||
|
|
|
@ -494,7 +494,7 @@ function worldGraph:writeItems(tscFiles)
|
||||||
end
|
end
|
||||||
|
|
||||||
function worldGraph:collect(preCollectedItems)
|
function worldGraph:collect(preCollectedItems)
|
||||||
local collected = preCollectedItems or {}
|
local collected = _.clone(preCollectedItems) or {}
|
||||||
assert(collected ~= nil)
|
assert(collected ~= nil)
|
||||||
local availableLocations = self:getFilledLocations()
|
local availableLocations = self:getFilledLocations()
|
||||||
|
|
||||||
|
@ -515,6 +515,9 @@ function worldGraph:collect(preCollectedItems)
|
||||||
end
|
end
|
||||||
until foundItems == 0
|
until foundItems == 0
|
||||||
|
|
||||||
|
--[[local s = "Collected items: "
|
||||||
|
for k,v in ipairs(collected) do s = s .. v.name .. ", " end
|
||||||
|
logDebug(s)]]
|
||||||
return collected
|
return collected
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -126,15 +126,17 @@ function C:_fillItems(items, locations)
|
||||||
assert(#items <= #locations, string.format("Trying to fill more items than there are locations! Items: %d Locations: %d", #items, #locations))
|
assert(#items <= #locations, string.format("Trying to fill more items than there are locations! Items: %d Locations: %d", #items, #locations))
|
||||||
|
|
||||||
local itemsLeft = _.clone(items)
|
local itemsLeft = _.clone(items)
|
||||||
for key, item in ipairs(items) do
|
repeat
|
||||||
local assumed = self.worldGraph:collect(_.remove(itemsLeft, item))
|
local item = _.pop(itemsLeft)
|
||||||
|
local assumed = self.worldGraph:collect(itemsLeft)
|
||||||
|
|
||||||
local fillable = _.filter(locations, function(k,v) return not v:hasItem() and v:canAccess(assumed) end)
|
local fillable = _.filter(locations, function(k,v) return not v:hasItem() and v:canAccess(assumed) end)
|
||||||
local empty = _.filter(locations, function(k,v) return not v:hasItem() end)
|
local empty = _.filter(locations, function(k,v) return not v:hasItem() end)
|
||||||
assert(#fillable > 0, "No available locations!")
|
assert(#fillable > 0, ("No available locations for %s! Items left: %d"):format(item.name, #itemsLeft))
|
||||||
assert(item ~= nil, "No item found!")
|
assert(item ~= nil, "No item found!")
|
||||||
|
logDebug(("Placing %s at %s"):format(item.name, fillable[1].name))
|
||||||
fillable[1]:setItem(item)
|
fillable[1]:setItem(item)
|
||||||
end
|
until #itemsLeft == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:_fastFillItems(items, locations)
|
function C:_fastFillItems(items, locations)
|
||||||
|
|
Loading…
Reference in a new issue