Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sudoku solver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Silas Dohm
sudoku solver
Commits
a27052f7
Commit
a27052f7
authored
2 years ago
by
Silas Dohm
Browse files
Options
Downloads
Patches
Plain Diff
removed delay/slider
parent
adbac78b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
window.cpp
+0
-25
0 additions, 25 deletions
window.cpp
window.h
+0
-5
0 additions, 5 deletions
window.h
with
0 additions
and
30 deletions
window.cpp
+
0
−
25
View file @
a27052f7
...
@@ -17,12 +17,6 @@ Window::Window(QWidget *parent)
...
@@ -17,12 +17,6 @@ Window::Window(QWidget *parent)
clearButton
=
new
QPushButton
(
"Clear"
,
this
);
clearButton
=
new
QPushButton
(
"Clear"
,
this
);
connect
(
clearButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
clearButtonClicked
()));
connect
(
clearButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
clearButtonClicked
()));
slider
=
new
QSlider
(
this
);
slider
->
setRange
(
0
,
1000
);
slider
->
setOrientation
(
Qt
::
Horizontal
);
slider
->
setValue
(
delayTime
);
connect
(
slider
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
setValue
(
int
)));
horizontalLayout
=
new
QHBoxLayout
(
this
);
horizontalLayout
=
new
QHBoxLayout
(
this
);
verticalLayout
=
new
QVBoxLayout
();
verticalLayout
=
new
QVBoxLayout
();
layout
=
new
QGridLayout
();
layout
=
new
QGridLayout
();
...
@@ -33,7 +27,6 @@ Window::Window(QWidget *parent)
...
@@ -33,7 +27,6 @@ Window::Window(QWidget *parent)
verticalLayout
->
addItem
(
spacer
[
2
]);
verticalLayout
->
addItem
(
spacer
[
2
]);
verticalLayout
->
addWidget
(
solveButton
);
verticalLayout
->
addWidget
(
solveButton
);
verticalLayout
->
addWidget
(
slider
);
verticalLayout
->
addWidget
(
clearButton
);
verticalLayout
->
addWidget
(
clearButton
);
horizontalLayout
->
addLayout
(
layout
,
5
);
horizontalLayout
->
addLayout
(
layout
,
5
);
horizontalLayout
->
addLayout
(
verticalLayout
,
1
);
horizontalLayout
->
addLayout
(
verticalLayout
,
1
);
...
@@ -83,8 +76,6 @@ void Window::solveButtonClicked()
...
@@ -83,8 +76,6 @@ void Window::solveButtonClicked()
srand
(
time
(
NULL
));
// random seed
srand
(
time
(
NULL
));
// random seed
while
(
1
)
while
(
1
)
{
{
repaint
();
// draw cells again
delay
(
delayTime
);
if
(
backtracking
)
if
(
backtracking
)
{
{
hist
.
back
().
cell
->
collapsedCellClicked
();
hist
.
back
().
cell
->
collapsedCellClicked
();
...
@@ -99,8 +90,6 @@ void Window::solveButtonClicked()
...
@@ -99,8 +90,6 @@ void Window::solveButtonClicked()
}
}
backtracking
=
false
;
backtracking
=
false
;
int
rndNr
=
rand
()
%
validNrs
.
size
();
// choose a random number;
int
rndNr
=
rand
()
%
validNrs
.
size
();
// choose a random number;
repaint
();
// draw cells again
delay
(
delayTime
);
hist
.
back
().
cell
->
collapse
(
validNrs
[
rndNr
]);
// collapse cell with chosen number;
hist
.
back
().
cell
->
collapse
(
validNrs
[
rndNr
]);
// collapse cell with chosen number;
hist
.
back
().
blocked
[
validNrs
[
rndNr
]]
++
;
hist
.
back
().
blocked
[
validNrs
[
rndNr
]]
++
;
}
}
...
@@ -128,7 +117,6 @@ void Window::solveButtonClicked()
...
@@ -128,7 +117,6 @@ void Window::solveButtonClicked()
else
if
(
minEtropy
==
0
)
else
if
(
minEtropy
==
0
)
{
{
qInfo
(
"backtracking"
);
backtracking
=
true
;
backtracking
=
true
;
continue
;
continue
;
}
}
...
@@ -146,14 +134,6 @@ void Window::solveButtonClicked()
...
@@ -146,14 +134,6 @@ void Window::solveButtonClicked()
}
}
}
}
}
}
inline
void
Window
::
delay
(
int
millisecondsWait
)
{
QEventLoop
loop
;
QTimer
t
;
t
.
connect
(
&
t
,
&
QTimer
::
timeout
,
&
loop
,
&
QEventLoop
::
quit
);
t
.
start
(
millisecondsWait
);
loop
.
exec
();
}
void
Window
::
clearButtonClicked
()
void
Window
::
clearButtonClicked
()
{
{
for
(
auto
&
x
:
grid
)
for
(
auto
&
x
:
grid
)
...
@@ -163,8 +143,3 @@ void Window::clearButtonClicked()
...
@@ -163,8 +143,3 @@ void Window::clearButtonClicked()
}
}
return
;
return
;
}
}
\ No newline at end of file
void
Window
::
setValue
(
int
s
)
{
delayTime
=
s
;
return
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
window.h
+
0
−
5
View file @
a27052f7
...
@@ -8,7 +8,6 @@ class QHBoxLayout;
...
@@ -8,7 +8,6 @@ class QHBoxLayout;
class
QVBoxLayout
;
class
QVBoxLayout
;
class
QGridLayout
;
class
QGridLayout
;
class
QPushButton
;
class
QPushButton
;
class
QSlider
;
class
Window
:
public
QWidget
class
Window
:
public
QWidget
{
{
Q_OBJECT
Q_OBJECT
...
@@ -18,9 +17,7 @@ public:
...
@@ -18,9 +17,7 @@ public:
private:
private:
QPushButton
*
clearButton
;
QPushButton
*
clearButton
;
QPushButton
*
solveButton
;
QPushButton
*
solveButton
;
QSlider
*
slider
;
std
::
array
<
Cell
,
81
>
grid
;
std
::
array
<
Cell
,
81
>
grid
;
int
delayTime
=
300
;
QSpacerItem
*
spacer
[
3
];
QSpacerItem
*
spacer
[
3
];
QHBoxLayout
*
horizontalLayout
;
QHBoxLayout
*
horizontalLayout
;
QVBoxLayout
*
verticalLayout
;
QVBoxLayout
*
verticalLayout
;
...
@@ -36,10 +33,8 @@ private:
...
@@ -36,10 +33,8 @@ private:
blocked
[
choice
]
++
;
blocked
[
choice
]
++
;
}
}
};
};
inline
void
delay
(
int
millisecondsWait
);
private
slots
:
private
slots
:
void
setValue
(
int
s
);
void
solveButtonClicked
();
void
solveButtonClicked
();
void
clearButtonClicked
();
void
clearButtonClicked
();
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment