Open
Conversation
If we verify the states of combinations of N boolean variables, it is in
general case a problem requiring 2^N iterations. However, if N variables
can be split into M independent components of length p(m), m \in M then
we require just \sum 2^{p(m)}.
If N is divided evenly into M components, for example, then we require
just M 2^{N/M} iterations. For N = 100 and M = 5, the naive method
requires
(2^N) / (M 2^{N/M}) = 1/M 2^{N - N/M} \approx 2.4e23
times more iterations.
As the logic of the application grows it becomes harder to analyse the results of a test evaluation manually. Thus, the tests now themselves know which results to expect.
compontents -> components. The unit tests are no longer evaluated twice needlessly.
After we're done with each component of our graph, we'll have to somehow find correspondence between these arrays and the initial data. So we return a set of indexes of original matrices that are present in each component. The order is preserved, so this is enough.
There may be matrices where the first `x` columns only contain 0. So we skip these columns and only consider those that have values.
Consistently using tabs everywhere in *.js-files.
Solver is called once the green button is pressed. Its results aren't yet displayed to user in any helpful way but they're written to console. It should allow for more rapid manual testing with examples.
Now the field shows with color the estimated probabilities of mine location in each specific cell.
f42973f to
92e5ab5
Compare
It used to perform some arithmetics that considered the last cell of line M a neighbor of the first cell of line M + 1. Fixed this.
92e5ab5 to
d2992b7
Compare
As soon as it became possible to test the algorithm interactively, a multitude of problems emerged. We can hope that now they're fixed: for small examples at least they give the correct results.
Added new tests that cover the problems we've had to fix which weren't detected by the previous set of tests. Performed some refactoring to remove boilerplate code from unit tests.
We need a more complex auto-testing framework which could generate many examples. It would allow us to cover the algorithm more fully as well as to create ground for future development of algorithm for automatical solution of the fields, not simple estimation of probabilities.
This one presumably can generate all the possible layouts depending on the seed instead of a small particular set of them.
Implemented memoised factorial function. Implemented a function that returns a permutation of a given array with an index.
Both functions manipulate arrays, the first one computes the permutations of various lengths, the second one merges the second array into the missing values in the first one.
88e369d to
d41a9f9
Compare
First steps have been made to allow mines to be not only present or not present but also have a range of possible values. It's useful because it shall allow us to use symmetry to reason about groups of mines at once.
These functions aren't really specific to the problem at hand, so we may as well take them out.
We've put the solving functions into an object so that we can set parameters for solutions.
The function didn't work since it called itself with the wrong name. It also included debugging logging that's no longer needed.
Debug logging was a major resource hog, and why bother with it when everything works? And when it doesn't work, the problems are usually highlighted by unit testing.
Now red appears and green disappears faster than as a linear function of probability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.