Phoenix2D-Library  0.10
Actions.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 "Actions.h"
22 #include "Self.h"
23 #include "Commands.h"
24 //#include <iostream>
25 #include "Game.h"
26 #include <cmath>
27 namespace Phoenix
28 {
30  this->commands = commands;
31 }
32 
34 
35 }
36 
37 bool Actions::goTo(Position position) {
38  Position myPosition = Self::getPosition();
39  if (myPosition.getDistanceTo(position) > 1.0) {
40  double moment = myPosition.getDirectionTo(position);
41  //std::cout << moment << std::endl;
42  if (std::abs(moment) > 5.0) {
43  double angle = moment * (1.0 + Self::INERTIA_MOMENT * Self::AMOUNT_OF_SPEED);
44  commands->turn(angle);
45  } else {
46  commands->dash(50.0, 0.0);
47  }
48  } else {
49  return true;
50  }
51  return false;
52 }
53 
54 void Actions::dribbleTo(Position position) {
55 
56 }
57 
59 
60 }
61 
63 
64 }
65 
67 
68 }
69 }
void attackSection(Position position)
Definition: Actions.cpp:66
void dash(double power, double direction)
Definition: Commands.cpp:92
Position The Position lorem Ipsum
Definition: Position.h:50
void passToSection(Position position)
Definition: Actions.cpp:62
void dribbleTo(Position position)
Definition: Actions.cpp:54
static Position getPosition()
Definition: Self.cpp:714
void holdPosition(Position position)
Definition: Actions.cpp:58
Commands The Commans lorem Ipsum
Definition: Commands.h:42
Commands * commands
Definition: Actions.h:47
void turn(double moment)
Definition: Commands.cpp:62
static double AMOUNT_OF_SPEED
Definition: Self.h:105
bool goTo(Position position)
Definition: Actions.cpp:37
static double INERTIA_MOMENT
Definition: Self.h:84
double getDirectionTo(Position position)
Definition: Position.cpp:86
Actions(Commands *commands)
Definition: Actions.cpp:29
double getDistanceTo(Position position)
Definition: Position.cpp:81