Skip to content

Commit

Permalink
lots of logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Malkierian committed Apr 9, 2024
1 parent 4e7e5b6 commit 87e0cf5
Showing 1 changed file with 176 additions and 29 deletions.
205 changes: 176 additions & 29 deletions soh/soh/Enhancements/randomizer/3drando/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ std::vector<RandomizerCheck> GetAccessibleLocations(const std::vector<Randomizer
updatedEvents = false;

for (Rando::ItemLocation* location : newItemLocations) {
SPDLOG_INFO("Playthrough: applying item effect for loc {}, item {}", location->GetRandomizerCheck(), location->GetPlacedRandomizerGet());
location->ApplyPlacedItemEffect();
}
newItemLocations.clear();
Expand Down Expand Up @@ -664,6 +665,7 @@ static void AssumedFill(const std::vector<RandomizerGet>& items, const std::vect
bool unsuccessfulPlacement = false;
std::vector<RandomizerCheck> attemptedLocations;
do {
SPDLOG_INFO("Retry {}", (11 - retries));
retries--;
if (retries <= 0) {
placementFailure = true;
Expand Down Expand Up @@ -769,7 +771,13 @@ static void RandomizeDungeonRewards() {
//End of Dungeons includes Link's Pocket
if (ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_END_OF_DUNGEON)) {
//get stones and medallions
std::vector<RandomizerGet> rewards = FilterAndEraseFromPool(ItemPool, [](const auto i) {return Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD;});
std::vector<RandomizerGet> rewards = FilterAndEraseFromPool(ItemPool, [](const auto i) {
if(Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});

// If there are less than 9 dungeon rewards, prioritize the actual dungeons
// for placement instead of Link's Pocket
Expand All @@ -782,6 +790,7 @@ static void RandomizeDungeonRewards() {
ctx->GetItemLocation(loc)->PlaceVanillaItem();
}
} else { //Randomize dungeon rewards with assumed fill
SPDLOG_INFO("Assumed Fill: Dungeon Rewards");
AssumedFill(rewards, Rando::StaticData::dungeonRewardLocations);
}

Expand Down Expand Up @@ -853,22 +862,42 @@ static void RandomizeOwnDungeon(const Rando::DungeonInfo* dungeon) {

//Add specific items that need be randomized within this dungeon
if (ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_OWN_DUNGEON) && dungeon->GetSmallKey() != RG_NONE) {
std::vector<RandomizerGet> dungeonSmallKeys = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i){ return (i == dungeon->GetSmallKey()) || (i == dungeon->GetKeyRing());});
std::vector<RandomizerGet> dungeonSmallKeys = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i) {
if ((i == dungeon->GetSmallKey()) || (i == dungeon->GetKeyRing())) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(dungeonItems, dungeonSmallKeys);
}

if ((ctx->GetOption(RSK_BOSS_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_OWN_DUNGEON) && dungeon->GetBossKey() != RG_GANONS_CASTLE_BOSS_KEY) ||
(ctx->GetOption(RSK_GANONS_BOSS_KEY).Is(RO_GANON_BOSS_KEY_OWN_DUNGEON) && dungeon->GetBossKey() == RG_GANONS_CASTLE_BOSS_KEY)) {
auto dungeonBossKey = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i){ return i == dungeon->GetBossKey();});
auto dungeonBossKey = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i) {
if (i == dungeon->GetBossKey()) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(dungeonItems, dungeonBossKey);
}

//randomize boss key and small keys together for even distribution
SPDLOG_INFO("Assumed Fill: Dungeon Items Own Dungeon");
AssumedFill(dungeonItems, dungeonLocations);

//randomize map and compass separately since they're not progressive
if (ctx->GetOption(RSK_SHUFFLE_MAPANDCOMPASS).Is(RO_DUNGEON_ITEM_LOC_OWN_DUNGEON) && dungeon->GetMap() != RG_NONE && dungeon->GetCompass() != RG_NONE) {
auto dungeonMapAndCompass = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i){ return i == dungeon->GetMap() || i == dungeon->GetCompass();});
auto dungeonMapAndCompass = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i) {
if (i == dungeon->GetMap() || i == dungeon->GetCompass()) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
SPDLOG_INFO("Assumed Fill: maps and compasses");
AssumedFill(dungeonMapAndCompass, dungeonLocations);
}
}
Expand All @@ -885,7 +914,13 @@ static void RandomizeDungeonItems() {
auto ctx = Rando::Context::GetInstance();

//Get Any Dungeon and Overworld group locations
std::vector<RandomizerCheck> anyDungeonLocations = FilterFromPool(ctx->allLocations, [](const auto loc){return Rando::StaticData::GetLocation(loc)->IsDungeon();});
std::vector<RandomizerCheck> anyDungeonLocations = FilterFromPool(ctx->allLocations, [](const auto loc) {
if (Rando::StaticData::GetLocation(loc)->IsDungeon()) {
SPDLOG_INFO("Filtering {} from location pool", loc);
return true;
}
return false;
});
//overworldLocations defined in item_location.cpp

//Create Any Dungeon and Overworld item pools
Expand All @@ -894,59 +929,133 @@ static void RandomizeDungeonItems() {

for (auto dungeon : ctx->GetDungeons()->GetDungeonList()) {
if (ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_OWN_DUNGEON)) {
auto dungeonKeys = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i){return (i == dungeon->GetSmallKey()) || (i == dungeon->GetKeyRing());});
auto dungeonKeys = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i) {
if ((i == dungeon->GetSmallKey()) || (i == dungeon->GetKeyRing())) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(anyDungeonItems, dungeonKeys);
} else if (ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_OVERWORLD)) {
auto dungeonKeys = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i){return (i == dungeon->GetSmallKey()) || (i == dungeon->GetKeyRing());});
auto dungeonKeys = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i) {
if ((i == dungeon->GetSmallKey()) || (i == dungeon->GetKeyRing())) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(overworldItems, dungeonKeys);
}

if (ctx->GetOption(RSK_BOSS_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANY_DUNGEON) && dungeon->GetBossKey() != RG_GANONS_CASTLE_BOSS_KEY) {
auto bossKey = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i){return i == dungeon->GetBossKey();});
auto bossKey = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i) {
if (i == dungeon->GetBossKey()) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(anyDungeonItems, bossKey);
} else if (ctx->GetOption(RSK_BOSS_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_OVERWORLD) && dungeon->GetBossKey() != RG_GANONS_CASTLE_BOSS_KEY) {
auto bossKey = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i){return i == dungeon->GetBossKey();});
auto bossKey = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i) {
if (i == dungeon->GetBossKey()) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(overworldItems, bossKey);
}

if (ctx->GetOption(RSK_GANONS_BOSS_KEY).Is(RO_GANON_BOSS_KEY_ANY_DUNGEON)) {
auto ganonBossKey = FilterAndEraseFromPool(ItemPool, [](const auto i){return i == RG_GANONS_CASTLE_BOSS_KEY;});
auto ganonBossKey = FilterAndEraseFromPool(ItemPool, [](const auto i) {
if (i == RG_GANONS_CASTLE_BOSS_KEY) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(anyDungeonItems, ganonBossKey);
} else if (ctx->GetOption(RSK_GANONS_BOSS_KEY).Is(RO_GANON_BOSS_KEY_OVERWORLD)) {
auto ganonBossKey = FilterAndEraseFromPool(ItemPool, [](const auto i) { return i == RG_GANONS_CASTLE_BOSS_KEY; });
auto ganonBossKey = FilterAndEraseFromPool(ItemPool, [](const auto i) {
if (i == RG_GANONS_CASTLE_BOSS_KEY) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(overworldItems, ganonBossKey);
}
}

if (ctx->GetOption(RSK_GERUDO_KEYS).Is(RO_GERUDO_KEYS_ANY_DUNGEON)) {
auto gerudoKeys = FilterAndEraseFromPool(ItemPool, [](const auto i) { return i == RG_GERUDO_FORTRESS_SMALL_KEY; });
auto gerudoKeys = FilterAndEraseFromPool(ItemPool, [](const auto i) {
if (i == RG_GERUDO_FORTRESS_SMALL_KEY) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(anyDungeonItems, gerudoKeys);
} else if (ctx->GetOption(RSK_GERUDO_KEYS).Is(RO_GERUDO_KEYS_OVERWORLD)) {
auto gerudoKeys = FilterAndEraseFromPool(ItemPool, [](const auto i) { return i == RG_GERUDO_FORTRESS_SMALL_KEY; });
auto gerudoKeys = FilterAndEraseFromPool(ItemPool, [](const auto i) {
if (i == RG_GERUDO_FORTRESS_SMALL_KEY) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(overworldItems, gerudoKeys);
}

if (ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_ANY_DUNGEON)) {
auto rewards = FilterAndEraseFromPool(
ItemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD; });
auto rewards = FilterAndEraseFromPool(ItemPool, [](const auto i) {
if (Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(anyDungeonItems, rewards);
} else if (ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_OVERWORLD)) {
auto rewards = FilterAndEraseFromPool(
ItemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD; });
auto rewards = FilterAndEraseFromPool(ItemPool, [](const auto i) {
if (Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
AddElementsToPool(overworldItems, rewards);
}

//Randomize Any Dungeon and Overworld pools
SPDLOG_INFO("Assumed Fill: Any Dungeon");
AssumedFill(anyDungeonItems, anyDungeonLocations, true);
SPDLOG_INFO("Assumed Fill: Dungeon in Overworld");
AssumedFill(overworldItems, Rando::StaticData::overworldLocations, true);

//Randomize maps and compasses after since they're not advancement items
for (auto dungeon : ctx->GetDungeons()->GetDungeonList()) {
if (ctx->GetOption(RSK_SHUFFLE_MAPANDCOMPASS).Is(RO_DUNGEON_ITEM_LOC_ANY_DUNGEON)) {
auto mapAndCompassItems = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i){return i == dungeon->GetMap() || i == dungeon->GetCompass();});
auto mapAndCompassItems = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i) {
if (i == dungeon->GetMap() || i == dungeon->GetCompass()) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
SPDLOG_INFO("Assumed Fill: Maps Any Dungeon");
AssumedFill(mapAndCompassItems, anyDungeonLocations, true);
} else if (ctx->GetOption(RSK_SHUFFLE_MAPANDCOMPASS).Is(RO_DUNGEON_ITEM_LOC_OVERWORLD)) {
auto mapAndCompassItems = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i){return i == dungeon->GetMap() || i == dungeon->GetCompass();});
auto mapAndCompassItems = FilterAndEraseFromPool(ItemPool, [dungeon](const RandomizerGet i) {
if (i == dungeon->GetMap() || i == dungeon->GetCompass()) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
SPDLOG_INFO("Assumed Fill: Maps Overworld");
AssumedFill(mapAndCompassItems, Rando::StaticData::overworldLocations, true);
}
}
Expand All @@ -957,7 +1066,12 @@ static void RandomizeLinksPocket() {
if (ctx->GetOption(RSK_LINKS_POCKET).Is(RO_LINKS_POCKET_ADVANCEMENT)) {
//Get all the advancement items don't include tokens
std::vector<RandomizerGet> advancementItems = FilterAndEraseFromPool(ItemPool, [](const auto i) {
return Rando::StaticData::RetrieveItem(i).IsAdvancement() && Rando::StaticData::RetrieveItem(i).GetItemType() != ITEMTYPE_TOKEN;
if (Rando::StaticData::RetrieveItem(i).IsAdvancement() &&
Rando::StaticData::RetrieveItem(i).GetItemType() != ITEMTYPE_TOKEN) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
//select a random one
RandomizerGet startingItem = RandomElement(advancementItems, true);
Expand Down Expand Up @@ -1034,7 +1148,13 @@ int Fill() {
}
SetAreas();
//erase temporary shop items
FilterAndEraseFromPool(ItemPool, [](const auto item) { return Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP; });
FilterAndEraseFromPool(ItemPool, [](const auto item) {
if (Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP) {
SPDLOG_INFO("Filtering {} from item pool", item);
return true;
}
return false;
});

//ctx->showItemProgress = true;
//Place shop items first, since a buy shield is needed to place a dungeon reward on Gohma due to access
Expand Down Expand Up @@ -1080,6 +1200,7 @@ int Fill() {
}
}
//Place the shop items which will still be at shop locations
SPDLOG_INFO("Assumed Fill: Shops");
AssumedFill(shopItems, shopLocations);
}

Expand All @@ -1095,21 +1216,36 @@ int Fill() {
if (ctx->GetOption(RSK_SHUFFLE_SONGS).IsNot(RO_SONG_SHUFFLE_ANYWHERE)) {

//Get each song
std::vector<RandomizerGet> songs = FilterAndEraseFromPool(
ItemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_SONG; });
std::vector<RandomizerGet> songs = FilterAndEraseFromPool(ItemPool, [](const auto i) {
if (Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_SONG) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});

//Get each song location
std::vector<RandomizerCheck> songLocations;
if (ctx->GetOption(RSK_SHUFFLE_SONGS).Is(RO_SONG_SHUFFLE_SONG_LOCATIONS)) {
songLocations = FilterFromPool(
ctx->allLocations, [](const auto loc) { return Rando::StaticData::GetLocation(loc)->IsCategory(Category::cSong); });
songLocations = FilterFromPool(ctx->allLocations, [](const auto loc) {
if (Rando::StaticData::GetLocation(loc)->IsCategory(Category::cSong)) {
SPDLOG_INFO("Filtering {} from location pool", loc);
return true;
}
return false;
});

} else if (ctx->GetOption(RSK_SHUFFLE_SONGS).Is(RO_SONG_SHUFFLE_DUNGEON_REWARDS)) {
songLocations = FilterFromPool(ctx->allLocations, [](const auto loc) {
return Rando::StaticData::GetLocation(loc)->IsCategory(Category::cSongDungeonReward);
if (Rando::StaticData::GetLocation(loc)->IsCategory(Category::cSongDungeonReward)) {
SPDLOG_INFO("Filtering {} from location pool", loc);
return true;
}
return false;
});
}

SPDLOG_INFO("Assumed Fill: Songs");
AssumedFill(songs, songLocations, true);
}

Expand All @@ -1119,12 +1255,23 @@ int Fill() {
//Then place Link's Pocket Item if it has to be an advancement item
RandomizeLinksPocket();
//Then place the rest of the advancement items
std::vector<RandomizerGet> remainingAdvancementItems =
FilterAndEraseFromPool(ItemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).IsAdvancement(); });
std::vector<RandomizerGet> remainingAdvancementItems = FilterAndEraseFromPool(ItemPool, [](const auto i) {
if (Rando::StaticData::RetrieveItem(i).IsAdvancement()) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
}
return false;
});
SPDLOG_INFO("Assumed Fill: Remaining Advancements");
AssumedFill(remainingAdvancementItems, ctx->allLocations, true);

//Fast fill for the rest of the pool
std::vector<RandomizerGet> remainingPool = FilterAndEraseFromPool(ItemPool, [](const auto i) { return true; });
std::vector<RandomizerGet> remainingPool = FilterAndEraseFromPool(ItemPool, [](const auto i) {
SPDLOG_INFO("Filtering {} from item pool", i);
return true;
return true;
});
SPDLOG_INFO("Fast Fill: Remaining Items");
FastFill(remainingPool, GetAllEmptyLocations(), false);

//Add prices for scrubsanity, this is unique to SoH because we write/read scrub prices to/from the spoilerfile.
Expand Down

0 comments on commit 87e0cf5

Please sign in to comment.