Phoenix2D-Library  0.10
Self.cpp
Go to the documentation of this file.
1 /*
2  * Phoenix2D (RoboCup Soccer Simulation 2D League)
3  * Copyright (c) 2013 Ivan Gonzalez
4  *
5  * This file is part of Phoenix2D.
6  *
7  * Phoenix2D is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * Phoenix2D is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Phoenix2D. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <cstdlib>
22 #include <sstream>
23 #include <cmath>
24 #include <algorithm>
25 #include <iostream>
26 #include <boost/regex.hpp>
27 #include <boost/circular_buffer.hpp>
28 #include "Command.h"
29 #include "Config.h"
30 #include "Self.h"
31 #include "Normal.h"
32 #include "Server.h"
33 #include "Game.h"
34 namespace Phoenix
35 {
36 int *types_id;
39 double *player_decay;
42 double *player_size;
44 double *kick_rand;
45 double *extra_stamina;
46 double *effort_max;
47 double *effort_min;
51 
52 double u[3] = {0.0, 0.0, 0.0};
53 
54 boost::regex sense_body_regex("^\\(sense_body\\s+\\d+\\s+"
55  "\\(view_mode\\s+(\\w+)\\s+(\\w+)\\)\\s*" //group 1 group 2
56  "\\(stamina\\s+([\\d\\.\\-e]+)\\s+([\\d\\.\\-e]+)\\s+([\\d\\.\\-e]+)\\)\\s*" //\\-\\d+|\\d+\\.\\d+ //group 3 group 4 group 5
57  "\\(speed\\s+([\\d\\.\\-e]+)\\s+([\\d\\.\\-e]+)\\)\\s*" //group 6 group 7
58  "\\(head_angle\\s+([\\d\\.\\-e]+)\\)\\s*" //group 8
59  "\\(kick\\s+(\\d+)\\)\\s*" //group 9
60  "\\(dash\\s+(\\d+)\\)\\s*" //group 10
61  "\\(turn\\s+(\\d+)\\)\\s*" //group 11
62  "\\(say\\s+(\\d+)\\)\\s*" //group 12
63  "\\(turn_neck\\s+(\\d+)\\)\\s*" //group 13
64  "\\(catch\\s+(\\d+)\\)\\s*" //group 14
65  "\\(move\\s+(\\d+)\\)\\s*" //group 15
66  "\\(change_view\\s+(\\d+)\\)\\s*" //group 16
67  "\\(arm\\s+"
68  "\\(movable\\s+(\\d+)\\)\\s*" //group 17
69  "\\(expires\\s+(\\d+)\\)\\s*" //group 18
70  "\\(target\\s+([\\d\\.\\-e]+)\\s+([\\d\\.\\-e]+)\\)\\s*" //group 19 20
71  "\\(count\\s+(\\d+)\\)\\s*" //group 21
72  "\\)\\s*"
73  "\\(focus\\s+"
74  "\\(target\\s+(none|[lr]\\s+\\d+)\\)\\s*" //group 22
75  "\\(count\\s+(\\d+)\\)\\s*" //group 23
76  "\\)\\s*"
77  "\\(tackle\\s+"
78  "\\(expires\\s+(\\d+)\\)\\s*" //group 24
79  "\\(count\\s+(\\d+)\\)\\s*" //group 25
80  "\\)\\s*"
81  "\\(collision\\s+(none|\\(ball\\)|\\(player\\)|\\(post\\)|\\s)+\\)\\s*" //group 26
82  "\\(foul\\s+"
83  "\\(charged\\s+(\\d+)\\)\\s*" //group 27
84  "\\(card\\s+(none|yellow|red)\\)\\s*" //group 28
85  "\\)\\s*"
86 "\\)$");
87 
88 bool positioned = false;
89 static double x = 0.0;
90 static double y = 0.0;
91 static double theta = 0.0;
92 static std::list<Command*> last_commands_sent;
93 static boost::circular_buffer<std::string> view_mode_width_buffer(Config::BUFFER_MAX_HISTORY, "normal");
94 static boost::circular_buffer<std::string> view_mode_quality_buffer(Config::BUFFER_MAX_HISTORY, "high");
95 static boost::circular_buffer<double> stamina_buffer(Config::BUFFER_MAX_HISTORY, 0.0);
96 static boost::circular_buffer<double> effort_buffer(Config::BUFFER_MAX_HISTORY, 0.0);
97 static boost::circular_buffer<double> stamina_capacity_buffer(Config::BUFFER_MAX_HISTORY, 0.0);
98 static boost::circular_buffer<double> amount_of_speed_buffer(Config::BUFFER_MAX_HISTORY, 0.0);
99 static boost::circular_buffer<double> direction_of_speed_buffer(Config::BUFFER_MAX_HISTORY, 0.0);
100 static boost::circular_buffer<double> head_angle_buffer(Config::BUFFER_MAX_HISTORY, 0.0);
101 static boost::circular_buffer<int> kick_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
102 static boost::circular_buffer<int> dash_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
103 static boost::circular_buffer<int> turn_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
104 static boost::circular_buffer<int> say_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
105 static boost::circular_buffer<int> turn_neck_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
106 static boost::circular_buffer<int> catch_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
107 static boost::circular_buffer<int> move_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
108 static boost::circular_buffer<int> change_view_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
109 static boost::circular_buffer<int> arm_movable_buffer(Config::BUFFER_MAX_HISTORY, 0);
110 static boost::circular_buffer<int> arm_expires_buffer(Config::BUFFER_MAX_HISTORY, 0);
111 static boost::circular_buffer<double> arm_dist_buffer(Config::BUFFER_MAX_HISTORY, 0.0);
112 static boost::circular_buffer<double> arm_dir_buffer(Config::BUFFER_MAX_HISTORY, 0.0);
113 static boost::circular_buffer<int> arm_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
114 static boost::circular_buffer<std::string> focus_target_buffer(Config::BUFFER_MAX_HISTORY, "none");
115 static boost::circular_buffer<int> focus_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
116 static boost::circular_buffer<int> tackle_expires_buffer(Config::BUFFER_MAX_HISTORY, 0);
117 static boost::circular_buffer<int> tackle_count_buffer(Config::BUFFER_MAX_HISTORY, 0);
118 std::list<std::string> empty_vector;
119 static boost::circular_buffer<std::list<std::string> > collisions_buffer(Config::BUFFER_MAX_HISTORY, empty_vector);
120 static boost::circular_buffer<int> foul_charged_buffer(Config::BUFFER_MAX_HISTORY, 0);
121 static boost::circular_buffer<std::string> foul_card_buffer(Config::BUFFER_MAX_HISTORY, "none");
122 
123 double Self::PI = 3.14159265359;
124 
125 std::string Self::TEAM_NAME = "Phoenix2D";
126 int Self::UNIFORM_NUMBER = 1;
127 std::string Self::SIDE = "l";
133 double Self::EFFORT_MAX_DELTA_FACTOR = -0.004;
134 double Self::EFFORT_MIN_DELTA_FACTOR = -0.004;
135 double Self::EXTRA_STAMINA_DELTA_MAX = 50.0;
136 double Self::EXTRA_STAMINA_DELTA_MIN = 0.0;
141 double Self::KICK_RAND_DELTA_FACTOR = 1.0;
143 double Self::KICKABLE_MARGIN_DELTA_MIN = -0.1;
145 double Self::NEW_DASH_POWER_RATE_DELTA_MIN = -0.0012;
147 double Self::PLAYER_DECAY_DELTA_MAX = 0.1;
148 double Self::PLAYER_DECAY_DELTA_MIN = -0.1;
149 double Self::PLAYER_SIZE_DELTA_FACTOR = -100.0;
152 int Self::PLAYER_TYPES = 18;
153 int Self::PT_MAX = 1;
154 int Self::RANDOM_SEED = 1325632690;
156 int Self::SUBS_MAX = 3;
157 int Self::TYPE_ID = 0;
158 double Self::PLAYER_SPEED_MAX = 1.05;
159 double Self::STAMINA_INC_MAX = 45.0;
160 double Self::PLAYER_DECAY = 0.4;
161 double Self::INERTIA_MOMENT = 5.0;
162 double Self::DASH_POWER_RATE = 0.006;
163 double Self::PLAYER_SIZE = 0.3;
164 double Self::KICKABLE_MARGIN = 0.7;
165 double Self::KICK_RAND = 0.1;
166 double Self::EXTRA_STAMINA = 50.0;
167 double Self::EFFORT_MAX = 1.0;
168 double Self::EFFORT_MIN = 0.6;
169 double Self::KICK_POWER_RATE = 0.027;
170 double Self::FOUL_DETECT_PROBABILITY = 0.5;
171 double Self::CATCHABLE_AREA_L_STRETCH = 1.0;
172 std::string Self::VIEW_MODE_WIDTH = "high";
173 std::string Self::VIEW_MODE_QUALITY = "normal";
174 double Self::STAMINA = 8000.0;
175 double Self::EFFORT = 1.0;
176 double Self::STAMINA_CAPACITY = 130600.0;
177 double Self::AMOUNT_OF_SPEED = 0.0;
178 double Self::DIRECTION_OF_SPEED = 0.0;
179 double Self::HEAD_ANGLE = 0.0;
180 int Self::KICK_COUNT = 0;
181 int Self::DASH_COUNT = 0;
182 int Self::TURN_COUNT = 0;
183 int Self::SAY_COUNT = 0;
184 int Self::TURN_NECK_COUNT = 0;
185 int Self::CATCH_COUNT = 0;
186 int Self::MOVE_COUNT = 0;
188 int Self::ARM_MOVABLE = 0;
189 int Self::ARM_EXPIRES = 0;
190 double Self::ARM_DIST = 0.0;
191 double Self::ARM_DIR = 0.0;
192 int Self::ARM_COUNT = 0;
193 std::string Self::FOCUS_TARGET = "none";
194 int Self::FOCUS_COUNT = 0;
195 int Self::TACKLE_EXPIRES = 0;
196 int Self::TACKLE_COUNT = 0;
197 std::list<std::string> Self::COLLISION; //empty
198 int Self::FOUL_CHARGED = 0;
199 std::string Self::FOUL_CARD = "none";
200 
201 std::string getPlayerTypeParameter(const std::string &player_type, std::string parameter) {
202  boost::regex parameter_regex("\\(" + parameter + "\\s+([\\w\\-\\.]+)\\)");
203  boost::cmatch match;
204  if (boost::regex_search(player_type.c_str(), match, parameter_regex)) {
205  std::string param = std::string() + match[1];
206  return param;
207  } else {
208  std::cerr << "Self::getParameter(string, string) -> search failed miserably for parameter " << parameter << std::endl;
209  return "";
210  }
211 }
212 
213 std::string getPlayerParameter(const std::string &player_params, std::string parameter) {
214  boost::regex parameter_regex("\\(" + parameter + "\\s+([\\w\\-\\.]+)\\)");
215  boost::cmatch match;
216  if (boost::regex_search(player_params.c_str(), match, parameter_regex)) {
217  std::string param = std::string() + match[1];
218  return param;
219  } else {
220  std::cerr << "Self::getParameter(string) -> search failed miserably for parameter " << parameter << std::endl;
221  return "";
222  }
223 }
224 
225 Self::Self(std::string player_params, std::string team_name, int unum, std::string side) {
226  Self::TEAM_NAME = team_name;
227  Self::UNIFORM_NUMBER = unum;
228  Self::SIDE = side;
229  Self::ALLOW_MULT_DEFAULT_TYPE = atoi((getPlayerParameter(player_params, "allow_mult_default_type")).c_str());
230  Self::CATCHABLE_AREA_L_STRECH_MAX = atof((getPlayerParameter(player_params, "catchable_area_l_stretch_max")).c_str());
231  Self::CATCHABLE_AREA_L_STRECH_MIN = atof((getPlayerParameter(player_params, "catchable_area_l_stretch_min")).c_str());
232  Self::DASH_POWER_RATE_DELTA_MAX = atof((getPlayerParameter(player_params, "dash_power_rate_delta_max")).c_str());
233  Self::DASH_POWER_RATE_DELTA_MIN = atof((getPlayerParameter(player_params, "dash_power_rate_delta_min")).c_str());
234  Self::EFFORT_MAX_DELTA_FACTOR = atof((getPlayerParameter(player_params, "effort_max_delta_factor")).c_str());
235  Self::EFFORT_MIN_DELTA_FACTOR = atof((getPlayerParameter(player_params, "effort_min_delta_factor")).c_str());
236  Self::EXTRA_STAMINA_DELTA_MAX = atof((getPlayerParameter(player_params, "extra_stamina_delta_max")).c_str());
237  Self::EXTRA_STAMINA_DELTA_MIN = atof((getPlayerParameter(player_params, "extra_stamina_delta_min")).c_str());
238  Self::FOUL_DETECT_PROBABILITY_DELTA_FACTOR = atof((getPlayerParameter(player_params, "foul_detect_probability_delta_factor")).c_str());
239  Self::INERTIA_MOMENT_DELTA_FACTOR = atof((getPlayerParameter(player_params, "inertia_moment_delta_factor")).c_str());
240  Self::KICK_POWER_RATE_DELTA_MAX = atof((getPlayerParameter(player_params, "kick_power_rate_delta_max")).c_str());
241  Self::KICK_POWER_RATE_DELTA_MIN = atof((getPlayerParameter(player_params, "kick_power_rate_delta_min")).c_str());
242  Self::KICK_RAND_DELTA_FACTOR = atof((getPlayerParameter(player_params, "kick_rand_delta_factor")).c_str());
243  Self::KICKABLE_MARGIN_DELTA_MAX = atof((getPlayerParameter(player_params, "kickable_margin_delta_max")).c_str());
244  Self::KICKABLE_MARGIN_DELTA_MIN = atof((getPlayerParameter(player_params, "kickable_margin_delta_min")).c_str());
245  Self::NEW_DASH_POWER_RATE_DELTA_MAX = atof((getPlayerParameter(player_params, "new_dash_power_rate_delta_max")).c_str());
246  Self::NEW_DASH_POWER_RATE_DELTA_MIN = atof((getPlayerParameter(player_params, "new_dash_power_rate_delta_min")).c_str());
247  Self::NEW_STAMINA_INC_MAX_DELTA_FACTOR = atof((getPlayerParameter(player_params, "new_stamina_inc_max_delta_factor")).c_str());
248  Self::PLAYER_DECAY_DELTA_MAX = atof((getPlayerParameter(player_params, "player_decay_delta_max")).c_str());
249  Self::PLAYER_DECAY_DELTA_MIN = atof((getPlayerParameter(player_params, "player_decay_delta_min")).c_str());
250  Self::PLAYER_SIZE_DELTA_FACTOR = atof((getPlayerParameter(player_params, "player_size_delta_factor")).c_str());
251  Self::PLAYER_SPEED_MAX_DELTA_MAX = atof((getPlayerParameter(player_params, "player_speed_max_delta_max")).c_str());
252  Self::PLAYER_SPEED_MAX_DELTA_MIN = atof((getPlayerParameter(player_params, "player_speed_max_delta_min")).c_str());
253  Self::PLAYER_TYPES = atoi((getPlayerParameter(player_params, "player_types")).c_str());
254  Self::PT_MAX = atoi((getPlayerParameter(player_params, "pt_max")).c_str());
255  Self::RANDOM_SEED = atoi((getPlayerParameter(player_params, "random_seed")).c_str());
256  Self::STAMINA_INC_MAX_DELTA_FACTOR = atof((getPlayerParameter(player_params, "stamina_inc_max_delta_factor")).c_str());
257  Self::SUBS_MAX = atoi((getPlayerParameter(player_params, "subs_max")).c_str());
258  types_id = new int[Self::PLAYER_TYPES];
259  player_speed_max = new double[Self::PLAYER_TYPES];
260  stamina_inc_max = new double[Self::PLAYER_TYPES];
261  player_decay = new double[Self::PLAYER_TYPES];
262  inertia_moment = new double[Self::PLAYER_TYPES];
263  dash_power_rate = new double[Self::PLAYER_TYPES];
264  player_size = new double[Self::PLAYER_TYPES];
265  kickable_margin = new double[Self::PLAYER_TYPES];
266  kick_rand = new double[Self::PLAYER_TYPES];
267  extra_stamina = new double[Self::PLAYER_TYPES];
268  effort_max = new double[Self::PLAYER_TYPES];
269  effort_min = new double[Self::PLAYER_TYPES];
270  kick_power_rate = new double[Self::PLAYER_TYPES];
273  if (side.compare("r")) {
274  theta = 180.0;
275  }
277 }
278 
280  if (Config::VERBOSE) std::cout << "Self out" << std::endl;
281  if (types_id) delete[] types_id;
282  if (player_speed_max) delete[] player_speed_max;
283  if (stamina_inc_max) delete[] stamina_inc_max;
284  if (player_decay) delete[] player_decay;
285  if (inertia_moment) delete[] inertia_moment;
286  if (dash_power_rate) delete[] dash_power_rate;
287  if (player_size) delete[] player_size;
288  if (kickable_margin) delete[] kickable_margin;
289  if (kick_rand) delete[] kick_rand;
290  if (extra_stamina) delete[] extra_stamina;
291  if (effort_max) delete[] effort_max;
292  if (effort_min) delete[] effort_min;
293  if (kick_power_rate) delete[] kick_power_rate;
296 }
297 
298 void Self::addPlayerType(std::string player_type) {
299  int id = atoi((getPlayerTypeParameter(player_type, "id")).c_str());
300  types_id[id] = id;
301  player_speed_max[id] = atof((getPlayerTypeParameter(player_type, "player_speed_max")).c_str());
302  stamina_inc_max[id] = atof((getPlayerTypeParameter(player_type, "stamina_inc_max")).c_str());
303  player_decay[id] = atof((getPlayerTypeParameter(player_type, "player_decay")).c_str());
304  inertia_moment[id] = atof((getPlayerTypeParameter(player_type, "inertia_moment")).c_str());
305  dash_power_rate[id] = atof((getPlayerTypeParameter(player_type, "dash_power_rate")).c_str());
306  player_size[id] = atof((getPlayerTypeParameter(player_type, "player_size")).c_str());
307  kickable_margin[id] = atof((getPlayerTypeParameter(player_type, "player_size")).c_str());
308  kick_rand[id] = atof((getPlayerTypeParameter(player_type, "kick_rand")).c_str());
309  extra_stamina[id] = atof((getPlayerTypeParameter(player_type, "extra_stamina")).c_str());
310  effort_max[id] = atof((getPlayerTypeParameter(player_type, "effort_max")).c_str());
311  effort_min[id] = atof((getPlayerTypeParameter(player_type, "effort_min")).c_str());
312  kick_power_rate[id] = atof((getPlayerTypeParameter(player_type, "kick_power_rate")).c_str());
313  foul_detect_probability[id] = atof((getPlayerTypeParameter(player_type, "foul_detect_probability")).c_str());
314  catchable_area_l_stretch[id] = atof((getPlayerTypeParameter(player_type, "catchable_area_l_stretch")).c_str());
315 }
316 
317 void Self::processSenseBody(std::string sense_body) {
318  u[0] = u[1] = u[2] = 0.0;
319  boost::cmatch match;
320  if (boost::regex_match(sense_body.c_str(), match, sense_body_regex)) {
321  Command* kick_ptr = 0;
322  Command* dash_ptr = 0;
323  Command* turn_ptr = 0;
324  Command* say_ptr = 0;
325  Command* turn_neck_ptr = 0;
326  Command* catch_ptr = 0;
327  Command* move_ptr = 0;
328  Command* change_view_ptr = 0;
329  Command* point_to_ptr = 0;
330  Command* tackle_ptr = 0;
331  for (std::list<Command*>::iterator it = last_commands_sent.begin(); it != last_commands_sent.end(); ++it) {
332  switch ((*it)->getCommandType()) {
333  case KICK:
334  kick_ptr = *it;
335  break;
336  case DASH:
337  dash_ptr = *it;
338  break;
339  case TURN:
340  turn_ptr = *it;
341  break;
342  case SAY:
343  say_ptr = *it;
344  break;
345  case TURN_NECK:
346  turn_neck_ptr = *it;
347  break;
348  case CATCH:
349  catch_ptr = *it;
350  break;
351  case MOVE:
352  move_ptr = *it;
353  break;
354  case CHANGE_VIEW:
355  change_view_ptr = *it;
356  break;
357  case POINT:
358  point_to_ptr = *it;
359  break;
360  case TACKLE:
361  tackle_ptr = *it;
362  break;
363  default:
364  break;
365  }
366  }
367  //view_mode_quality
368  Self::VIEW_MODE_QUALITY = match[1];
370  //view_mode_width
371  Self::VIEW_MODE_WIDTH = match[2];
373  //stamina
374  Self::STAMINA = atof((std::string() + match[3]).c_str());
375  stamina_buffer.push_front(Self::STAMINA);
376  //effort
377  Self::EFFORT = atof((std::string() + match[4]).c_str());
378  effort_buffer.push_front(Self::EFFORT);
379  //stamina_capacity
380  Self::STAMINA_CAPACITY = atof((std::string() + match[5]).c_str());
382  //amount_of_speed
383  Self::AMOUNT_OF_SPEED = atof((std::string() + match[6]).c_str());
385  //direction_of_speed
386  Self::DIRECTION_OF_SPEED = atof((std::string() + match[7]).c_str());
388  //head_angle
389  Self::HEAD_ANGLE = atof((std::string() + match[8]).c_str());
391  //kick_count
392  Self::KICK_COUNT = atoi((std::string() + match[9]).c_str());
394  if (kick_ptr) kick_ptr->changeStatusTo(EXECUTED);
395  }
397  //dash_count
398  Self::DASH_COUNT = atoi((std::string() + match[10]).c_str());
400  if (dash_ptr) {
401  u[0] = dash_ptr->getDashPower();
402  u[1] = dash_ptr->getDashDirection();
403  dash_ptr->changeStatusTo(EXECUTED);
404  }
405  }
407  //turn_count
408  Self::TURN_COUNT = atoi((std::string() + match[11]).c_str());
410  if (turn_ptr) {
411  u[2] = turn_ptr->getTurnMoment();
412  turn_ptr->changeStatusTo(EXECUTED);
413  }
414  }
416  //say_count
417  Self::SAY_COUNT = atoi((std::string() + match[12]).c_str());
419  if (say_ptr) say_ptr->changeStatusTo(EXECUTED);
420  }
421  say_count_buffer.push_front(Self::SAY_COUNT);
422  //turn_neck_count
423  Self::TURN_NECK_COUNT = atoi((std::string() + match[13]).c_str());
425  if (turn_neck_ptr) turn_neck_ptr->changeStatusTo(EXECUTED);
426  }
428  //catch_count
429  Self::CATCH_COUNT = atoi((std::string() + match[14]).c_str());
431  if (catch_ptr) catch_ptr->changeStatusTo(EXECUTED);
432  }
434  //move_count
435  Self::MOVE_COUNT = atoi((std::string() + match[15]).c_str());
437  if (move_ptr) {
438  x = move_ptr->getMoveX();
439  y = move_ptr->getMoveY();
440  positioned = true;
441  move_ptr->changeStatusTo(EXECUTED);
442  }
443  }
445  //change_view_count
446  Self::CHANGE_VIEW_COUNT = atoi((std::string() + match[16]).c_str());
448  if (change_view_ptr) change_view_ptr->changeStatusTo(EXECUTED);
449  }
451  //arm_movable
452  Self::ARM_MOVABLE = atoi((std::string() + match[17]).c_str());
454  //arm_expires
455  Self::ARM_EXPIRES = atoi((std::string() + match[18]).c_str());
457  //arm_dist
458  Self::ARM_DIST = atof((std::string() + match[19]).c_str());
459  arm_dist_buffer.push_front(Self::ARM_DIST);
460  //arm_dir
461  Self::ARM_DIR = atof((std::string() + match[20]).c_str());
462  arm_dir_buffer.push_front(Self::ARM_DIR);
463  //arm_count
464  Self::ARM_COUNT = atoi((std::string() + match[21]).c_str());
466  if (point_to_ptr) point_to_ptr->changeStatusTo(EXECUTED);
467  }
468  arm_count_buffer.push_front(Self::ARM_COUNT);
469  //focus_target
470  Self::FOCUS_TARGET = match[22];
472  //focus_count
473  Self::FOCUS_COUNT = atoi((std::string() + match[23]).c_str());
475  //tackle_expires
476  Self::TACKLE_EXPIRES = atoi((std::string() + match[24]).c_str());
478  //tackle_count
479  Self::TACKLE_COUNT = atoi((std::string() + match[25]).c_str());
481  if (tackle_ptr) tackle_ptr->changeStatusTo(EXECUTED);
482  }
484  //collisions
485  std::string stream = std::string() + match[26];
486  std::stringstream ss(stream);
487  std::string token;
488  std::list<std::string> collisions;
489  while(std::getline(ss, token, ' ')) {
490  collisions.push_back(token);
491  }
492  Self::COLLISION = collisions;
494  //foul_charged
495  Self::FOUL_CHARGED = atoi((std::string() + match[27]).c_str());
497  //foul_card
498  Self::FOUL_CARD = match[28];
499  foul_card_buffer.push_front(Self::FOUL_CARD);
500  } else {
501  std::cerr << "Self::processSenseBody(string) -> failed to match " << sense_body << std::endl;
502  }
503 }
504 
505 void Self::changePlayerType(int type) {
506  if (type < Self::PLAYER_TYPES) {
514  Self::KICK_RAND = kick_rand[type];
521  }
522 }
523 
524 double angleMean(std::list<double> arcs) {
525  double x_m = 0.0;
526  double y_m = 0.0;
527  for (std::list<double>::iterator it = arcs.begin(); it != arcs.end(); ++it) {
528  x_m += cos(Self::PI * *it / 180.0);
529  y_m += sin(Self::PI * *it / 180.0);
530  }
531  x_m /= arcs.size();
532  y_m /= arcs.size();
533  return 180.0 * atan2(y_m, x_m) / Self::PI;
534 }
535 
543 bool triangular(Flag* flag0, Flag* flag1, double &x_t, double &y_t, double &theta_t, double &error_d) {
544  double k0 = pow(flag0->getDistance(), 2.0) - pow(flag0->getX(), 2.0) - pow(flag0->getY(), 2.0);
545  double k1 = pow(flag1->getDistance(), 2.0) - pow(flag1->getX(), 2.0) - pow(flag1->getY(), 2.0);
546  double x0, x1, y0, y1, B, C;
547  if (flag0->getX() == flag1->getX()) {
548  double y = (k0 - k1) / (2.0 * (flag1->getY() - flag0->getY()));
549  y0 = y;
550  y1 = y;
551  B = -2.0 * flag0->getX();
552  C = pow(y, 2.0) - 2.0 * y * flag0->getY() - k0;
553  if (pow(B, 2.0) - 4.0 * C > 0) {
554  x0 = (-B + sqrt(pow(B, 2.0) - 4.0 * C)) / 2.0;
555  x1 = (-B - sqrt(pow(B, 2.0) - 4.0 * C)) / 2.0;
556  } else {
557  return false;
558  }
559  } else if (flag0->getY() == flag1->getY()) {
560  double x = (k0 - k1) / (2.0 * (flag1->getX() - flag0->getX()));
561  x0 = x;
562  x1 = x;
563  B = -2.0 * flag0->getY();
564  C = pow(x, 2.0) - 2.0 * x * flag0->getX() - k0;
565  if (pow(B, 2.0) - 4.0 * C > 0) {
566  y0 = (-B + sqrt(pow(B, 2.0) - 4.0 * C)) / 2.0;
567  y1 = (-B - sqrt(pow(B, 2.0) - 4.0 * C)) / 2.0;
568  } else {
569  return false;
570  }
571  } else {
572  double M = (k1 - k0) / (2.0 * (flag0->getX() - flag1->getX()));
573  double N = (flag0->getY() - flag1->getY()) / (flag1->getX() - flag0->getX());
574  B = (2.0 * (M * N - N * flag0->getX() - flag0->getY())) / (pow(N, 2.0) + 1.0);
575  C = (pow(M, 2.0) - 2.0 * M * flag0->getX() - k0) / (pow(N, 2.0) + 1.0);
576  if (pow(B, 2.0) - 4.0 * C > 0) {
577  y0 = (-B + sqrt(pow(B, 2.0) - 4.0 * C)) / 2.0;
578  x0 = M + y0 * N;
579  y1 = (-B - sqrt(pow(B, 2.0) - 4.0 * C)) / 2.0;
580  x1 = M + y1 * N;
581  } else {
582  return false;
583  }
584  }
585  double d0 = sqrt(pow(x0 - x, 2.0) + pow(y0 - y, 2.0));
586  double d1 = sqrt(pow(x1 - x, 2.0) + pow(y1 - y, 2.0));
587  double gamma0, gamma1;
588  if (d0 < d1) {
589  x_t = x0;
590  y_t = y0;
591  } else {
592  x_t = x1;
593  y_t = y1;
594  }
595  gamma0 = 180 * atan2(flag0->getY() - y_t, flag0->getX() - x_t) / Self::PI - flag0->getDirection();
596  gamma1 = 180 * atan2(flag1->getY() - y_t, flag1->getX() - x_t) / Self::PI - flag1->getDirection();
597  if (gamma0 >= 180.0) {
598  gamma0 -= 360.0;
599  } else if (gamma0 < -180.0) {
600  gamma0 += 360.0;
601  }
602  if (gamma1 >= 180.0) {
603  gamma1 -= 360.0;
604  } else if (gamma1 < -180.0) {
605  gamma1 += 360.0;
606  }
607  double x_m = (cos(Self::PI * gamma0 / 180.0) + cos(Self::PI * gamma1 / 180.0)) / 2.0;
608  double y_m = (sin(Self::PI * gamma0 / 180.0) + sin(Self::PI * gamma1 / 180.0)) / 2.0;
609  theta_t = 180.0 * atan2(y_m, x_m) / Self::PI;
610  error_d = flag0->getError() + flag1->getError();
611  return true;
612 }
613 
614 bool areaCheck(double x_min, double x_max, double rmax, double x_c, double y_c, double error) {
615  double x_t = cos(theta) * (x_c - x) + sin(theta) * (y_c - y);
616  double y_t = sin(theta) * (x - x_c) + cos(theta) * (y_c - y);
617  if (((x_t > x_min - error) && (x_t < x_max + error)) && ((y_t > -1.0 * rmax - error) && (y_t < rmax + error))) {
618  return true;
619  } else {
620  return false;
621  }
622 }
623 
624 void Self::localize(std::vector<Flag> flags) {
625  if (!positioned) return;
626  if (flags.size() == 0) {
627  localize();
628  return;
629  }
630 // int point_counter = 0;
631  std::list<double> thetas;
632 // double total_x = 0.0, total_y = 0.0;
633 // if (Config::LOGGING && Game::PLAY_MODE.compare("play_on") == 0) {
634 // std::clog << Game::GAME_TIME;
635 // for (std::vector<Flag>::iterator it = flags.begin(); it != flags.end(); ++it) {
636 // std::clog << " (x: " << it->getX() << ", y: " << it->getY() << ", dis: " << it->getDistance() << ", dir: " << it->getDirection() << ")";
637 // }
638 // std::clog << std::endl;
639 // std::clog.flush();
640 // }
641 // for (std::vector<Flag>::iterator it_flag_0 = flags.begin(); it_flag_0 != flags.end() - 1; ++it_flag_0) {
642 // for (std::vector<Flag>::iterator it_flag_1 = it_flag_0 + 1; it_flag_1 != flags.end(); ++it_flag_1) {
643 // Flag* flag0 = &(*it_flag_0);
644 // Flag* flag1 = &(*it_flag_1);
645 // double x_t, y_t, theta_t, error_d;
646 // if (triangular(flag0, flag1, x_t, y_t, theta_t, error_d)) {
647 // total_x += x_t;
648 // total_y += y_t;
649 // thetas.push_back(theta_t);
650 // point_counter++;
651 // }
652 // }
653 // }
654  double x_e = x;
655  double y_e = y;
656  double tao = 0.6;
657  switch (flags.size()) {
658  case 1:
659  tao = 0.3;
660  break;
661  case 2:
662  tao = 0.4;
663  break;
664  case 3:
665  tao = 0.5;
666  break;
667  default:
668  break;
669  }
670  for (std::vector<Flag>::iterator it_flag = flags.begin(); it_flag != flags.end(); ++it_flag) {
671  double dir = atan2(y_e - it_flag->getY(), x_e - it_flag->getX());
672  double x_i = it_flag->getX() + cos(dir) * it_flag->getDistance();
673  double y_i = it_flag->getY() + sin(dir) * it_flag->getDistance();
674  x_e = tao * x_e + (1 - tao) * x_i;
675  y_e = tao * y_e + (1 - tao) * y_i;
676  double gamma = 180 * atan2(it_flag->getY() - y_e, it_flag->getX() - x_e) / Self::PI - it_flag->getDirection();
677  if (gamma > 180.0) {
678  gamma -= 360.0;
679  } else if (gamma < -180.0) {
680  gamma += 360.0;
681  }
682  thetas.push_back(gamma);
683  }
684  x = x_e;
685  y = y_e;
686  theta = angleMean(thetas);
687 // if (point_counter > 0) {
688 // x = total_x / point_counter;
689 // y = total_y / point_counter;
690 // theta = angleMean(thetas);
691 // } else {
692 // localize();
693 // }
694 }
695 
697  if (!positioned) return;
698  double effective_turn = u[2] / (1.0 + Self::getAmountOfSpeedAtTime(1) * Self::INERTIA_MOMENT);
699  theta += effective_turn;
700  if (theta > 180.0) {
701  theta -= 360.0;
702  } else if (theta < -180.0) {
703  theta += 360.0;
704  }
705  double edp = Self::getEffortAtTime(1) * Server::DASH_POWER_RATE * u[0];
710  x += speed.getXComponent();
711  y += speed.getYComponent();
712 }
713 
715  return Position(x, y, theta);
716 }
717 
720 }
721 
722 void Self::setLastCommandsSet(std::list<Command*> last_commands_sent_t) {
723  last_commands_sent.swap(last_commands_sent_t);
724 }
725 
726 std::string Self::getViewModeWidthAtTime(unsigned int time) {
727  return (time < Config::BUFFER_MAX_HISTORY) ? view_mode_width_buffer[time] : "";
728 }
729 
730 std::string Self::getViewModeQualityAtTime(unsigned int time) {
731  return (time < Config::BUFFER_MAX_HISTORY) ? view_mode_quality_buffer[time] : "";
732 }
733 
734 double Self::getStaminaAtTime(unsigned int time) {
735  return (time < Config::BUFFER_MAX_HISTORY) ? stamina_buffer[time] : 0.0;
736 }
737 
738 double Self::getEffortAtTime(unsigned int time) {
739  return (time < Config::BUFFER_MAX_HISTORY) ? effort_buffer[time] : 0.0;
740 }
741 
742 double Self::getStaminaCapacityAtTime(unsigned int time) {
743  return (time < Config::BUFFER_MAX_HISTORY) ? stamina_capacity_buffer[time] : 0.0;
744 }
745 
746 double Self::getAmountOfSpeedAtTime(unsigned int time) {
747  return (time < Config::BUFFER_MAX_HISTORY) ? amount_of_speed_buffer[time] : 0.0;
748 }
749 
750 double Self::getDirectionOfSpeedAtTime(unsigned int time) {
751  return (time < Config::BUFFER_MAX_HISTORY) ? direction_of_speed_buffer[time] : 0.0;
752 }
753 
754 int Self::getKickCountAtTime(unsigned int time) {
755  return (time < Config::BUFFER_MAX_HISTORY) ? kick_count_buffer[time] : 0;
756 }
757 
758 int Self::getDashCountAtTime(unsigned int time) {
759  return (time < Config::BUFFER_MAX_HISTORY) ? dash_count_buffer[time] : 0;
760 }
761 
762 int Self::getTurnCountAtTime(unsigned int time) {
763  return (time < Config::BUFFER_MAX_HISTORY) ? turn_count_buffer[time] : 0;
764 }
765 
766 int Self::getSayCountAtTime(unsigned int time) {
767  return (time < Config::BUFFER_MAX_HISTORY) ? say_count_buffer[time] : 0;
768 }
769 
770 int Self::getTurnNeckCountAtTime(unsigned int time) {
771  return (time < Config::BUFFER_MAX_HISTORY) ? turn_neck_count_buffer[time] : 0;
772 }
773 
774 int Self::getCatchCountAtTime(unsigned int time) {
775  return (time < Config::BUFFER_MAX_HISTORY) ? catch_count_buffer[time] : 0;
776 }
777 
778 int Self::getMoveCountAtTime(unsigned int time) {
779  return (time < Config::BUFFER_MAX_HISTORY) ? move_count_buffer[time] : 0;
780 }
781 
782 int Self::getChangeViewCountAtTime(unsigned int time) {
783  return (time < Config::BUFFER_MAX_HISTORY) ? change_view_count_buffer[time] : 0;
784 }
785 
786 int Self::getArmMovableAtTime(unsigned int time) {
787  return (time < Config::BUFFER_MAX_HISTORY) ? arm_movable_buffer[time] : 0;
788 }
789 
790 int Self::getArmExpiresAtTime(unsigned int time) {
791  return (time < Config::BUFFER_MAX_HISTORY) ? arm_expires_buffer[time] : 0;
792 }
793 
794 double Self::getArmDistAtTime(unsigned int time) {
795  return (time < Config::BUFFER_MAX_HISTORY) ? arm_dist_buffer[time] : 0.0;
796 }
797 
798 double Self::getArmDirAtTime(unsigned int time) {
799  return (time < Config::BUFFER_MAX_HISTORY) ? arm_dir_buffer[time] : 0.0;
800 }
801 
802 int Self::getArmCountAtTime(unsigned int time) {
803  return (time < Config::BUFFER_MAX_HISTORY) ? arm_count_buffer[time] : 0;
804 }
805 
806 std::string Self::getFocusTargetAtTime(unsigned int time) {
807  return (time < Config::BUFFER_MAX_HISTORY) ? focus_target_buffer[time] : "";
808 }
809 
810 int Self::getFocusCountAtTime(unsigned int time) {
811  return (time < Config::BUFFER_MAX_HISTORY) ? focus_count_buffer[time] : 0;
812 }
813 
814 int Self::getTackleExpiresAtTime(unsigned int time) {
815  return (time < Config::BUFFER_MAX_HISTORY) ? tackle_expires_buffer[time] : 0;
816 }
817 
818 int Self::getTackleCountAtTime(unsigned int time) {
819  return (time < Config::BUFFER_MAX_HISTORY) ? tackle_count_buffer[time] : 0;
820 }
821 
822 std::list<std::string> Self::getCollisionsAtTime(unsigned int time) {
824 }
825 
826 int Self::getFoulChargedAtTime(unsigned int time) {
827  return (time < Config::BUFFER_MAX_HISTORY) ? foul_charged_buffer[time] : 0;
828 }
829 
830 std::string Self::getFoulCardAtTime(unsigned int time) {
831  return (time < Config::BUFFER_MAX_HISTORY) ? foul_card_buffer[time] : "";
832 }
833 }
static double getArmDistAtTime(unsigned int time)
Definition: Self.cpp:794
static int MOVE_COUNT
Definition: Self.h:123
Used by Player and Goalie.
Definition: Command.h:56
static int UNIFORM_NUMBER
Definition: Self.h:49
Self(std::string player_params, std::string team_name, int unum, std::string side)
Definition: Self.cpp:225
static double NEW_DASH_POWER_RATE_DELTA_MAX
Definition: Self.h:67
void changePlayerType(int type)
Definition: Self.cpp:505
double getDistance()
Definition: Flag.cpp:128
static double getStaminaCapacityAtTime(unsigned int time)
Definition: Self.cpp:742
static int CATCH_COUNT
Definition: Self.h:121
static unsigned int BUFFER_MAX_HISTORY
Definition: Config.h:39
static double DASH_POWER_RATE
Definition: Self.h:85
static double PLAYER_DECAY
Definition: Self.h:83
void addPlayerType(std::string player_type)
Definition: Self.cpp:298
static boost::circular_buffer< double > effort_buffer(Config::BUFFER_MAX_HISTORY, 0.0)
static double theta
Definition: Self.cpp:91
static boost::circular_buffer< int > arm_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
double * kick_rand
Definition: Self.cpp:44
static double PLAYER_DECAY_DELTA_MIN
Definition: Self.h:71
void localize()
Definition: Self.cpp:696
static double getEffortAtTime(unsigned int time)
Definition: Self.cpp:738
std::string getPlayerParameter(const std::string &player_params, std::string parameter)
Definition: Self.cpp:213
double getTurnMoment()
Definition: Command.cpp:105
double * extra_stamina
Definition: Self.cpp:45
static std::string VIEW_MODE_QUALITY
Definition: Self.h:97
static int TACKLE_COUNT
Definition: Self.h:143
double u[3]
Definition: Self.cpp:52
static int FOCUS_COUNT
Definition: Self.h:139
Position The Position lorem Ipsum
Definition: Position.h:50
static boost::circular_buffer< int > foul_charged_buffer(Config::BUFFER_MAX_HISTORY, 0)
double getError()
Definition: Flag.cpp:152
static boost::circular_buffer< std::list< std::string > > collisions_buffer(Config::BUFFER_MAX_HISTORY, empty_vector)
static void initializeField()
Definition: Flag.cpp:66
static double PI
Definition: Self.h:47
static double EXTRA_STAMINA_DELTA_MIN
Definition: Self.h:59
Used by Player and Goalie.
Definition: Command.h:53
static int getArmMovableAtTime(unsigned int time)
Definition: Self.cpp:786
static double DASH_POWER_RATE_DELTA_MAX
Definition: Self.h:54
Used by Player and Goalie.
Definition: Command.h:50
static int getTurnCountAtTime(unsigned int time)
Definition: Self.cpp:762
static std::list< std::string > getCollisionsAtTime(unsigned int time)
Definition: Self.cpp:822
static boost::circular_buffer< int > catch_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
Used by Player and Goalie.
Definition: Command.h:52
static double getArmDirAtTime(unsigned int time)
Definition: Self.cpp:798
static Vector2D getVelocity()
Definition: Self.cpp:718
static boost::circular_buffer< int > tackle_expires_buffer(Config::BUFFER_MAX_HISTORY, 0)
static Position getPosition()
Definition: Self.cpp:714
static double STAMINA_INC_MAX_DELTA_FACTOR
Definition: Self.h:78
double getY()
Definition: Flag.cpp:140
double getMoveY()
Definition: Command.cpp:113
static int getFoulChargedAtTime(unsigned int time)
Definition: Self.cpp:826
static double KICK_POWER_RATE_DELTA_MAX
Definition: Self.h:62
double getDirection()
Definition: Flag.cpp:132
static double PLAYER_ACCEL_MAX
Definition: Server.h:159
static int getArmExpiresAtTime(unsigned int time)
Definition: Self.cpp:790
double * player_size
Definition: Self.cpp:42
double getMoveX()
Definition: Command.cpp:109
Used by Player and Goalie.
Definition: Command.h:57
static double KICKABLE_MARGIN
Definition: Self.h:87
static boost::circular_buffer< std::string > focus_target_buffer(Config::BUFFER_MAX_HISTORY,"none")
static boost::circular_buffer< int > arm_movable_buffer(Config::BUFFER_MAX_HISTORY, 0)
double * kick_power_rate
Definition: Self.cpp:48
static double KICKABLE_MARGIN_DELTA_MIN
Definition: Self.h:66
static double NEW_STAMINA_INC_MAX_DELTA_FACTOR
Definition: Self.h:69
static boost::circular_buffer< int > arm_expires_buffer(Config::BUFFER_MAX_HISTORY, 0)
static double PLAYER_SIZE_DELTA_FACTOR
Definition: Self.h:72
double getYComponent()
Definition: Vector2D.cpp:67
static double KICK_RAND
Definition: Self.h:88
static int PLAYER_TYPES
Definition: Self.h:75
static int DASH_COUNT
Definition: Self.h:113
static int getChangeViewCountAtTime(unsigned int time)
Definition: Self.cpp:782
double * kickable_margin
Definition: Self.cpp:43
double * catchable_area_l_stretch
Definition: Self.cpp:50
static double KICK_RAND_DELTA_FACTOR
Definition: Self.h:64
static double KICKABLE_MARGIN_DELTA_MAX
Definition: Self.h:65
double * stamina_inc_max
Definition: Self.cpp:38
static boost::circular_buffer< double > amount_of_speed_buffer(Config::BUFFER_MAX_HISTORY, 0.0)
Used by Player and Goalie.
Definition: Command.h:49
static double STAMINA
Definition: Self.h:99
static double FOUL_DETECT_PROBABILITY
Definition: Self.h:93
static double getStaminaAtTime(unsigned int time)
Definition: Self.cpp:734
static int TURN_NECK_COUNT
Definition: Self.h:119
double getDashPower()
Definition: Command.cpp:97
static double EXTRA_STAMINA_DELTA_MAX
Definition: Self.h:58
static double CATCHABLE_AREA_L_STRECH_MIN
Definition: Self.h:53
double getDashDirection()
Definition: Command.cpp:101
static double STAMINA_CAPACITY
Definition: Self.h:103
static std::list< Command * > last_commands_sent
Definition: Self.cpp:92
std::string getPlayerTypeParameter(const std::string &player_type, std::string parameter)
Definition: Self.cpp:201
static int getFocusCountAtTime(unsigned int time)
Definition: Self.cpp:810
static double x
Definition: Self.cpp:89
static double AMOUNT_OF_SPEED
Definition: Self.h:105
static int TURN_COUNT
Definition: Self.h:115
static double DIRECTION_OF_SPEED
Definition: Self.h:107
static std::string TEAM_NAME
Definition: Self.h:48
static int ALLOW_MULT_DEFAULT_TYPE
Definition: Self.h:51
static int TACKLE_EXPIRES
Definition: Self.h:141
static double KICK_POWER_RATE_DELTA_MIN
Definition: Self.h:63
static Vector2D getVector2DWithMagnitudeAndDirection(double magnitude, double direction)
Definition: Vector2D.cpp:53
static boost::circular_buffer< int > say_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
Used by Player and Goalie.
Definition: Command.h:51
static double PLAYER_SIZE
Definition: Self.h:86
static boost::circular_buffer< int > focus_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
double * inertia_moment
Definition: Self.cpp:40
static std::string getFoulCardAtTime(unsigned int time)
Definition: Self.cpp:830
double * dash_power_rate
Definition: Self.cpp:41
static std::string getFocusTargetAtTime(unsigned int time)
Definition: Self.cpp:806
static int getMoveCountAtTime(unsigned int time)
Definition: Self.cpp:778
static boost::circular_buffer< std::string > view_mode_width_buffer(Config::BUFFER_MAX_HISTORY,"normal")
static int FOUL_CHARGED
Definition: Self.h:147
Command The Command lorem Ipsum
Definition: Command.h:70
static double DASH_POWER_RATE
Definition: Server.h:73
static std::string SIDE
Definition: Self.h:50
static double EFFORT_MAX_DELTA_FACTOR
Definition: Self.h:56
static double NEW_DASH_POWER_RATE_DELTA_MIN
Definition: Self.h:68
static bool VERBOSE
Definition: Config.h:38
static double CATCHABLE_AREA_L_STRECH_MAX
Definition: Self.h:52
static std::string FOUL_CARD
Definition: Self.h:149
void changeStatusTo(COMMAND_STATUS status)
Definition: Command.cpp:157
static double FOUL_DETECT_PROBABILITY_DELTA_FACTOR
Definition: Self.h:60
static double CATCHABLE_AREA_L_STRETCH
Definition: Self.h:94
static int getTackleExpiresAtTime(unsigned int time)
Definition: Self.cpp:814
static int getKickCountAtTime(unsigned int time)
Definition: Self.cpp:754
static boost::circular_buffer< double > stamina_buffer(Config::BUFFER_MAX_HISTORY, 0.0)
static boost::circular_buffer< int > dash_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
static int SUBS_MAX
Definition: Self.h:79
static double ARM_DIR
Definition: Self.h:133
static double DASH_POWER_RATE_DELTA_MIN
Definition: Self.h:55
static int getArmCountAtTime(unsigned int time)
Definition: Self.cpp:802
int * types_id
Definition: Self.cpp:36
std::list< std::string > empty_vector
Definition: Self.cpp:118
double getX()
Definition: Flag.cpp:136
static std::string FOCUS_TARGET
Definition: Self.h:137
static boost::circular_buffer< double > stamina_capacity_buffer(Config::BUFFER_MAX_HISTORY, 0.0)
static double KICK_POWER_RATE
Definition: Self.h:92
Flag The Flag lorem Ipsum
Definition: Flag.h:45
double * player_speed_max
Definition: Self.cpp:37
boost::regex sense_body_regex("^\\(sense_body\\s+\\d+\\s+""\\(view_mode\\s+(\\w+)\\s+(\\w+)\\)\\s*""\\(stamina\\s+([\\d\\.\\-e]+)\\s+([\\d\\.\\-e]+)\\s+([\\d\\.\\-e]+)\\)\\s*""\\(speed\\s+([\\d\\.\\-e]+)\\s+([\\d\\.\\-e]+)\\)\\s*""\\(head_angle\\s+([\\d\\.\\-e]+)\\)\\s*""\\(kick\\s+(\\d+)\\)\\s*""\\(dash\\s+(\\d+)\\)\\s*""\\(turn\\s+(\\d+)\\)\\s*""\\(say\\s+(\\d+)\\)\\s*""\\(turn_neck\\s+(\\d+)\\)\\s*""\\(catch\\s+(\\d+)\\)\\s*""\\(move\\s+(\\d+)\\)\\s*""\\(change_view\\s+(\\d+)\\)\\s*""\\(arm\\s+""\\(movable\\s+(\\d+)\\)\\s*""\\(expires\\s+(\\d+)\\)\\s*""\\(target\\s+([\\d\\.\\-e]+)\\s+([\\d\\.\\-e]+)\\)\\s*""\\(count\\s+(\\d+)\\)\\s*""\\)\\s*""\\(focus\\s+""\\(target\\s+(none|[lr]\\s+\\d+)\\)\\s*""\\(count\\s+(\\d+)\\)\\s*""\\)\\s*""\\(tackle\\s+""\\(expires\\s+(\\d+)\\)\\s*""\\(count\\s+(\\d+)\\)\\s*""\\)\\s*""\\(collision\\s+(none|\\(ball\\)|\\(player\\)|\\(post\\)|\\s)+\\)\\s*""\\(foul\\s+""\\(charged\\s+(\\d+)\\)\\s*""\\(card\\s+(none|yellow|red)\\)\\s*""\\)\\s*""\\)$")
static boost::circular_buffer< int > kick_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
static double EXTRA_STAMINA
Definition: Self.h:89
static boost::circular_buffer< std::string > foul_card_buffer(Config::BUFFER_MAX_HISTORY,"none")
static boost::circular_buffer< int > change_view_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
static double INERTIA_MOMENT
Definition: Self.h:84
static std::string VIEW_MODE_WIDTH
Definition: Self.h:95
static double ARM_DIST
Definition: Self.h:131
static double y
Definition: Self.cpp:90
Used by Player and Goalie.
Definition: Command.h:55
static boost::circular_buffer< double > head_angle_buffer(Config::BUFFER_MAX_HISTORY, 0.0)
static std::string getViewModeQualityAtTime(unsigned int time)
Definition: Self.cpp:730
static double EFFORT
Definition: Self.h:101
static double PLAYER_DECAY_DELTA_MAX
Definition: Self.h:70
static int PT_MAX
Definition: Self.h:76
static int TYPE_ID
Definition: Self.h:80
static double getAmountOfSpeedAtTime(unsigned int time)
Definition: Self.cpp:746
double * effort_min
Definition: Self.cpp:47
Used by Player and Goalie.
Definition: Command.h:58
Used by Player and Goalie.
Definition: Command.h:54
static boost::circular_buffer< int > move_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
static int getCatchCountAtTime(unsigned int time)
Definition: Self.cpp:774
static int CHANGE_VIEW_COUNT
Definition: Self.h:125
double * foul_detect_probability
Definition: Self.cpp:49
static double HEAD_ANGLE
Definition: Self.h:109
static double EFFORT_MIN
Definition: Self.h:91
double getXComponent()
Definition: Vector2D.cpp:63
static double EFFORT_MAX
Definition: Self.h:90
bool areaCheck(double x_min, double x_max, double rmax, double x_c, double y_c, double error)
Definition: Self.cpp:614
bool triangular(Flag *flag0, Flag *flag1, double &x_t, double &y_t, double &theta_t, double &error_d)
Definition: Self.cpp:543
static double STAMINA_INC_MAX
Definition: Self.h:82
double * player_decay
Definition: Self.cpp:39
double * effort_max
Definition: Self.cpp:46
static double EFFORT_MIN_DELTA_FACTOR
Definition: Self.h:57
static int ARM_EXPIRES
Definition: Self.h:129
double getMagnitude()
Definition: Vector2D.cpp:71
static std::string getViewModeWidthAtTime(unsigned int time)
Definition: Self.cpp:726
double angleMean(std::list< double > arcs)
Definition: Self.cpp:524
static double getDirectionOfSpeedAtTime(unsigned int time)
Definition: Self.cpp:750
static boost::circular_buffer< double > arm_dist_buffer(Config::BUFFER_MAX_HISTORY, 0.0)
bool positioned
Definition: Self.cpp:88
static int RANDOM_SEED
Definition: Self.h:77
static int ARM_COUNT
Definition: Self.h:135
static void setLastCommandsSet(std::list< Command * > last_commands_sent)
Definition: Self.cpp:722
static boost::circular_buffer< double > arm_dir_buffer(Config::BUFFER_MAX_HISTORY, 0.0)
static std::list< std::string > COLLISION
Definition: Self.h:145
static double PLAYER_SPEED_MAX_DELTA_MIN
Definition: Self.h:74
static boost::circular_buffer< int > turn_neck_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
static int getSayCountAtTime(unsigned int time)
Definition: Self.cpp:766
static boost::circular_buffer< int > tackle_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
static int KICK_COUNT
Definition: Self.h:111
static boost::circular_buffer< int > turn_count_buffer(Config::BUFFER_MAX_HISTORY, 0)
static int getTackleCountAtTime(unsigned int time)
Definition: Self.cpp:818
static int SAY_COUNT
Definition: Self.h:117
static double INERTIA_MOMENT_DELTA_FACTOR
Definition: Self.h:61
static int ARM_MOVABLE
Definition: Self.h:127
static boost::circular_buffer< std::string > view_mode_quality_buffer(Config::BUFFER_MAX_HISTORY,"high")
static double PLAYER_SPEED_MAX_DELTA_MAX
Definition: Self.h:73
Vector2D The Vector2D lorem Ipsum
Definition: Vector2D.h:45
void processSenseBody(std::string sense_body)
Definition: Self.cpp:317
static int getTurnNeckCountAtTime(unsigned int time)
Definition: Self.cpp:770
static int getDashCountAtTime(unsigned int time)
Definition: Self.cpp:758
static double PLAYER_SPEED_MAX
Definition: Self.h:81
static boost::circular_buffer< double > direction_of_speed_buffer(Config::BUFFER_MAX_HISTORY, 0.0)