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

history added

parent 48e8331e
Branches
No related tags found
1 merge request!1Master
...@@ -26,7 +26,6 @@ public slots: ...@@ -26,7 +26,6 @@ public slots:
void addOption(int x); void addOption(int x);
void removeOption(int x); void removeOption(int x);
void collapse(int x); void collapse(int x);
private slots:
void un(void); void un(void);
}; };
......
...@@ -72,6 +72,7 @@ Window::Window(QWidget *parent) ...@@ -72,6 +72,7 @@ Window::Window(QWidget *parent)
void Window::solveButtonClicked() void Window::solveButtonClicked()
{ {
// std::array<Cell,81> start = m_cell; // std::array<Cell,81> start = m_cell;
std::list<Cell*> hist;
srand(time(NULL)); srand(time(NULL));
while (1) while (1)
{ {
...@@ -101,12 +102,18 @@ void Window::solveButtonClicked() ...@@ -101,12 +102,18 @@ void Window::solveButtonClicked()
return; return;
} }
else if(minEtropy ==0){ else if(minEtropy ==0){
qInfo("dead End reached"); while (hist.size()>1)
{
hist.back()->un();
hist.pop_back();
}
return; return;
//solveButtonClicked();
} }
int choiceCell = rand() % b.size(); //choose a random cell int choiceCell = rand() % b.size(); //choose a random cell
int choiceNr = rand() % b[choiceCell]->index.size(); //choose a random number; int choiceNr = rand() % b[choiceCell]->index.size(); //choose a random number;
b[choiceCell]->collapse(b[choiceCell]->index[choiceNr]); //collapse that random cell with chosen number; b[choiceCell]->collapse(b[choiceCell]->index[choiceNr]); //collapse that random cell with chosen number;
hist.push_back(b[choiceCell]);
repaint(); //draw cells again repaint(); //draw cells again
QThread::msleep(m_delay); QThread::msleep(m_delay);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment