SGSolve
sgaction_pencilsharpening.hpp
1 // This file is part of the SGSolve library for stochastic games
2 // Copyright (C) 2019 Benjamin A. Brooks
3 //
4 // SGSolve free software: you can redistribute it and/or modify it
5 // under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // SGSolve is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see
16 // <http://www.gnu.org/licenses/>.
17 //
18 // Benjamin A. Brooks
19 // ben@benjaminbrooks.net
20 // Chicago, IL
21 
22 // Classes for storing data for stochastic games.
23 #ifndef _SGACTION_HPP
24 #define _SGACTION_HPP
25 
26 #include "sgcommon.hpp"
27 #include "sgtuple.hpp"
28 #include "sgenv.hpp"
29 #include "sggame.hpp"
30 #include "sgbaseaction.hpp"
31 
33 
43 {
44 private:
45  const SGEnv & env;
52 public:
54 
56  env(_env),
57  SGBaseAction()
58  {}
59 
61 
63  SGAction_PencilSharpening(const SGEnv & _env, int _state, int _action):
64  env(_env), SGBaseAction(_state,_action)
65  {
66  trimmedPoints.resize(2);
67  }
68 
70  const vector<SGTuple> & getTrimmedPoints() const { return trimmedPoints; }
71 
73 
76  void intersectRay(const SGPoint & pivot,
77  const SGPoint & direction);
79 
81  void intersectRaySegment(const SGPoint & pivot,
82  const SGPoint & direction,
83  int player);
84 
86  void intersectRaySegment(const SGPoint & pivot,
87  const SGPoint & direction,
88  SGTuple & segment);
89 
91  void trim(const SGPoint & pivot,
92  const SGPoint & direction);
93 
95  void calculateMinIC(const SGGame & game,
96  const vector<bool> & update,
97  const SGTuple & threatTuple);
98 
100  void updateTrim();
101 
103  double distToTrimmed() const;
104 
106 
107  void calculateBindingContinuations(const vector<bool> & updatedThreatTuple,
108  const SGGame & game,
109  const vector<SGTuple> & extremeTuples,
110  const SGTuple & threatTuple,
111  const SGTuple & pivot,
112  const SGPoint & currentDirection,
113  int oldWest);
114 
116 
119  static double calculateMinIC(int action,int state, int player,
120  const SGGame & game,
121  const SGTuple & threatTuple);
122 
123 }; // SGAction
124 
125 
126 #endif
SGAction_PencilSharpening::intersectRay
void intersectRay(const SGPoint &pivot, const SGPoint &direction)
Trims binding continuation segments.
Definition: sgaction_pencilsharpening.cpp:27
SGAction_PencilSharpening::trim
void trim(const SGPoint &pivot, const SGPoint &direction)
Trims the trimmedPoints using intersectRaySegment.
Definition: sgaction_pencilsharpening.cpp:34
SGAction_PencilSharpening::intersectRaySegment
void intersectRaySegment(const SGPoint &pivot, const SGPoint &direction, int player)
Static method to carry out trimming operations.
Definition: sgaction_pencilsharpening.cpp:69
SGAction_PencilSharpening::getTrimmedPoints
const vector< SGTuple > & getTrimmedPoints() const
Get method for trimmed points.
Definition: sgaction_pencilsharpening.hpp:70
SGAction_PencilSharpening::SGAction_PencilSharpening
SGAction_PencilSharpening(const SGEnv &_env, int _state, int _action)
Constructor.
Definition: sgaction_pencilsharpening.hpp:63
SGGame
Describes a stochastic game.
Definition: sggame.hpp:40
SGAction_PencilSharpening::trimmedPoints
vector< SGTuple > trimmedPoints
Definition: sgaction_pencilsharpening.hpp:49
SGBaseAction::state
int state
Definition: sgbaseaction.hpp:42
SGAction_PencilSharpening::env
const SGEnv & env
Definition: sgaction_pencilsharpening.hpp:45
SGEnv
Manages parameters for algorithm behavior.
Definition: sgenv.hpp:35
SGAction_PencilSharpening::SGAction_PencilSharpening
SGAction_PencilSharpening(const SGEnv &_env)
Constructor.
Definition: sgaction_pencilsharpening.hpp:55
std::vector< SGTuple >
Definition: sgstl.cpp:27
SGAction_PencilSharpening::calculateBindingContinuations
void calculateBindingContinuations(const vector< bool > &updatedThreatTuple, const SGGame &game, const vector< SGTuple > &extremeTuples, const SGTuple &threatTuple, const SGTuple &pivot, const SGPoint &currentDirection, int oldWest)
Calculates binding continuation values.
Definition: sgaction_pencilsharpening.cpp:187
SGPoint
A vector in .
Definition: sgpoint.hpp:35
SGAction_PencilSharpening::calculateMinIC
void calculateMinIC(const SGGame &game, const vector< bool > &update, const SGTuple &threatTuple)
Calculates the minimum incentive compatible continuation payoff.
Definition: sgaction_pencilsharpening.cpp:134
SGAction_PencilSharpening
Enhanced version of SGBaseAction.
Definition: sgaction_pencilsharpening.hpp:43
SGAction_PencilSharpening::distToTrimmed
double distToTrimmed() const
Calculates sup norm distance between comparable points and trimmed points.
Definition: sgaction_pencilsharpening.cpp:51
SGBaseAction
Describes an action in the game.
Definition: sgbaseaction.hpp:39
SGTuple
Definition: sgtuple.hpp:52
SGBaseAction::action
int action
Definition: sgbaseaction.hpp:43
SGAction_PencilSharpening::updateTrim
void updateTrim()
Sets points equal to the trimmed points.
Definition: sgaction_pencilsharpening.cpp:41