Skip to content

Create new solving mechanism#1

Open
rouanth wants to merge 25 commits intogh-pagesfrom
solver_rewrite
Open

Create new solving mechanism#1
rouanth wants to merge 25 commits intogh-pagesfrom
solver_rewrite

Conversation

@rouanth
Copy link
Owner

@rouanth rouanth commented Jul 30, 2016

No description provided.

rouanth added 10 commits July 14, 2016 13:20
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.
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.
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.
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.
No reason to trust unit tests if they aren't working. And it turns out
they doesn't. Some errors have surfaced that needed the code to be
updated.
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.

1 participant