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

renamed cell arr to grid

parent 5f261e57
No related branches found
No related tags found
No related merge requests found
......@@ -49,16 +49,16 @@ Window::Window(QWidget *parent)
{
for (int y = 0; y < 9; y++)
{
cell[x + y * 9].setParent(this);
layout->addWidget(&cell[x + y * 9], y + y / 3, x + x / 3);
grid[x + y * 9].setParent(this);
layout->addWidget(&grid[x + y * 9], y + y / 3, x + x / 3);
// connecting signals & slots
for (int d = 0; d < 9; d++) // rows and columns
{
connect(&cell[x + y * 9], SIGNAL(update(int)), &cell[x + d * 9], SLOT(removeOption(int)));
connect(&cell[x + y * 9], SIGNAL(update(int)), &cell[d + y * 9], SLOT(removeOption(int)));
connect(&grid[x + y * 9], SIGNAL(update(int)), &grid[x + d * 9], SLOT(removeOption(int)));
connect(&grid[x + y * 9], SIGNAL(update(int)), &grid[d + y * 9], SLOT(removeOption(int)));
connect(&cell[x + y * 9], SIGNAL(undo(int)), &cell[x + d * 9], SLOT(addOption(int)));
connect(&cell[x + y * 9], SIGNAL(undo(int)), &cell[d + y * 9], SLOT(addOption(int)));
connect(&grid[x + y * 9], SIGNAL(undo(int)), &grid[x + d * 9], SLOT(addOption(int)));
connect(&grid[x + y * 9], SIGNAL(undo(int)), &grid[d + y * 9], SLOT(addOption(int)));
}
int a = x / 3 * 3;
int b = y / 3 * 3;
......@@ -68,9 +68,9 @@ Window::Window(QWidget *parent)
{
if (x1 == x || y1 == y)
continue;
connect(&cell[x + y * 9], SIGNAL(update(int)), &cell[x1 + y1 * 9], SLOT(removeOption(int)));
connect(&grid[x + y * 9], SIGNAL(update(int)), &grid[x1 + y1 * 9], SLOT(removeOption(int)));
connect(&cell[x + y * 9], SIGNAL(undo(int)), &cell[x1 + y1 * 9], SLOT(addOption(int)));
connect(&grid[x + y * 9], SIGNAL(undo(int)), &grid[x1 + y1 * 9], SLOT(addOption(int)));
}
}
}
......@@ -111,17 +111,17 @@ void Window::solveButtonClicked()
{
for (int y = 0; y < 9; y++)
{
if (cell[x + y * 9].collapsed)
if (grid[x + y * 9].collapsed)
continue;
else if (cell[x + y * 9].possibleStates < minEtropy)
else if (grid[x + y * 9].possibleStates < minEtropy)
{
minEtropy = cell[x + y * 9].possibleStates;
minEtropy = grid[x + y * 9].possibleStates;
b.clear();
b.push_back(&cell[x + y * 9]);
b.push_back(&grid[x + y * 9]);
}
else if (cell[x + y * 9].possibleStates == minEtropy)
else if (grid[x + y * 9].possibleStates == minEtropy)
{
b.push_back(&cell[x + y * 9]);
b.push_back(&grid[x + y * 9]);
}
}
}
......@@ -154,7 +154,7 @@ inline void Window::delay(int millisecondsWait)
}
void Window::clearButtonClicked()
{
for (auto &x : cell)
for (auto &x : grid)
{
if (x.collapsed)
x.collapsedCellClicked();
......
......@@ -19,7 +19,7 @@ private:
QPushButton *clearButton;
QPushButton *solveButton;
QSlider *slider;
std::array<Cell, 81> cell;
std::array<Cell, 81> grid;
int delayTime = 300;
QSpacerItem *spacer[3];
QHBoxLayout *horizontalLayout;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment