SGSolve
|
Class for implementing the twist algorithm within SGViewer. More...
#include <sgsolverworker.hpp>
Public Types | |
enum | STATUS { FAILED, CONVERGED, NOTCONVERGED } |
Code for status at the end of the iteration. More... | |
Public Slots | |
void | iterate () |
Iterates. More... | |
const SGSolution_MaxMinMax & | getSolution () const |
Returns the SGSolution object. | |
const SGSolver_MaxMinMax & | getSolver () const |
Returns the solver object. | |
Signals | |
void | resultReady (bool) |
Signal that gets emitted when iteration finishes. | |
void | exceptionCaught () |
Signal that gets emitted when an exception is caught. More... | |
Public Member Functions | |
SGSolverWorker (const SGEnv &_env, const SGGame &game, QTextEdit *_logTextEdit) | |
Constructor. More... | |
STATUS | getStatus () const |
Returns the status of the worker. | |
const QString & | getExceptionMsg () const |
Returns the exception message (if one is caught) | |
Public Attributes | |
enum SGSolverWorker::STATUS | status |
Private Attributes | |
const SGEnv & | env |
An environment object to hold settings. | |
SGSolver_MaxMinMax | solver |
The main object for performing calculations. | |
QTextEdit * | logTextEdit |
A pointer to the text edit in which to report progress. | |
int | numIter |
Number of iterations. | |
QString | exceptionMsg |
Exception message caught by solver. | |
Class for implementing the twist algorithm within SGViewer.
If we just used the SGSolver class to solve the game, the algorithm would run continuously until convergence or an error. Since we want regular status updates and we want to print progress to the log window, we have to reimplement the solver routine.
This class uses SGApprox to calculate the solution. The main program assigns this object to a separate thread to preserve responsiveness of the algorithm. After each iteration, control is returned to the main process, which prints a status update if a revolution has been completed and cancels the algorithm if the cancel flag has been thrown. Communication between the SGSolverWorker and SGMainWindow is facilitated by signals and slots.
|
inline |
Constructor.
Initializes the solver object. Waits for instruction to begin iteration via the SGSolverWorker_V2::iterate slot.
|
signal |
Signal that gets emitted when an exception is caught.
Not currently used.
|
inlineslot |
Iterates.
Runs one iteration of the twist algorithm and emits the resultReady signal.
enum SGSolverWorker::STATUS SGSolverWorker::status |
Current status.