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

relaxed failure limit #6

Merged
merged 1 commit into from
Feb 5, 2024
Merged

relaxed failure limit #6

merged 1 commit into from
Feb 5, 2024

Conversation

khrome
Copy link
Collaborator

@khrome khrome commented Feb 4, 2024

This takes it from failing about half the time to failing less than ~5% of the time (anecdotally) while retaining performance.

@khrome khrome changed the title relaxed faailure limit relaxed failure limit Feb 4, 2024
@Marak
Copy link
Contributor

Marak commented Feb 5, 2024

LGTM. Thank you for your contribution.

In the production demo we are infinitely retrying in a loop using new random seed:

  function tryGenerate(generatorType, map) {
    try {
      generators[generatorType](map, {});
      if (LABY.terrains[generatorType]) {
        map.scaleToTileRange(4);
      }
      updateMapDisplay(map);
    } catch (err) {
      // console.log(err)
      //console.log('try again');
      map.seedRandom(); // new seed
      setTimeout(function(){
        tryGenerate(generatorType, map);
      }, 10)
    }

  }

@Marak Marak merged commit de3958a into master Feb 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants