BCESolve
bcecounter.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 BCECOUNTER_HPP
24#define BCECOUNTER_HPP
25
26#include "bcecommon.hpp"
27#include "bceexception.hpp"
28
30
40{
41private:
43
47
51
56 int state;
58 vector<int> actions;
60 vector<int> types;
62
66
68 vector<int> actionIndices;
70
72 vector<int> typeIndices;
73
75
79
82
84
85 vector<int> stateConditions;
87
89 vector< vector<int> > actionConditions;
91
93 vector< vector<int> > typeConditions;
94
96
100
102 vector<bool> actionMarginal;
104
106 vector<bool> typeMarginal;
107
111 vector<int> numActions;
113 vector<int> numTypes;
114
116 vector<int> actionIncrements;
118 vector<int> typeIncrements;
120 vector<int> actionDecrements;
122 vector<int> typeDecrements;
123
134
141
142public:
145
147
187 BCECounter(int _numStates,const vector<int> & _numActions,
188 const vector<int> & _numTypes,
189 const vector<int> &_stateConditions,
190 const vector< vector<int> > & _actionConditions,
191 const vector< vector<int> > & _typeConditions,
192 bool _stateMarginal,
193 const vector<bool> & _actionMarginal,
194 const vector<bool> & _typeMarginal):
195 numPlayers(2),
196 numStates(_numStates), numActions(_numActions),
197 numTypes(_numTypes), stateConditions(_stateConditions),
198 actionConditions(_actionConditions),
199 typeConditions(_typeConditions),
200 stateMarginal(_stateMarginal),
201 actionMarginal(_actionMarginal),
202 typeMarginal(_typeMarginal),
203 actions(2,0), types(2,0),
211 {
212 initialize();
213 }
214
216
223 void initialize();
224
226
229 bool operator++();
230
234 int getVariable() const { return variable; }
236 int getMarginal() const { return marginal; }
238 int getState() const { return state; }
240 const vector<int> & getTypes() const { return types; }
242 const vector<int> & getActions() const { return actions; }
243
244}; // BCECounter
245
246
247#endif
Class for iterating through arrays.
Definition: bcecounter.hpp:40
vector< int > typeIncrementsMarginal
Marginal index increment when types increase.
Definition: bcecounter.hpp:129
vector< int > actionIndices
Indices of the current actions.
Definition: bcecounter.hpp:68
vector< int > actionIncrementsStateType
State/type index increment when actions increase.
Definition: bcecounter.hpp:136
vector< int > stateConditions
Conditions on the state.
Definition: bcecounter.hpp:85
int numPlayers
The number of players, always 2.
Definition: bcecounter.hpp:54
vector< int > numTypes
Each player's number of types.
Definition: bcecounter.hpp:113
bool operator++()
Increments the counter.
Definition: bcecounter.cpp:171
int stateType
State/type counter.
Definition: bcecounter.hpp:52
BCECounter(int _numStates, const vector< int > &_numActions, const vector< int > &_numTypes, const vector< int > &_stateConditions, const vector< vector< int > > &_actionConditions, const vector< vector< int > > &_typeConditions, bool _stateMarginal, const vector< bool > &_actionMarginal, const vector< bool > &_typeMarginal)
Constructor.
Definition: bcecounter.hpp:187
vector< int > typeDecrements
Variable index decrement when actions decrease.
Definition: bcecounter.hpp:122
int getNumMarginal()
Returns the maximum marginal index.
Definition: bcecounter.hpp:232
vector< int > types
Current type profile.
Definition: bcecounter.hpp:60
vector< vector< int > > actionConditions
Conditions on the action profile.
Definition: bcecounter.hpp:89
vector< int > actionDecrements
Variable index decrement when actions decrease.
Definition: bcecounter.hpp:120
const vector< int > & getActions() const
Return the current vector of actions.
Definition: bcecounter.hpp:242
void initialize()
Initialization routine.
Definition: bcecounter.cpp:25
int getMarginal() const
Return the marginal index.
Definition: bcecounter.hpp:236
vector< int > typeIncrementsStateType
State/type index increment when types increase.
Definition: bcecounter.hpp:138
int numMarginalVariables
Maximum marginal index.
Definition: bcecounter.hpp:77
BCECounter()
Default constructor.
Definition: bcecounter.hpp:144
int marginal
Marginal counter.
Definition: bcecounter.hpp:49
int stateIndex
Index of the current state.
Definition: bcecounter.hpp:64
int numVariables
Maximum variable index.
Definition: bcecounter.hpp:81
vector< int > typeDecrementsMarginal
Marginal index decrement when types decrease.
Definition: bcecounter.hpp:133
int state
Current index of the state.
Definition: bcecounter.hpp:56
vector< bool > typeMarginal
Determines if types are marginal directions.
Definition: bcecounter.hpp:106
vector< int > numActions
Each player's number ofactions.
Definition: bcecounter.hpp:111
vector< int > typeIncrements
Variable index increment when types increase.
Definition: bcecounter.hpp:118
const vector< int > & getTypes() const
Return the current vector of types.
Definition: bcecounter.hpp:240
vector< bool > actionMarginal
Determines if actions are marginal dimensions.
Definition: bcecounter.hpp:102
vector< int > actionIncrements
Variable index increment when actions increase.
Definition: bcecounter.hpp:116
int getVariable() const
Return the variable index.
Definition: bcecounter.hpp:234
int stateIncrementMarginal
Marginal index increment when state increases.
Definition: bcecounter.hpp:125
vector< int > typeIndices
Indices of the current types.
Definition: bcecounter.hpp:72
vector< int > actionIncrementsMarginal
Marginal index increment when actions increase.
Definition: bcecounter.hpp:127
vector< vector< int > > typeConditions
Conditions on the type profile.
Definition: bcecounter.hpp:93
bool stateMarginal
Determines if the state is a marginal dimension.
Definition: bcecounter.hpp:98
int getState() const
Return the current state.
Definition: bcecounter.hpp:238
vector< int > actions
Current action profile.
Definition: bcecounter.hpp:58
vector< int > typeDecrementsStateType
State/type index decrement when types decrease.
Definition: bcecounter.hpp:140
int variable
Variable counter.
Definition: bcecounter.hpp:45
int numStates
The number of states.
Definition: bcecounter.hpp:109
vector< int > actionDecrementsMarginal
Marginal index decrement when actions decrease.
Definition: bcecounter.hpp:131