BCESolve
bcegamehandler.hpp
1// This file is part of the BCESolve library for games of incomplete
2// information
3// Copyright (C) 2022 Benjamin A. Brooks
4//
5// BCESolve free software: you can redistribute it and/or modify it
6// under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// BCESolve is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see
17// <http://www.gnu.org/licenses/>.
18//
19// Benjamin A. Brooks
20// ben@benjaminbrooks.net
21// Chicago, IL
22
23#ifndef BCEGAMEHANDLER_HPP
24#define BCEGAMEHANDLER_HPP
25
26#include <QtWidgets>
27#include <QAbstractTableModel>
28#include <QTableView>
29#include "bcegame.hpp"
30#include "bcepayofftablemodel.hpp"
31// #include "bceprobabilitytablemodel.hpp"
32#include "bcetableview.hpp"
33#include "bcepriortablemodel.hpp"
34#include "bceconditionaltablemodel.hpp"
35#include "bceobjweightstablemodel.hpp"
36#include "bcepushbutton.hpp"
37#include "bceenumeration.hpp"
38
40
55class BCEGameHandler : public QMainWindow
56{
57 Q_OBJECT;
58 friend class BCEPlotHandler;
59
60private:
62
80
82
86
90
92 QVBoxLayout * layout;
93
95 QPushButton * solveButton;
97 QPushButton * cancelButton;
99 QPushButton *clearButton;
101 QPushButton *mapBoundaryButton;
102
103 // Edits
104
106 vector<QLineEdit*> numActionsEdits;
108 QLineEdit * numStatesEdit;
110 vector<QLineEdit*> numTypesEdits;
113
114 // Combo box
116 QComboBox * currentStateCombo;
117
118 // Tables
131
132public:
134
136 BCEGameHandler(QWidget *parent);
138
140
142
144 void setGame(const BCEGame & _game);
145
147 const BCEGame & getGame() const
148 { return game; }
149
151 QVBoxLayout * getLayout() const
152 { return layout; }
153
155 QPushButton * getSolveButton() const
156 { return solveButton; }
157
159 QPushButton * getCancelButton() const
160 { return cancelButton; }
161
163
165 void setState(int state);
167 const vector<double> getWeightsOnObjectives();
169
172 const vector<vector<double> > getMapBWeights();
174 const bool getMapBoundaryOption() const {
175 return mapBoundaryOption;
176 }
177 const double getMinAngleIncr() const {
178 return minAngleIncrement;
179 }
180
181
182private:
184
185 void initializeModels();
187 void changeNumberOfStates(int newS);
189 void setupLayout();
190
191private slots:
193 void currentStateChanged(int newS);
195 void stateAdded();
197 void actionAdded(int player);
199 void typeAdded(int player);
201 void typeRemoved(int player);
203 void objectiveAdded();
205 void objectiveRemoved();
207 void stateRemoved();
209
212 void actionRemoved(int player);
213
215 void nextState();
217 void prevState();
219 void emitSolveSignal();
221
222 void clearCurrentGame();
225 mapBoundaryOption = true;
226 emit(startSolveRoutine());
227 }
229 void setMinAngleIncr(QString strValue) {
230 double incr = strValue.toDouble();
231 std::cout << incr << std::endl;
232 minAngleIncrement = incr;
233 }
234
235signals:
236
238
242
243};
244
245
246#endif
Table models for BCEViewer.
Definition: bceconditionaltablemodel.hpp:41
This class handles the widgets for editing/displaying the game.
Definition: bcegamehandler.hpp:56
QPushButton * clearButton
Button that clears currently displayed game.
Definition: bcegamehandler.hpp:99
QPushButton * getCancelButton() const
Returns the cancelButton.
Definition: bcegamehandler.hpp:159
void stateRemoved()
Removes the current state.
Definition: bcegamehandler.cpp:742
BCEGameHandler(QWidget *parent)
Constructor.
Definition: bcegamehandler.cpp:25
void cancelSolveRoutine()
Signals that the user has clicked the cancel solve button.
void setGame(const BCEGame &_game)
Replaces the current game with _game.
Definition: bcegamehandler.cpp:459
BCEGame game
The game object.
Definition: bcegamehandler.hpp:67
void stateAdded()
Adds a new state. Calls changeNumberOfStates.
Definition: bcegamehandler.cpp:656
void setState(int state)
Changes the current state.
Definition: bcegamehandler.cpp:539
const bool getMapBoundaryOption() const
Returns mapBoundaryOption.
Definition: bcegamehandler.hpp:174
void initializeModels()
Delete old data models and create new ones.
Definition: bcegamehandler.cpp:505
QPushButton * mapBoundaryButton
Button handling map boundary solve option.
Definition: bcegamehandler.hpp:101
vector< QLineEdit * > numActionsEdits
Edits for number of actions.
Definition: bcegamehandler.hpp:106
const BCEGame & getGame() const
Returns constant reference to the current game.
Definition: bcegamehandler.hpp:147
BCEObjWeightsTableModel * obj1WeightsModel
Model for settings weights on objective1 for mapboundary.
Definition: bcegamehandler.hpp:79
BCEObjWeightsTableModel * weightsModel
Model for setting weights on main solver objectives.
Definition: bcegamehandler.hpp:75
const vector< vector< double > > getMapBWeights()
Returns weights on map boundary objectives.
Definition: bcegamehandler.cpp:802
BCETableView * obj0WeightsTableView
Table for displaying mapBoundary objective0 weights data.
Definition: bcegamehandler.hpp:128
void setupLayout()
Sets up the layout for the game handler.
Definition: bcegamehandler.cpp:32
void changeNumberOfStates(int newS)
Adds/removes models to achieve correct number of states.
Definition: bcegamehandler.cpp:478
~BCEGameHandler()
Destructor.
Definition: bcegamehandler.cpp:443
void objectiveAdded()
Adds an objective to the game.
Definition: bcegamehandler.cpp:636
double minAngleIncrement
Minimum Angle increment, used for mapBoundary()
Definition: bcegamehandler.hpp:89
void startSolveRoutine()
Signals that the user has clicked the solve button.
void objectiveRemoved()
Removes an objective from the game.
Definition: bcegamehandler.cpp:721
QPushButton * solveButton
Button that triggers solve routine.
Definition: bcegamehandler.hpp:95
void setMBSolveOption()
Solves the game and maps the boundary.
Definition: bcegamehandler.hpp:224
void prevState()
Decreases currentState to the previous state.
Definition: bcegamehandler.cpp:576
QLineEdit * numObjectivesEdit
Edit for number of objectives.
Definition: bcegamehandler.hpp:112
void typeAdded(int player)
Adds a new type for the indicated player.
Definition: bcegamehandler.cpp:610
BCEConditionalTableModel * conditionalModel
Model for interfacing with conditional distribution of types.
Definition: bcegamehandler.hpp:73
QVBoxLayout * layout
Layout for the game tab.
Definition: bcegamehandler.hpp:92
BCEPayoffTableModel * payoffModel
The model for interfacing with payoffs.
Definition: bcegamehandler.hpp:69
BCEObjWeightsTableModel * obj0WeightsModel
Model for setting weights on objective0 for mapboundary.
Definition: bcegamehandler.hpp:77
bool mapBoundaryOption
Map Boundary option.
Definition: bcegamehandler.hpp:84
void actionAdded(int player)
Adds a new action for the indicated player.
Definition: bcegamehandler.cpp:584
void currentStateChanged(int newS)
Slot for changing the state. Calls setState.
Definition: bcegamehandler.cpp:563
void clearCurrentGame()
Clears the game currently displayed in the game tab.
Definition: bcegamehandler.cpp:775
void emitSolveSignal()
Emits the startSolveRoutine signal to BCEWindow.
Definition: bcegamehandler.cpp:807
vector< QLineEdit * > numTypesEdits
Edit for number of types.
Definition: bcegamehandler.hpp:110
BCETableView * priorTableView
Table for displaying prior.
Definition: bcegamehandler.hpp:122
QComboBox * currentStateCombo
Drop down menu for selecting a state.
Definition: bcegamehandler.hpp:116
BCETableView * weightsTableView
Table for displaying main solver weights data.
Definition: bcegamehandler.hpp:126
QPushButton * getSolveButton() const
Returns the solveButton.
Definition: bcegamehandler.hpp:155
BCETableView * conditionalTableView
Table for displaying conditional distn of types.
Definition: bcegamehandler.hpp:124
QLineEdit * numStatesEdit
Edit for number of states.
Definition: bcegamehandler.hpp:108
void setMinAngleIncr(QString strValue)
Sets the minimum angle increment to the provided value.
Definition: bcegamehandler.hpp:229
const vector< double > getWeightsOnObjectives()
Returns weights on objectives.
Definition: bcegamehandler.cpp:798
void nextState()
Advances currentState to the next state.
Definition: bcegamehandler.cpp:568
BCEPriorTableModel * priorModel
Model for interfacing with prior.
Definition: bcegamehandler.hpp:71
BCETableView * obj1WeightsTableView
Table for displaying mapBoundary objective1 weights data.
Definition: bcegamehandler.hpp:130
void typeRemoved(int player)
Removes a type for the indicated player.
Definition: bcegamehandler.cpp:697
BCETableView * payoffTableView
Table for displaying stage payoffs.
Definition: bcegamehandler.hpp:120
QPushButton * cancelButton
Button that cancels solve.
Definition: bcegamehandler.hpp:97
QVBoxLayout * getLayout() const
Returns the layout.
Definition: bcegamehandler.hpp:151
void actionRemoved(int player)
Removes action for the given player.
Definition: bcegamehandler.cpp:672
The base class for games of incomplete information.
Definition: bcegame.hpp:40
Model for Objective Weights in the BCEViewer.
Definition: bceobjweightstablemodel.hpp:46
Derived class for payoff table models.
Definition: bcepayofftablemodel.hpp:43
This class handles all the plotting in the solution tab.
Definition: bceplothandler.hpp:46
Table models for BCEViewer.
Definition: bcepriortablemodel.hpp:40
Specialized table view for BCEViewer.
Definition: bcetableview.hpp:36