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

Don't check all map options if there's an infinite loop #33201

Merged
merged 3 commits into from Feb 20, 2020

Conversation

ajpal
Copy link
Contributor

@ajpal ajpal commented Feb 19, 2020

If there are a lot of map configurations and there's an infinite loop, the code hangs for quite a while before animating the result. The reason for this is that we check every possible configuration prior to showing any results. As soon as we detect an infinite loop, we should break out of checking the possible grid configurations and immediately show the result.

See for example https://studio.code.org/s/express-2019/stage/17/puzzle/5, which has 144 possible configurations.

Also reduce the max number of ticks to 1000. This should be a high enough upper bound for maze.

Links

Testing story

Reviewer Checklist:

  • Tests provide adequate coverage
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@ajpal ajpal requested a review from Hamms February 19, 2020 01:07
@@ -372,6 +373,9 @@ module.exports = class Maze {
this.onExecutionFinish_();
if (this.executionInfo.terminationValue() === true) {
successes.push(i);
} else if (this.executionInfo.terminationValue() === Infinity) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd really like to see a comment here explaining both what this termination value indicates and why we're treating it differently.

I'd also be interested to see some reasoning about what we want to do in the situation in which the user encounters an infinite loop on only some of the possible grids. Specifically with regards to deciding which failure case to show them

@ajpal ajpal merged commit f54dbf8 into staging Feb 20, 2020
@ajpal ajpal deleted the feb18-maze-quantum-infinite-loop-break branch February 20, 2020 20:18
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.

None yet

2 participants