LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
stamina_model.h
Go to the documentation of this file.
1// -*-c++-*-
2
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa AKIYAMA
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
31
32#ifndef RCSC_PLAYER_STAMINA_MODEL_H
33#define RCSC_PLAYER_STAMINA_MODEL_H
34
35namespace rcsc {
36
37class PlayerType;
38class GameTime;
39
45private:
46
48 double M_stamina;
50 double M_effort;
52 double M_recovery;
54 double M_capacity;
55
56public:
61
66 void init( const PlayerType & player_type );
67
68 //
69 // accessor method
70 //
71
76 double stamina() const
77 {
78 return M_stamina;
79 }
80
85 double recovery() const
86 {
87 return M_recovery;
88 }
89
94 double effort() const
95 {
96 return M_effort;
97 }
98
103 double capacity() const
104 {
105 return M_capacity;
106 }
107
112 bool capacityIsEmpty() const
113 {
114 return M_capacity <= 1.0e-5
115 && M_capacity >= 0.0;
116 }
117
118 //
119 // interface for update
120 //
121
129 void updateBySenseBody( const double sensed_stamina,
130 const double sensed_effort,
131 const double sensed_capacity,
132 const GameTime & current );
133
142 const StaminaModel & setValues( const double new_stamina,
143 const double new_effort,
144 const double new_recovery,
145 const double new_capacity );
146
152 const StaminaModel & setStamina( const double new_stamina )
153 {
154 M_stamina = new_stamina;
155 return *this;
156 }
157
163 const StaminaModel & setEffort( const double new_effort )
164 {
165 M_effort = new_effort;
166 return *this;
167 }
173 const StaminaModel & setRecovery( const double new_recovery )
174 {
175 M_recovery = new_recovery;
176 return *this;
177 }
183 const StaminaModel & setCapacity( const double new_capacity )
184 {
185 M_capacity = new_capacity;
186 return *this;
187 }
188
189
190 //
191 // utility for prediction
192 //
193
198 void simulateWait( const PlayerType & player_type );
199
205 void simulateWaits( const PlayerType & player_type,
206 const int n_wait );
207
213 void simulateDash( const PlayerType & player_type,
214 const double & dash_power );
215
222 void simulateDashes( const PlayerType & player_type,
223 const int n_dash,
224 const double & dash_power );
225
233 void simulate( const PlayerType & player_type,
234 const int n_wait,
235 const int n_dash,
236 const double & dash_power );
237
245 double getSafetyDashPower( const PlayerType & player_type,
246 const double dash_power,
247 const double stamina_buffer = 1.0 ) const;
248};
249
250}
251
252#endif
game time object
Definition: game_time.h:43
heterogeneous player parametor class
Definition: player_type.h:50
stamina management class
Definition: stamina_model.h:44
bool capacityIsEmpty() const
check if stamina capacity is empty.
Definition: stamina_model.h:112
void init(const PlayerType &player_type)
initialize internal variables with server settings
StaminaModel()
init members by built-in values
void updateBySenseBody(const double sensed_stamina, const double sensed_effort, const double sensed_capacity, const GameTime &current)
update by sense_body information
void simulateDashes(const PlayerType &player_type, const int n_dash, const double &dash_power)
simulate stamina variables after nr dashes.
void simulateWaits(const PlayerType &player_type, const int n_wait)
simulate stamina variables after nr waits.
double capacity() const
get the current remained stamina capacity
Definition: stamina_model.h:103
double getSafetyDashPower(const PlayerType &player_type, const double dash_power, const double stamina_buffer=1.0) const
get dash power to save recovery
void simulateDash(const PlayerType &player_type, const double &dash_power)
simulate stamina variables after one dash.
const StaminaModel & setStamina(const double new_stamina)
set new stamina value
Definition: stamina_model.h:152
double recovery() const
get current recovery value
Definition: stamina_model.h:85
double effort() const
get current effort value
Definition: stamina_model.h:94
void simulate(const PlayerType &player_type, const int n_wait, const int n_dash, const double &dash_power)
simulate stamina variables
const StaminaModel & setCapacity(const double new_capacity)
set new stamina capacity value
Definition: stamina_model.h:183
const StaminaModel & setRecovery(const double new_recovery)
set new recovery value
Definition: stamina_model.h:173
double stamina() const
get current stamina value
Definition: stamina_model.h:76
const StaminaModel & setEffort(const double new_effort)
set new effort value
Definition: stamina_model.h:163
void simulateWait(const PlayerType &player_type)
simulate stamina variables after one wait.
const StaminaModel & setValues(const double new_stamina, const double new_effort, const double new_recovery, const double new_capacity)
set all values