From 75cd69efd37c9014cbc8e3b1d5f2dd1db9275808 Mon Sep 17 00:00:00 2001
From: Silas Dohm <silas.dohm@stud.hs-bochum.de>
Date: Sat, 30 Jul 2022 13:10:56 +0200
Subject: [PATCH] history added

---
 cell.h     | 1 -
 window.cpp | 9 ++++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/cell.h b/cell.h
index 808e5a1..3ca68e3 100644
--- a/cell.h
+++ b/cell.h
@@ -26,7 +26,6 @@ public slots:
     void addOption(int x);
     void removeOption(int x);
     void collapse(int x);
-private slots:
     void un(void);
 };
 
diff --git a/window.cpp b/window.cpp
index b055b88..825783a 100644
--- a/window.cpp
+++ b/window.cpp
@@ -72,6 +72,7 @@ Window::Window(QWidget *parent)
 void Window::solveButtonClicked()
 {
     // std::array<Cell,81> start = m_cell;
+    std::list<Cell*> hist;
     srand(time(NULL));
     while (1)
     {
@@ -101,12 +102,18 @@ void Window::solveButtonClicked()
             return;
         }
         else if(minEtropy ==0){
-            qInfo("dead End reached");
+            while (hist.size()>1)
+            {
+                hist.back()->un();
+                hist.pop_back();
+            }
             return;
+            //solveButtonClicked();
         }
         int choiceCell = rand() % b.size(); //choose a random cell 
         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;
+        hist.push_back(b[choiceCell]);
         repaint(); //draw cells again
         QThread::msleep(m_delay);
     }
-- 
GitLab