#include <simulation.hpp>
Collaboration diagram for Simulation:
Public Member Functions | |
Simulation (SimulationView *view, SimulationManager *controller, Grid initialLayout, list< Rule > *rules, list< ForbiddenPattern > *patterns) | |
Constructor. | |
virtual | ~Simulation () |
Destructor. | |
bool | isFinished () |
Simulation status. | |
bool | nextStep (bool gui) |
Performs a simulation step. | |
void | nextRow () |
Asks the controller for another row to simulate. | |
void | results () |
Asks the controller to show the simulation results. | |
void | simulateAll () |
Simulates all the rows of the simulation. | |
void | resetSimulation (SimulationView *view, SimulationManager *controller, Grid initialLayout, list< Rule > *rules, list< ForbiddenPattern > *patterns) |
Sets the parameters for a new simulation. | |
list< simulationStep > | getStableLayouts () |
Returns the stable spaces. | |
list< Grid > | getProcessedLayouts () |
Returns the spaces simulated. | |
list< simulationStep > | getForbiddenLayouts () |
Returns the forbidden spaces. | |
list< simulationStep > | getCycles () |
Returns the cycle spaces. | |
Private Member Functions | |
list< coordinate > | findRule (Grid layout, Rule rule) |
Finds a rule in a space. | |
list< coordinate > | findPattern (Grid layout, ForbiddenPattern pattern) |
Finds a forbidden in a space. | |
Grid | applyRule (Grid layout, Rule rule, coordinate position) |
Applies a rule to a space. | |
bool | ruleApplicable (Grid layout, coordinate position, Rule rule) |
Finds if a rule is applicable in a certain coordinate of a space. | |
void | printRule (Rule rule) |
Prints a rule to the standard output. | |
void | printLayout (Grid layout) |
Prints a grid to the standard output. | |
bool | find (Grid initialLayout, list< Grid > *processedLayouts) |
Finds a grid on a grid list. | |
bool | patternApplicable (Grid layout, coordinate position, ForbiddenPattern pattern) |
Finds if a pattern is applicable in a certain coordinate of a space. | |
void | updateView () |
Updates the simulation view with flow control information. | |
Private Attributes | |
SimulationView * | view |
Simulation presentation layer. | |
SimulationManager * | controller |
Simulation controller. | |
list< simulationStep > * | finalLayouts |
List of stable layouts reached through the simulation. | |
list< simulationStep > * | patternsToSimulate |
List of patterns to still be simulated. | |
list< Grid > * | patternsSimulated |
List of spaces which already have been simulated. | |
list< simulationStep > * | forbiddenPatternsFound |
List of forbidden patterns found during the simulation. | |
list< simulationStep > * | cycles |
List of cycles found during the simulation. | |
list< Rule > * | rules |
List of rules to test. | |
list< ForbiddenPattern > * | patterns |
List of forbidden patterns to test. | |
bool | finished |
Is the simulation finished? | |
bool | simulating |
Are we in a step? | |
bool | stillRows |
There are more rows to simulate? |
This class is used to simulate rows of a truth table. It gets the initial configuration, the rules and forbidden patterns to use, and it simulates step by step until all the spaces have been simulated or an error occurs.
Definition at line 61 of file simulation.hpp.
|
Constructor.
Definition at line 35 of file simulation.cpp. References controller, cycles, finalLayouts, finished, forbiddenPatternsFound, patternsSimulated, patternsToSimulate, SimulationView::setGrid(), simulating, simulationStep::space, stillRows, and view. Here is the call graph for this function: ![]() |
|
Destructor.
Definition at line 58 of file simulation.cpp. |
|
Applies a rule to a space.
Definition at line 126 of file simulation.cpp. References Rule::getFinalGrid(), Rule::getHeight(), Rule::getInitialGrid(), Rule::getWidth(), nDISABLED, nDONTCARE, coordinate::x, and coordinate::y. Here is the call graph for this function: ![]() |
|
Finds a grid on a grid list.
Definition at line 269 of file simulation.cpp. |
|
Finds a forbidden in a space.
Definition at line 98 of file simulation.cpp. References Grid::getHeight(), Grid::getWidth(), and patternApplicable(). Referenced by nextStep(). Here is the call graph for this function: ![]() |
|
Finds a rule in a space.
Definition at line 70 of file simulation.cpp. References Grid::getHeight(), Grid::getWidth(), and ruleApplicable(). Here is the call graph for this function: ![]() |
|
Returns the cycle spaces.
Definition at line 660 of file simulation.cpp. References cycles. Referenced by SimulationManager::finishedRow(). |
|
Returns the forbidden spaces.
Definition at line 643 of file simulation.cpp. References forbiddenPatternsFound. Referenced by SimulationManager::finishedRow(). |
|
Returns the spaces simulated.
Definition at line 625 of file simulation.cpp. References patternsSimulated. Referenced by SimulationManager::finishedRow(). |
|
Returns the stable spaces.
Definition at line 610 of file simulation.cpp. References finalLayouts. Referenced by SimulationManager::finishedRow(). |
|
Simulation status.
Definition at line 335 of file simulation.cpp. References finished. |
|
Asks the controller for another row to simulate.
Definition at line 579 of file simulation.cpp. References controller, SimulationView::enableSimulation(), SimulationManager::nextRow(), SimulationView::setNextRow(), SimulationView::setResults(), SimulationManager::simulateRow(), and view. Referenced by SimulationView::OnNext(). Here is the call graph for this function: ![]() |
|
Performs a simulation step. It gets a space to be simulated, checks if it's a valid space, that is, it does not have any forbidden pattern. Then searches for rules to apply to it. If it does not find any rule, it saves the space as a stable layout. Otherwise, it applies the rules it finds, and queue the new spaces to be simulated if they're not repeated.
Definition at line 355 of file simulation.cpp. References findPattern(), finished, patterns, patternsSimulated, patternsToSimulate, SimulationView::setGrid(), SimulationView::setInfo(), simulating, simulationStep::space, updateView(), and view. Referenced by SimulationView::OnStep(), SimulationView::OnTimer(), and simulateAll(). Here is the call graph for this function: ![]() |
|
Finds if a pattern is applicable in a certain coordinate of a space.
Definition at line 289 of file simulation.cpp. References Grid::getWidth(), ForbiddenPattern::getWidth(), and coordinate::x. Referenced by findPattern(). Here is the call graph for this function: ![]() |
|
Prints a grid to the standard output. This is for debugging purposes only.
Definition at line 246 of file simulation.cpp. References Grid::getWidth(). Here is the call graph for this function: ![]() |
|
Prints a rule to the standard output. This is for debugging purposes only.
Definition at line 208 of file simulation.cpp. References Rule::getWidth(). Here is the call graph for this function: ![]() |
|
Sets the parameters for a new simulation.
Definition at line 679 of file simulation.cpp. References controller, cycles, finalLayouts, finished, forbiddenPatternsFound, patternsSimulated, patternsToSimulate, SimulationView::setGrid(), simulationStep::space, stillRows, SimulationView::stopSimulation(), and view. Here is the call graph for this function: ![]() |
|
Asks the controller to show the simulation results.
Definition at line 598 of file simulation.cpp. References controller, and SimulationManager::results(). Referenced by SimulationView::OnResults(). Here is the call graph for this function: ![]() |
|
Finds if a rule is applicable in a certain coordinate of a space.
Definition at line 160 of file simulation.cpp. References Grid::getWidth(), Rule::getWidth(), and coordinate::x. Referenced by findRule(). Here is the call graph for this function: ![]() |
|
Simulates all the rows of the simulation. This method simulates all the rows in a shot, without the timer and user interactivity. Useful for quick simulations. Definition at line 709 of file simulation.cpp. References controller, SimulationView::enableSimulation(), finished, SimulationManager::nextRow(), nextStep(), SimulationView::setNextRow(), SimulationView::setResults(), SimulationManager::simulateRow(), stillRows, and view. Referenced by SimulationView::OnForward(). Here is the call graph for this function: ![]() |
|
Updates the simulation view with flow control information. This method updates the view to allow the user simulate other rows and view the simulation results when the simulation is over. Definition at line 558 of file simulation.cpp. References controller, SimulationView::enableSimulation(), finished, SimulationManager::nextRow(), SimulationView::setNextRow(), SimulationView::setResults(), and view. Referenced by nextStep(). Here is the call graph for this function: ![]() |
|
Simulation controller.
Definition at line 90 of file simulation.hpp. Referenced by nextRow(), resetSimulation(), results(), simulateAll(), Simulation(), and updateView(). |
|
List of cycles found during the simulation.
Definition at line 100 of file simulation.hpp. Referenced by getCycles(), resetSimulation(), and Simulation(). |
|
List of stable layouts reached through the simulation.
Definition at line 92 of file simulation.hpp. Referenced by getStableLayouts(), resetSimulation(), and Simulation(). |
|
Is the simulation finished?
Definition at line 106 of file simulation.hpp. Referenced by isFinished(), nextStep(), resetSimulation(), simulateAll(), Simulation(), and updateView(). |
|
List of forbidden patterns found during the simulation.
Definition at line 98 of file simulation.hpp. Referenced by getForbiddenLayouts(), resetSimulation(), and Simulation(). |
|
List of forbidden patterns to test.
Definition at line 104 of file simulation.hpp. Referenced by nextStep(). |
|
List of spaces which already have been simulated.
Definition at line 96 of file simulation.hpp. Referenced by getProcessedLayouts(), nextStep(), resetSimulation(), and Simulation(). |
|
List of patterns to still be simulated.
Definition at line 94 of file simulation.hpp. Referenced by nextStep(), resetSimulation(), and Simulation(). |
|
List of rules to test.
Definition at line 102 of file simulation.hpp. |
|
Are we in a step?
Definition at line 108 of file simulation.hpp. Referenced by nextStep(), and Simulation(). |
|
There are more rows to simulate?
Definition at line 110 of file simulation.hpp. Referenced by resetSimulation(), simulateAll(), and Simulation(). |
|
Simulation presentation layer.
Definition at line 88 of file simulation.hpp. Referenced by nextRow(), nextStep(), resetSimulation(), simulateAll(), Simulation(), and updateView(). |