Skip to content
Snippets Groups Projects
Commit f4f7964f authored by Silas Dohm's avatar Silas Dohm
Browse files

clean up

parent a27052f7
Branches
No related tags found
No related merge requests found
......@@ -85,6 +85,8 @@ void Window::solveButtonClicked()
validNrs.push_back(i);
if (validNrs.size() == 0)
{
if (hist.size() <= 0)
return;
hist.pop_back();
continue;
}
......@@ -93,8 +95,6 @@ void Window::solveButtonClicked()
hist.back().cell->collapse(validNrs[rndNr]); // collapse cell with chosen number;
hist.back().blocked[validNrs[rndNr]]++;
}
else
{
std::vector<Cell *> b; // vector of cells with least entropy
int minEtropy = 10;
for (auto &cell : grid)
......@@ -129,11 +129,10 @@ void Window::solveButtonClicked()
validNrs.push_back(i);
}
int rndNr = rand() % validNrs.size(); // choose a random number;
hist.push_back(History(b[rndCell], b[rndCell]->blocked, validNrs[rndNr]));
hist.push_back(History(b[rndCell], validNrs[rndNr]));
b[rndCell]->collapse(validNrs[rndNr]); // collapse that random cell with chosen number;
}
}
}
void Window::clearButtonClicked()
{
for (auto &x : grid)
......
......@@ -26,10 +26,10 @@ private:
{
Cell *cell;
std::array<int, 9> blocked;
History(Cell *c, std::array<int,9> in, int choice)
History(Cell *c, int choice)
{
cell = c;
blocked =in;
blocked = c->blocked;
blocked[choice] ++;
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment