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

var names

parent e9e29398
No related branches found
No related tags found
No related merge requests found
...@@ -88,21 +88,21 @@ void Window::solveButtonClicked() ...@@ -88,21 +88,21 @@ void Window::solveButtonClicked()
if (backtracking) if (backtracking)
{ {
hist.back().cell->collapsedCellClicked(); hist.back().cell->collapsedCellClicked();
std::vector<int> b; std::vector<int> validNrs;
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
if (hist.back().blocked[i] == 0) if (hist.back().blocked[i] == 0)
b.push_back(i); validNrs.push_back(i);
if (b.size() == 0) if (validNrs.size() == 0)
{ {
hist.pop_back(); hist.pop_back();
continue; continue;
} }
backtracking = false; backtracking = false;
int choiceNr = rand() % b.size(); // choose a random number; int rndNr = rand() % validNrs.size(); // choose a random number;
repaint(); // draw cells again repaint(); // draw cells again
delay(delayTime); delay(delayTime);
hist.back().cell->collapse(b[choiceNr]); // collapse cell with chosen number; hist.back().cell->collapse(validNrs[rndNr]); // collapse cell with chosen number;
hist.back().blocked[b[choiceNr]]++; hist.back().blocked[validNrs[rndNr]]++;
} }
else else
{ {
...@@ -138,16 +138,16 @@ void Window::solveButtonClicked() ...@@ -138,16 +138,16 @@ void Window::solveButtonClicked()
continue; continue;
} }
int choiceCell = rand() % b.size(); // choose a random cell int rndCell = rand() % b.size(); // choose a random cell
std::vector<int> c; std::vector<int> validNrs;
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
if (b[choiceCell]->blocked[i] == 0) if (b[rndCell]->blocked[i] == 0)
c.push_back(i); validNrs.push_back(i);
} }
int choiceNr = rand() % c.size(); // choose a random number; int rndNr = rand() % validNrs.size(); // choose a random number;
hist.push_back(History(b[choiceCell], b[choiceCell]->blocked, c[choiceNr])); // fix this!!! hist.push_back(History(b[rndCell], b[rndCell]->blocked, validNrs[rndNr]));
b[choiceCell]->collapse(c[choiceNr]); // collapse that random cell with chosen number; b[rndCell]->collapse(validNrs[rndNr]); // collapse that random cell with chosen number;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment