Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SM: 0.4.2 percent goals fix #2183

Merged
merged 230 commits into from
Sep 19, 2023

Conversation

lordlou
Copy link
Contributor

@lordlou lordlou commented Sep 15, 2023

What is this fixing or adding?

How was this tested?

  • generation was failing before the fix, it now passes. I also tried generating differents seeds with the fix, all passing.

…VariaRandomizer's rules, items, locations and accessPoint (as regions)
…se (fills ROM item table)

This is dependant on modifications done to sm_randomizer_rom project
- player name inject in ROM and get in client
- end game get from ROM in client
- send self item to server
- add player names table in ROM
…ition of an array of it (required to generation more than one SM world, which is still fails but is better)
- fixed seeded generation
- fixed broken logic when more than one SM world
- added missing rules for inter-area transitions
- added basic patch presence for logic
- added DoorManager init call to reflect present patches for logic
- moved CollectionState addition out of BaseClasses into SM world
- added condition to apply progitempool presorting only if SM world is present
- set Bosses item id to None to prevent them going into multidata
- now use get_game_players
…VariaRandomizer's rules, items, locations and accessPoint (as regions)
…se (fills ROM item table)

This is dependant on modifications done to sm_randomizer_rom project
- player name inject in ROM and get in client
- end game get from ROM in client
- send self item to server
- add player names table in ROM
…ition of an array of it (required to generation more than one SM world, which is still fails but is better)
@@ -164,6 +164,7 @@ def escapeTrigger(self, emptyContainer, graph, maxDiff, escapeTrigger):
availLocsByArea[itemLoc.Location.GraphArea].append(itemLoc.Location.Name)
self.log.debug("escapeTrigger. availLocsByArea="+str(availLocsByArea))
sm.objectives.setAreaFuncs({area:lambda sm,ap:SMBool(len(container.getLocs(lambda loc: loc.Name in availLocsByArea[area]))==0) for area in availLocsByArea})
sm.objectives.setPercentFuncs({percent:lambda sm,ap:SMBool(len(container.getUsedLocs(lambda loc: True)) >= percent) for percent in [25, 50, 75, 100]})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this right, it's not actually percent, but that many locations? As in, it's checking for being able to reach 25, 50, 75 and 100 locations respectively?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right: thats wrong. Its should really be a percentage of obtainable location checks otherwise things like "Nothing" Items will be counted. I'll fix that.

Copy link
Collaborator

@Silvris Silvris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was able to play a fun movement/disabled Tourian/collect all items seed without any failures. This should cover the test case where less than 100 locations exist (98 total, 97 functional were present, Space and Grapple were removed).

@strotlog
Copy link
Contributor

strotlog commented Sep 17, 2023

Haven't reviewed the code, but as far as testing, I encountered weird generation issues blocking 10 of 10 attempts at generating a fairly normal 3-player SM multi on 0.4.2. Checking out this PR branch fixed the issue, yielding multiple successful generations with the same yamls.

Comment on lines 524 to 525
goal = 'collect %d%% items' % pct
self.goals[goal].clearFunc = getPctFunc(pct, totalItemsCount, container)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
goal = 'collect %d%% items' % pct
self.goals[goal].clearFunc = getPctFunc(pct, totalItemsCount, container)
goal = 'collect %d%% items' % pct
self.goals[goal].clearFunc = getPctFunc(pct, totalItemsCount, container)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with latest commit.

def setItemPercentFuncs(self, totalItemsCount=None, allUpgradeTypes=None):
def getPctFunc(pct, totalItemsCount):
def setItemPercentFuncs(self, totalItemsCount=None, allUpgradeTypes=None, container=None):
def getPctFunc(pct, totalItemsCount, container):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def getPctFunc(pct, totalItemsCount, container):
def getPctFunc(pct, totalItemsCount, container):
total_needed: float = pct * totalItemsCount / 100

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with latest commit.

Comment on lines 517 to 519
nonlocal pct, totalItemsCount, container
locs_checked = len(container.getUsedLocs(lambda loc: True))
return SMBool(locs_checked * 100 / totalItemsCount >= pct)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nonlocal pct, totalItemsCount, container
locs_checked = len(container.getUsedLocs(lambda loc: True))
return SMBool(locs_checked * 100 / totalItemsCount >= pct)
locs_checked = len(container.getUsedLocs(lambda loc: True))
return SMBool(locs_checked >= total_needed)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calculating it once ahead of the function should make it a nice bit faster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with latest commit.

@Berserker66 Berserker66 merged commit 0012584 into ArchipelagoMW:main Sep 19, 2023
12 checks passed
@ThePhar ThePhar added the is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. label Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants