[Jais-checkins] jaisteam/src/jais/player StateManager.java,1.13,1.14 KI.java,1.78,1.79 ActionManager
Status: Beta
Brought to you by:
maestrodd
|
From: <mae...@us...> - 2002-07-14 22:56:43
|
Update of /cvsroot/jais/jaisteam/src/jais/player
In directory usw-pr-cvs1:/tmp/cvs-serv30379/player
Modified Files:
StateManager.java KI.java ActionManager.java
Log Message:
viewmodes added & more
checkgoalkick new progged by bombenleger
...
many bugs....
Index: StateManager.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/player/StateManager.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** StateManager.java 13 Jul 2002 20:29:24 -0000 1.13
--- StateManager.java 14 Jul 2002 22:56:40 -0000 1.14
***************
*** 20,26 ****
int m_state= 1;
public static final int[] VIEW_ANGLES={45,90,180};
! public int m_currentViewMode=1;
!
int m_actionCounter = 0;
/**
* Returns if we are offense or defense
--- 20,28 ----
int m_state= 1;
public static final int[] VIEW_ANGLES={45,90,180};
! public int m_currentViewWidth=1; // 0 , 1, 2
! public int m_currentViewQuality=1; // 0 for LOW, 1 for HIGH
! public boolean m_searchingBall=false;
int m_actionCounter = 0;
+
/**
* Returns if we are offense or defense
Index: KI.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/player/KI.java,v
retrieving revision 1.78
retrieving revision 1.79
diff -C2 -d -r1.78 -r1.79
*** KI.java 14 Jul 2002 14:01:23 -0000 1.78
--- KI.java 14 Jul 2002 22:56:40 -0000 1.79
***************
*** 35,39 ****
/*defense*/ new Coordinate(-25,20), new Coordinate(-30,7), new Coordinate(-30,-7),new Coordinate(-25,-20),
/*midfield*/ new Coordinate(0,10), new Coordinate(0,0), new Coordinate(0,-10),
! /*attackers*/ new Coordinate(30,15), new Coordinate(25,0), new Coordinate(30,-15)};
private final Coordinate GOALIE_HOME_POS = new Coordinate(-50, 0);
--- 35,39 ----
/*defense*/ new Coordinate(-25,20), new Coordinate(-30,7), new Coordinate(-30,-7),new Coordinate(-25,-20),
/*midfield*/ new Coordinate(0,10), new Coordinate(0,0), new Coordinate(0,-10),
! /*attackers*/ new Coordinate(30,18), new Coordinate(25,0), new Coordinate(30,-18)};
private final Coordinate GOALIE_HOME_POS = new Coordinate(-50, 0);
***************
*** 47,57 ****
private final Coordinate ENEMY_GOAL_POS = new Coordinate(52.5, 0);
private final int MAX_GOAL_KICK_DISTANCE = 25;
! private final int MIN_DISTANCE_FOR_DRIBBEL = 5;
private final int MAX_PASS_DISTANCE =30;
private final int MAX_LOOKING_FORWARD_TIME = 20;
! private final int FREE_ANGLE = 15;
! private int m_searchAngle;
ArrayList m_enemyTeam;
--- 47,58 ----
private final Coordinate ENEMY_GOAL_POS = new Coordinate(52.5, 0);
private final int MAX_GOAL_KICK_DISTANCE = 25;
! private final int MIN_DISTANCE_FOR_DRIBBEL = 10;
private final int MAX_PASS_DISTANCE =30;
private final int MAX_LOOKING_FORWARD_TIME = 20;
! private final int MAX_ANGLE_FOR_GOAL_KICK = 75;
! private final int FREE_ANGLE_FOR_GOAL_KICK = 5;
! private final int FREE_ANGLE = 15;
ArrayList m_enemyTeam;
***************
*** 73,78 ****
this.setName("KI"+f_playerNumber);
m_myWorld = f_world;
- m_actions = new ActionManager(m_myWorld, f_myCom, f_playerNumber);
m_myState = new StateManager();
}
--- 74,79 ----
this.setName("KI"+f_playerNumber);
m_myWorld = f_world;
m_myState = new StateManager();
+ m_actions = new ActionManager(m_myWorld, f_myCom, f_playerNumber, m_myState);
}
***************
*** 121,124 ****
--- 122,126 ----
}//of while()
//logger.info("\t" + getName() + ": i've left my while-loop. run() will stop immediatly
+
}
***************
*** 251,255 ****
m_actions.kickTo(MAXPOWER,ENEMY_GOAL_POS,0); // schön ausrichten und voll draufhauen
else
! m_actions.runTo(NORMPOWER,m_myWorld.getBall(), m_myState.m_currentViewMode);
}
}
--- 253,257 ----
m_actions.kickTo(MAXPOWER,ENEMY_GOAL_POS,0); // schön ausrichten und voll draufhauen
else
! m_actions.runTo(NORMPOWER,m_myWorld.getBall(), m_myState.m_currentViewWidth);
}
}
***************
*** 292,302 ****
l_tempPlayer =checkForPassPartner(10);
if (l_tempPlayer != null)
! passTo(l_tempPlayer,0);
else
! kickTo(ENEMY_GOAL_POS,0);
}
else
{
! m_actions.runTo(MINPOWER, m_myWorld.getBall(), m_myState.m_currentViewMode);
}
}
--- 294,304 ----
l_tempPlayer =checkForPassPartner(10);
if (l_tempPlayer != null)
! passTo(l_tempPlayer,m_myState.m_currentViewWidth);
else
! m_actions.kickTo(MAXPOWER,ENEMY_GOAL_POS,m_myState.m_currentViewWidth);
}
else
{
! m_actions.runTo(MINPOWER, m_myWorld.getBall(), m_myState.m_currentViewWidth);
}
}
***************
*** 309,313 ****
if(m_myWorld.getMyself().getDistanceTo(m_myWorld.getBall().getAbsPosition()) < 10)
{
! m_actions.run((int)-MINPOWER);
}
else
--- 311,315 ----
if(m_myWorld.getMyself().getDistanceTo(m_myWorld.getBall().getAbsPosition()) < 10)
{
! m_actions.run((int)-NORMPOWER);
}
else
***************
*** 320,326 ****
* @param f_forLeftSide
*/
! private void goalKick(boolean f_forLeftSide){
PlayerInfo l_tempPlayer;
! if(m_myWorld.getMyself().isGoalie()){
if ((m_myWorld.isPlayingLeft()&& f_forLeftSide) || (!m_myWorld.isPlayingLeft()&& !f_forLeftSide ))
{
--- 322,330 ----
* @param f_forLeftSide
*/
! private void goalKick(boolean f_forLeftSide)
! {
PlayerInfo l_tempPlayer;
! if(m_myWorld.getMyself().isGoalie())
! {
if ((m_myWorld.isPlayingLeft()&& f_forLeftSide) || (!m_myWorld.isPlayingLeft()&& !f_forLeftSide ))
{
***************
*** 331,341 ****
l_tempPlayer =checkForPassPartner(10);
if (l_tempPlayer != null)
! passTo(l_tempPlayer,0);
else
! kickTo(ENEMY_GOAL_POS,0);
}
else
{
! m_actions.runTo(MAXPOWER, m_myWorld.getBall(), m_myState.m_currentViewMode);
}
--- 335,345 ----
l_tempPlayer =checkForPassPartner(10);
if (l_tempPlayer != null)
! passTo(l_tempPlayer,m_myState.m_currentViewWidth);
else
! m_actions.kickTo(MAXPOWER,ENEMY_GOAL_POS,m_myState.m_currentViewWidth);
}
else
{
! m_actions.runTo(MAXPOWER, m_myWorld.getBall(), m_myState.m_currentViewWidth);
}
***************
*** 346,350 ****
}
}
!
}
--- 350,360 ----
}
}
! else //not the goalie
! {
! if (m_myWorld.getBall().isVisible())
! gotoHomePosition();
! else
! searchBall();
! }
}
***************
*** 404,410 ****
double l_ballSpeed = 0;
Coordinate l_diffPos;
! if (m_myWorld.getBall().getAbsPositionOfNextRound() != null) //&& m_myWorld.getMyDistanceTo(m_myWorld.getBall()) < 1.5)
{
! if (m_myWorld.getMyDistanceTo(m_myWorld.getBall().getAbsPosition()) >= m_myWorld.getMyDistanceTo(m_myWorld.getBall().getAbsPositionOfNextRound()))
{
//Ball kommt zu mir
--- 414,420 ----
double l_ballSpeed = 0;
Coordinate l_diffPos;
! if (m_myWorld.getBall().getAbsPositionOfNextRound() != null)
{
! if (m_myWorld.getMyDistanceTo(m_myWorld.getBall()) >= m_myWorld.getMyDistanceTo(m_myWorld.getBall().getAbsPositionOfNextRound()))
{
//Ball kommt zu mir
***************
*** 412,417 ****
while (l_zaehler < MAX_LOOKING_FORWARD_TIME )
{
! l_zaehler+=m_myState.m_currentViewMode+1;
! l_nextDistance = m_myWorld.getMyself().getDistanceTo(getBallPosInRound(l_zaehler));
if (l_nextDistance < l_smallestDistance)
{
--- 422,427 ----
while (l_zaehler < MAX_LOOKING_FORWARD_TIME )
{
! l_zaehler++;
! l_nextDistance = m_myWorld.getMyDistanceTo(getBallPosInRound(l_zaehler));
if (l_nextDistance < l_smallestDistance)
{
***************
*** 429,434 ****
while (l_zaehler < MAX_LOOKING_FORWARD_TIME )
{
! l_myTempPos=l_myTempPos.add(l_diffPos.scaleWith(3));
! l_zaehler+=m_myState.m_currentViewMode+1;
l_nextDistance = l_myTempPos.getDistanceTo(getBallPosInRound(l_zaehler));
if (l_nextDistance < l_smallestDistance)
--- 439,444 ----
while (l_zaehler < MAX_LOOKING_FORWARD_TIME )
{
! l_zaehler++;
! l_myTempPos=l_myTempPos.add(l_diffPos.scaleWith(l_zaehler));
l_nextDistance = l_myTempPos.getDistanceTo(getBallPosInRound(l_zaehler));
if (l_nextDistance < l_smallestDistance)
***************
*** 439,448 ****
}
}
! m_actions.runTo(MAXPOWER,getBallPosInRound(l_estimatedCyclesToReachTheBall), m_myState.m_currentViewMode);
}
- // else if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null)
- // m_actions.runTo(MAXPOWER,m_myWorld.getBall().getAbsPositionOfNextRound());
else //ball doesnt move so simply go to its position
! m_actions.runTo(MAXPOWER,m_myWorld.getBall(), m_myState.m_currentViewMode);
}
--- 449,456 ----
}
}
! m_actions.runTo(MAXPOWER,getBallPosInRound(l_estimatedCyclesToReachTheBall), m_myState.m_currentViewWidth);
}
else //ball doesnt move so simply go to its position
! m_actions.runTo(MAXPOWER,m_myWorld.getBall(), m_myState.m_currentViewWidth);
}
***************
*** 454,461 ****
{
//check where the ball was the last time we saw it and turn to that direction
if (m_myWorld.getBall().getDirection() > 0)
! m_actions.turn(m_myState.VIEW_ANGLES[m_myState.m_currentViewMode]-15);
else
! m_actions.turn(-m_myState.VIEW_ANGLES[m_myState.m_currentViewMode]+15);
}
--- 462,470 ----
{
//check where the ball was the last time we saw it and turn to that direction
+ // if it is behind us, simply run a bit backwards
if (m_myWorld.getBall().getDirection() > 0)
! m_actions.turn(m_myState.VIEW_ANGLES[m_myState.m_currentViewWidth]-15);
else
! m_actions.turn(-m_myState.VIEW_ANGLES[m_myState.m_currentViewWidth]+15);
}
***************
*** 475,493 ****
else
{
- /* if (m_myWorld.getMyself().getBackNumber()==2)
- if (m_myWorld.getBall().getAbsPositionOfNextRound() !=null){
- logger.debug("BallPos Now:" + m_myWorld.getBall().getAbsPosition());
- logger.debug("BallPos Next:" + m_myWorld.getBall().getAbsPositionOfNextRound());
- }
- else
- logger.debug("Ball is not moving");
- */
int l_cycle=isBallKickableByMe();
! if (l_cycle >= 0) //hab den ball
! // if(m_myWorld.getBall().isVisible() && m_myWorld.getBall().isBallKickableBy(m_myWorld.getMyself()))
{
l_tempCoord = checkGoalKick();
! if (l_tempCoord != null){
! kickTo( l_tempCoord,l_cycle);
logger.debug("Goalpos: " + l_tempCoord.getY());
}
--- 484,494 ----
else
{
int l_cycle=isBallKickableByMe();
! if (m_myWorld.getBall().isVisible() && l_cycle >= 0) //hab den ball
{
l_tempCoord = checkGoalKick();
! if (l_tempCoord != null)
! {
! m_actions.kickTo(MAXPOWER, l_tempCoord,l_cycle);
logger.debug("Goalpos: " + l_tempCoord.getY());
}
***************
*** 502,506 ****
dribble(l_cycle);
else
! kickTo(ENEMY_GOAL_POS,l_cycle); //nix möglich, weghauen
}
}
--- 503,507 ----
dribble(l_cycle);
else
! m_actions.kickTo(MAXPOWER,ENEMY_GOAL_POS,l_cycle); //nix möglich, weghauen
}
}
***************
*** 563,567 ****
if(m_myWorld.getMyself().getAbsPosition().getX()>l_offsideBarrier-3)
{
! m_actions.runTo(NORMPOWER + 10, new Coordinate( l_offsideBarrier-8, HOMEPOS[m_myWorld.getMyself().getBackNumber()].getY()), m_myState.m_currentViewMode);
}
else if(atHomepos())
--- 564,568 ----
if(m_myWorld.getMyself().getAbsPosition().getX()>l_offsideBarrier-3)
{
! m_actions.runTo(NORMPOWER + 10, new Coordinate( l_offsideBarrier-5, HOMEPOS[m_myWorld.getMyself().getBackNumber()].getY()), m_myState.m_currentViewWidth);
}
else if(atHomepos())
***************
*** 569,575 ****
else
{
! if (m_myWorld.getSenseBodyInfo().m_stamina > 1000)
//m_actions.runTo (NORMPOWER + 10, HOMEPOS[m_myState.getState()][m_myWorld.getMyself().getBackNumber()]);
! m_actions.runTo(NORMPOWER + 10, HOMEPOS[m_myWorld.getMyself().getBackNumber()], m_myState.m_currentViewMode);
}
}
--- 570,576 ----
else
{
! if (m_myWorld.getSenseBodyInfo().m_stamina > 1500)
//m_actions.runTo (NORMPOWER + 10, HOMEPOS[m_myState.getState()][m_myWorld.getMyself().getBackNumber()]);
! m_actions.runTo(NORMPOWER + 10, HOMEPOS[m_myWorld.getMyself().getBackNumber()], m_myState.m_currentViewWidth);
}
}
***************
*** 591,595 ****
l_runToPos.setY(MY_GOAL_POS.getY() + (-Math.sin(l_angleOfBall) * f_radius));
if (Math.abs(m_myWorld.getMyself().getDistanceTo(l_runToPos)) > 0.8)
! m_actions.runTo(MAXPOWER, l_runToPos, m_myState.m_currentViewMode);
else
watchBall();
--- 592,596 ----
l_runToPos.setY(MY_GOAL_POS.getY() + (-Math.sin(l_angleOfBall) * f_radius));
if (Math.abs(m_myWorld.getMyself().getDistanceTo(l_runToPos)) > 0.8)
! m_actions.runTo(MAXPOWER, l_runToPos, m_myState.m_currentViewWidth);
else
watchBall();
***************
*** 602,606 ****
private void gotoEnemy(PlayerInfo f_player)
{
! m_actions.runTo(MAXPOWER, f_player.getAbsPosition(), m_myState.m_currentViewMode);
}
--- 603,607 ----
private void gotoEnemy(PlayerInfo f_player)
{
! m_actions.runTo(NORMPOWER, (f_player.getAbsPositionOfNextRound() != null) ? f_player.getAbsPositionOfNextRound() : f_player.getAbsPosition(), m_myState.m_currentViewWidth);
}
***************
*** 612,626 ****
if (m_myWorld.getBall().isVisible())
{
! if (m_myWorld.getMyself().getDistanceTo(getBallPosInRound(1)) < (ServerConf.CATCHABLE_AREA_L + (ServerConf.PLAYER_SIZE / 2) ))
{
m_actions.catchTheBall(0);
return;
}
! else if (m_myWorld.getMyself().getDistanceTo( getBallPosInRound(2)) < (ServerConf.CATCHABLE_AREA_L + (ServerConf.PLAYER_SIZE / 2) ))
{
m_actions.catchTheBall(1);
return;
}
! else if (m_myWorld.getMyself().getDistanceTo( getBallPosInRound(3)) < (ServerConf.CATCHABLE_AREA_L + (ServerConf.PLAYER_SIZE / 2) ))
{
m_actions.catchTheBall(2);
--- 613,627 ----
if (m_myWorld.getBall().isVisible())
{
! if (m_myWorld.getMyself().getDistanceTo(getBallPosInRound(0)) < (ServerConf.CATCHABLE_AREA_L ))
{
m_actions.catchTheBall(0);
return;
}
! else if (m_myWorld.getMyself().getDistanceTo( getBallPosInRound(1)) < (ServerConf.CATCHABLE_AREA_L ))
{
m_actions.catchTheBall(1);
return;
}
! else if (m_myWorld.getMyself().getDistanceTo( getBallPosInRound(2)) < (ServerConf.CATCHABLE_AREA_L ))
{
m_actions.catchTheBall(2);
***************
*** 652,659 ****
* @return Coordinate
*/
private Coordinate checkGoalKick()
{
double l_myAngleToGoal = 0.0;
- /** Find the best position on goal **/
PlayerInfo l_players;
--- 653,728 ----
* @return Coordinate
*/
+ /** Find the best position on goal **/
private Coordinate checkGoalKick()
{
+ if (!m_enemyTeam.isEmpty())
+ {
+ if (m_myWorld.getMyDistanceTo(ENEMY_GOAL_POS) > MAX_GOAL_KICK_DISTANCE) //Distance to great for a succesful goal kick
+ return null;
+
+ PlayerInfo l_enemyPlayer = null;
+ Coordinate l_shortCorner = ENEMY_GOAL_POS;
+ Coordinate l_longCorner = ENEMY_GOAL_POS;
+ Coordinate l_middleOfGoal = ENEMY_GOAL_POS;
+ double l_angleToGoal = 0;
+
+ l_angleToGoal = Math.atan((Math.abs(ENEMY_GOAL_POS.getY() - m_myWorld.getMyself().getAbsPosition().getY()) ) / (Math.abs(ENEMY_GOAL_POS.getX() - m_myWorld.getMyself().getAbsPosition().getX())));
+ if (l_angleToGoal > MAX_ANGLE_FOR_GOAL_KICK)
+ return null;
+
+ //Checking where I'm standing
+ if (m_myWorld.getMyself().getAbsPosition().getY() > ENEMY_GOAL_POS.getY()) //standing 'under' the middle goal
+ {
+ l_shortCorner.setY(ENEMY_GOAL_POS.getY() + (ServerConf.GOAL_WIDTH / 2 ) - 2);
+ l_longCorner.setY(ENEMY_GOAL_POS.getY() - (ServerConf.GOAL_WIDTH / 2 ) + 2);
+ }
+ else //standing 'over' the middle of the goal
+ {
+ l_longCorner.setY(ENEMY_GOAL_POS.getY() + (ServerConf.GOAL_WIDTH / 2 ) - 2);
+ l_shortCorner.setY(ENEMY_GOAL_POS.getY() - (ServerConf.GOAL_WIDTH / 2 ) + 2);
+ }
+
+ //now checking if the way to the goal is free
+ for (ListIterator it = m_enemyTeam.listIterator(); it.hasNext();)
+ {
+ l_enemyPlayer = (PlayerInfo)it.next();
+ if (Math.abs(m_myWorld.getBodyDirectionTo(l_enemyPlayer) - m_myWorld.getBodyDirectionTo(l_middleOfGoal)) < FREE_ANGLE_FOR_GOAL_KICK)
+ {
+ l_middleOfGoal = null;
+ }
+ if (Math.abs(m_myWorld.getBodyDirectionTo(l_enemyPlayer) - m_myWorld.getBodyDirectionTo(l_shortCorner)) < FREE_ANGLE_FOR_GOAL_KICK)
+ {
+ l_shortCorner = null;
+ }
+ if (Math.abs(m_myWorld.getBodyDirectionTo(l_enemyPlayer) - m_myWorld.getBodyDirectionTo(l_longCorner)) < FREE_ANGLE_FOR_GOAL_KICK)
+ {
+ l_longCorner = null;
+ }
+ }
+ if (l_middleOfGoal != null)
+ return l_middleOfGoal;
+ if (l_shortCorner != null)
+ return l_shortCorner;
+ return l_longCorner; //if also null, return null
+
+ }
+ else //enemyList empty
+ {
+ if (m_myWorld.getMyDistanceTo(ENEMY_GOAL_POS) > MAX_GOAL_KICK_DISTANCE)
+ return null;
+ else
+ return ENEMY_GOAL_POS;
+ }
+
+ }
+
+
+
+
+
+
+ /* private Coordinate checkGoalKick()
+ {
double l_myAngleToGoal = 0.0;
PlayerInfo l_players;
***************
*** 669,673 ****
if (m_myWorld.getMyself().getDistanceTo(ENEMY_GOAL_POS) < MAX_GOAL_KICK_DISTANCE)
{
- /** Find the best position on goal **/
if (!m_enemyTeam.isEmpty())
{
--- 738,741 ----
***************
*** 696,701 ****
l_shootOnPos.setY(l_greatestDistPos/2-.5);
l_myAngleToGoal = m_myWorld.getBodyDirectionTo(l_shootOnPos);
- /**Now we should have the best Point to shoot on,
- Checking if way to goal is free **/
if (!m_enemyTeam.isEmpty())
{
--- 764,767 ----
***************
*** 717,721 ****
return null;
}
!
/**
* Returns true if I am the nearest to the ball in the next cycles
--- 783,787 ----
return null;
}
! */
/**
* Returns true if I am the nearest to the ball in the next cycles
***************
*** 747,751 ****
l_minDistanceToBall = l_distanceToBall;
} //playerList
! if (l_minDistanceToBall + TOLERANCE > m_myWorld.getMyDistanceTo( m_myWorld.getBall() ))
return true;
}
--- 813,817 ----
l_minDistanceToBall = l_distanceToBall;
} //playerList
! if (l_minDistanceToBall + TOLERANCE > m_myWorld.getMyDistanceTo(m_myWorld.getBall()))
return true;
}
***************
*** 884,900 ****
private boolean checkDribble()
{
- boolean l_dribble = true;
if (!m_enemyTeam.isEmpty())
{
for (ListIterator it = m_enemyTeam.listIterator(); it.hasNext();)
{
! if (m_myWorld.getMyDistanceTo(m_myWorld.getMyself()) < MIN_DISTANCE_FOR_DRIBBEL)
{
! l_dribble = false;
! break;
}
}
}
! return l_dribble;
}
--- 950,966 ----
private boolean checkDribble()
{
if (!m_enemyTeam.isEmpty())
{
+ if (m_myWorld.isPlayerBehind()) //theres a player behind me...so dont dribble
+ return false;
for (ListIterator it = m_enemyTeam.listIterator(); it.hasNext();)
{
! if (m_myWorld.getMyDistanceTo((PlayerInfo)it.next()) < MIN_DISTANCE_FOR_DRIBBEL)
{
! return false;
}
}
}
! return true;
}
***************
*** 950,972 ****
private boolean atHomepos()
{
-
//if (m_myWorld.getMyself().getDistanceTo(HOMEPOS[m_myState.getState()][m_myWorld.getMyself().getBackNumber()]) > HOMERANGE_R)
if (m_myWorld.getMyself().getDistanceTo(HOMEPOS[m_myWorld.getMyself().getBackNumber()]) > HOMERANGE_R)
return false;
! else return true; //at homepos
!
! }
!
! /**
! * Kick to a given Coordinate in a given cycle
! * @param f_coord
! * @param f_cycle
! */
! private void kickTo(Coordinate f_coord, int f_cycle)
! {
! Coordinate l_kickVector= f_coord.sub(m_myWorld.getMyself().getAbsPosition());
! //int l_kickpower = Math.min(100, 7*(int)Math.sqrt( l_kickVector.getX() *l_kickVector.getX() +l_kickVector.getY()*l_kickVector.getY()));
! double l_kickpower=MAXPOWER;
! m_actions.kickTo(l_kickpower, f_coord, f_cycle);
}
--- 1016,1024 ----
private boolean atHomepos()
{
//if (m_myWorld.getMyself().getDistanceTo(HOMEPOS[m_myState.getState()][m_myWorld.getMyself().getBackNumber()]) > HOMERANGE_R)
if (m_myWorld.getMyself().getDistanceTo(HOMEPOS[m_myWorld.getMyself().getBackNumber()]) > HOMERANGE_R)
return false;
! else
! return true; //at homepos
}
***************
*** 991,998 ****
double l_power;
Coordinate l_dribbleToPos;
-
l_power = MAXPOWER;
l_dribbleToPos = ENEMY_GOAL_POS;
-
m_actions.dribbelTo(l_power, l_dribbleToPos, f_cycle);
}
--- 1043,1048 ----
***************
*** 1000,1036 ****
/**
- * Returns the number of round when the ball is kickable
- * @return int
- */
- private int ballAvailableInNextRounds()
- {
- if (m_myWorld.getBall().isBallKickableBy(m_myWorld.getMyself()))
- return 0;
- else
- {
- if (m_myWorld.getMyself().getDistanceTo(getBallPosInRound(1)) < ServerConf.KICKABLE_MARGIN + (ServerConf.PLAYER_SIZE / 2 ) + (ServerConf.BALL_SIZE / 2))
- return 1;
- else
- {
- if (m_myWorld.getMyself().getDistanceTo(getBallPosInRound(2)) < ServerConf.KICKABLE_MARGIN + (ServerConf.PLAYER_SIZE / 2 ) + (ServerConf.BALL_SIZE / 2))
- return 2;
- }
- }
- return -1;
- }
-
-
- /**
* This method calculates at which position our Ball is after f_cycles
! * @param f_cycles defines how far we should look into the future
* @return Coordinate of future position
*/
private Coordinate getBallPosInRound(int f_cycles)
{
! Coordinate l_deltaBall = new Coordinate(0, 0);
! Coordinate l_finalPos = new Coordinate(0, 0);
! if (f_cycles ==0)
! return m_myWorld.getBall().getAbsPosition();
! else if (m_myWorld.getBall().getAbsPositionOfNextRound() != null)
{
l_deltaBall = m_myWorld.getBall().getAbsPositionOfNextRound().sub(m_myWorld.getBall().getAbsPosition());
--- 1050,1062 ----
/**
* This method calculates at which position our Ball is after f_cycles
! * @param f_cycles defines how far we should look into the future (e.g. if f_cycles==1 we take AbsPosOfNextRound
* @return Coordinate of future position
*/
private Coordinate getBallPosInRound(int f_cycles)
{
! Coordinate l_deltaBall;
! Coordinate l_finalPos;
! if (f_cycles !=0 && m_myWorld.getBall().getAbsPositionOfNextRound() != null)
{
l_deltaBall = m_myWorld.getBall().getAbsPositionOfNextRound().sub(m_myWorld.getBall().getAbsPosition());
***************
*** 1044,1049 ****
}
-
-
/**
* With this method the KI is started at the beginning
--- 1070,1073 ----
***************
*** 1083,1100 ****
* @return int
*/
! private int isBallKickableByMe(){
! if (m_myWorld.getBall().isVisible())
{
! if (m_myWorld.getBall().getDistance() < ServerConf.KICKABLE_MARGIN + (ServerConf.PLAYER_SIZE / 2 ) + (ServerConf.BALL_SIZE / 2))
! {
! // logger.debug("Pos in next: (0) " + m_myWorld.getBall().getAbsPositionOfNextRound());
! return 0;
! }
! else if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null && m_myWorld.getMyself().getDistanceTo( getBallPosInRound(1)) < ServerConf.KICKABLE_MARGIN + (ServerConf.PLAYER_SIZE / 2 ) + (ServerConf.BALL_SIZE / 2))
! {
! // logger.debug("Pos in next: (1)" + m_myWorld.getBall().getAbsPositionOfNextRound());
! // logger.debug("dist to ball in next round"+m_myWorld.getMyself().getDistanceTo( getBallPosInRound(1)));
! return 1;
! }
}
return -1;
--- 1107,1119 ----
* @return int
*/
! private int isBallKickableByMe()
! {
! if (m_myWorld.getMyDistanceTo(m_myWorld.getBall())< ServerConf.KICKABLE_MARGIN + (ServerConf.PLAYER_SIZE / 2 ) + (ServerConf.BALL_SIZE / 2))
{
! return 0;
! }
! else if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null && m_myWorld.getMyDistanceTo( m_myWorld.getBall().getAbsPositionOfNextRound()) < ServerConf.KICKABLE_MARGIN + (ServerConf.PLAYER_SIZE / 2 ) + (ServerConf.BALL_SIZE / 2))
! {
! return 1;
}
return -1;
***************
*** 1110,1144 ****
if(!m_myWorld.getBall().isVisible())
{
! if (m_myWorld.sorry_whatTimeDoWeHave()-m_myWorld.getBall().getTime()>6)
{
! if (m_myState.m_currentViewMode!=SenseBodyInfo.WIDE)
m_actions.changeView(SenseBodyInfo.WIDE,true);
! m_myState.m_currentViewMode=SenseBodyInfo.WIDE;
}
else
{
! if (m_myState.m_currentViewMode!=SenseBodyInfo.NORMAL)
m_actions.changeView(SenseBodyInfo.NORMAL,true);
! m_myState.m_currentViewMode=SenseBodyInfo.NORMAL;
}
}
! else if (m_myWorld.getMyDistanceTo(m_myWorld.getBall())< 2)
! {
! if (m_myState.m_currentViewMode!=SenseBodyInfo.NARROW)
! m_actions.changeView(SenseBodyInfo.NARROW,true);
! m_myState.m_currentViewMode=SenseBodyInfo.NARROW;
! }
! else if (m_myWorld.getMyDistanceTo(m_myWorld.getBall())< 40)
! {
! if (m_myState.m_currentViewMode!=SenseBodyInfo.NORMAL)
! m_actions.changeView(SenseBodyInfo.NORMAL,true);
! m_myState.m_currentViewMode=SenseBodyInfo.NORMAL;
! }
! else
{
! if (m_myState.m_currentViewMode!=SenseBodyInfo.WIDE)
! m_actions.changeView(SenseBodyInfo.WIDE,true);
! m_myState.m_currentViewMode=SenseBodyInfo.WIDE;
}
}
! }
--- 1129,1168 ----
if(!m_myWorld.getBall().isVisible())
{
! m_myState.m_searchingBall=true;
! if (m_myWorld.sorry_whatTimeDoWeHave()-m_myWorld.getBall().getTime()>m_myState.m_currentViewWidth)
{
! if (m_myState.m_currentViewWidth!=SenseBodyInfo.WIDE)
m_actions.changeView(SenseBodyInfo.WIDE,true);
! m_myState.m_currentViewWidth=SenseBodyInfo.WIDE;
}
else
{
! if (m_myState.m_currentViewWidth!=SenseBodyInfo.NORMAL)
m_actions.changeView(SenseBodyInfo.NORMAL,true);
! m_myState.m_currentViewWidth=SenseBodyInfo.NORMAL;
}
}
! else //ball is visible
{
! m_myState.m_searchingBall=false;
! if (m_myWorld.getMyDistanceTo(m_myWorld.getBall())< 4 && Math.abs(m_myWorld.getBall().getDirection())<StateManager.VIEW_ANGLES[SenseBodyInfo.NARROW]/2)
! {
! if (m_myState.m_currentViewWidth!=SenseBodyInfo.NARROW)
! m_actions.changeView(SenseBodyInfo.NARROW,true);
! m_myState.m_currentViewWidth=SenseBodyInfo.NARROW;
! }
! else if (m_myWorld.getMyDistanceTo(m_myWorld.getBall())< 25 && Math.abs(m_myWorld.getBall().getDirection())<StateManager.VIEW_ANGLES[SenseBodyInfo.NORMAL]/2)
! {
! if (m_myState.m_currentViewWidth !=SenseBodyInfo.NORMAL)
! m_actions.changeView(SenseBodyInfo.NORMAL,true);
! m_myState.m_currentViewWidth=SenseBodyInfo.NORMAL;
! }
! else
! {
! if (m_myState.m_currentViewWidth !=SenseBodyInfo.WIDE)
! m_actions.changeView(SenseBodyInfo.WIDE,true);
! m_myState.m_currentViewWidth=SenseBodyInfo.WIDE;
! }
}
}
! }
\ No newline at end of file
Index: ActionManager.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/player/ActionManager.java,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -d -r1.60 -r1.61
*** ActionManager.java 14 Jul 2002 14:01:23 -0000 1.60
--- ActionManager.java 14 Jul 2002 22:56:40 -0000 1.61
***************
*** 8,12 ****
import org.apache.log4j.Logger;
-
/**
* <p>Title: Actionmanager</p>
--- 8,11 ----
***************
*** 37,41 ****
static final int NOP = 6;
-
private LinkedList m_actionList;
private WorldModel m_myWorld;
--- 36,39 ----
***************
*** 49,52 ****
--- 47,51 ----
private Thread m_performerThread;
private boolean m_threadSuspended;
+ private StateManager m_myState;
/**
* Creates a new <code>ActionManager</code> instance.
***************
*** 56,61 ****
* @roseuid 3CEB6AAA0062
*/
! public ActionManager(WorldModel f_myWorld, Communication f_myCom, int f_playerNumber)
{
this.setName("ActionPerformer"+f_playerNumber);
m_myWorld = f_myWorld;
--- 55,61 ----
* @roseuid 3CEB6AAA0062
*/
! public ActionManager(WorldModel f_myWorld, Communication f_myCom, int f_playerNumber, StateManager f_stateManager)
{
+ m_myState=f_stateManager;
this.setName("ActionPerformer"+f_playerNumber);
m_myWorld = f_myWorld;
***************
*** 78,82 ****
// Ball ist nah genug zu kicken
m_actionList.add(m_actionList.size(),new Action(KICK, f_power * DRIBBELKICKPOWER ,
! m_myWorld.getBodyDirectionTo(f_position)));
m_actionList.add(m_actionList.size(),new Action(TURN, m_myWorld.getBodyDirectionTo(f_position) , 0));
m_actionList.add(m_actionList.size(),new Action(DASH, f_power , 0));
--- 78,82 ----
// Ball ist nah genug zu kicken
m_actionList.add(m_actionList.size(),new Action(KICK, f_power * DRIBBELKICKPOWER ,
! m_myWorld.getBodyDirectionTo(f_position)));
m_actionList.add(m_actionList.size(),new Action(TURN, m_myWorld.getBodyDirectionTo(f_position) , 0));
m_actionList.add(m_actionList.size(),new Action(DASH, f_power , 0));
***************
*** 85,89 ****
nop();
m_actionList.add(m_actionList.size(),new Action(KICK, f_power * DRIBBELKICKPOWER ,
! m_myWorld.getBodyDirectionTo(f_position)));
m_actionList.add(m_actionList.size(),new Action(TURN, m_myWorld.getBodyDirectionTo(f_position) , 0));
break;
--- 85,89 ----
nop();
m_actionList.add(m_actionList.size(),new Action(KICK, f_power * DRIBBELKICKPOWER ,
! m_myWorld.getBodyDirectionTo(f_position)));
m_actionList.add(m_actionList.size(),new Action(TURN, m_myWorld.getBodyDirectionTo(f_position) , 0));
break;
***************
*** 92,96 ****
nop();
m_actionList.add(m_actionList.size(),new Action(KICK, f_power * DRIBBELKICKPOWER ,
! m_myWorld.getBodyDirectionTo(f_position)));
break;
default:
--- 92,96 ----
nop();
m_actionList.add(m_actionList.size(),new Action(KICK, f_power * DRIBBELKICKPOWER ,
! m_myWorld.getBodyDirectionTo(f_position)));
break;
default:
***************
*** 111,117 ****
public void kickTo(double f_power, Coordinate f_position, int f_cycle)
{
! logger.debug("Kickto Cycles: " + f_cycle);
double l_turnedDirection=m_myWorld.getBodyDirectionTo(m_myWorld.getBall());
double l_moment= l_turnedDirection * moment();
Coordinate l_posOfBallInNextRound=null;
Coordinate l_posOfBallOverNextRound=null;
--- 111,123 ----
public void kickTo(double f_power, Coordinate f_position, int f_cycle)
{
! // logger.fatal("Kickto Cycles: " + f_cycle + " dist: " +m_myWorld.getMyDistanceTo(m_myWorld.getBall()) + "dir:" +(int)m_myWorld.getBodyDirectionTo(m_myWorld.getBall()));
double l_turnedDirection=m_myWorld.getBodyDirectionTo(m_myWorld.getBall());
double l_moment= l_turnedDirection * moment();
+ /* if (Math.abs(l_turnedDirection)>20)
+ {
+ m_actionList.add(m_actionList.size(),new Action(TURN,l_moment,0));
+ return;
+ }
+ */
Coordinate l_posOfBallInNextRound=null;
Coordinate l_posOfBallOverNextRound=null;
***************
*** 129,138 ****
case 1:
// Is Ball moving?
- System.out.println("wanted to kick in 1 cycle");
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null)
{
// Position of the ball when finally kicking
l_posDiff=m_myWorld.getBall().getAbsPositionOfNextRound().sub(m_myWorld.getBall().getAbsPosition());
! l_dashPwr= edp2pwr(m_myWorld.getMyself().getDistanceTo(m_myWorld.getBall().getAbsPositionOfNextRound())-MINDISTTOBALL
-(m_myWorld.getSenseBodyInfo().m_amountOfSpeed ));
}
--- 135,143 ----
case 1:
// Is Ball moving?
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null)
{
// Position of the ball when finally kicking
l_posDiff=m_myWorld.getBall().getAbsPositionOfNextRound().sub(m_myWorld.getBall().getAbsPosition());
! l_dashPwr= edp2pwr(m_myWorld.getMyDistanceTo(m_myWorld.getBall().getAbsPositionOfNextRound())-MINDISTTOBALL
-(m_myWorld.getSenseBodyInfo().m_amountOfSpeed ));
}
***************
*** 140,146 ****
{
//Ball is not moving, but maybe myself
! l_dashPwr= edp2pwr( m_myWorld.getMyself().getDistanceTo( m_myWorld.getBall().getAbsPosition()) -MINDISTTOBALL
! -(m_myWorld.getSenseBodyInfo().m_amountOfSpeed
! ));
}
--- 145,151 ----
{
//Ball is not moving, but maybe myself
! l_dashPwr= edp2pwr( m_myWorld.getMyDistanceTo( m_myWorld.getBall().getAbsPosition()) -MINDISTTOBALL
! -m_myWorld.getSenseBodyInfo().m_amountOfSpeed
! );
}
***************
*** 148,152 ****
m_actionList.add(m_actionList.size(),new Action(DASH,l_dashPwr , 0));
m_actionList.add(m_actionList.size(),new Action(KICK, f_power, l_kickDir ));
- // nop();
break;
/* case 2:
--- 153,156 ----
***************
*** 154,158 ****
// Is Ball moving?
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null) {
! // Position of the ball when finally kicking
l_posDiff=m_myWorld.getBall().getAbsPositionOfNextRound().sub(m_myWorld.getBall().getAbsPosition());
l_posOfBallOverOverNextRound=m_myWorld.getBall().getAbsPositionOfNextRound().
--- 158,162 ----
// Is Ball moving?
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null) {
! // Position of the ball when finally kicking
l_posDiff=m_myWorld.getBall().getAbsPositionOfNextRound().sub(m_myWorld.getBall().getAbsPosition());
l_posOfBallOverOverNextRound=m_myWorld.getBall().getAbsPositionOfNextRound().
***************
*** 160,173 ****
add(l_posDiff.scaleWith(ServerConf.BALL_DECAY*ServerConf.BALL_DECAY));
! // Direction of the ball when finally kicking
l_turnedDirection=m_myWorld.getBodyDirectionTo(l_posOfBallOverOverNextRound);
! // Moment of the ball when finally kicking
l_moment= l_turnedDirection * moment();
l_dashPwr= edp2pwr(m_myWorld.getMyself().getDistanceTo(l_posOfBallOverOverNextRound)-MINDISTTOBALL
-(m_myWorld.getSenseBodyInfo().m_amountOfSpeed
! *Math.pow(ServerConf.PLAYER_DECAY,3)));
}
else{
! //Ball is not moving, but maybe myself
l_turnedDirection=m_myWorld.getBodyDirectionTo( m_myWorld.getBall());
l_moment= l_turnedDirection * moment();
--- 164,177 ----
add(l_posDiff.scaleWith(ServerConf.BALL_DECAY*ServerConf.BALL_DECAY));
! // Direction of the ball when finally kicking
l_turnedDirection=m_myWorld.getBodyDirectionTo(l_posOfBallOverOverNextRound);
! // Moment of the ball when finally kicking
l_moment= l_turnedDirection * moment();
l_dashPwr= edp2pwr(m_myWorld.getMyself().getDistanceTo(l_posOfBallOverOverNextRound)-MINDISTTOBALL
-(m_myWorld.getSenseBodyInfo().m_amountOfSpeed
! *Math.pow(ServerConf.PLAYER_DECAY,3)));
}
else{
! //Ball is not moving, but maybe myself
l_turnedDirection=m_myWorld.getBodyDirectionTo( m_myWorld.getBall());
l_moment= l_turnedDirection * moment();
***************
*** 214,344 ****
public void performAction()
{
! if (!m_actionList.isEmpty())
{
! double l_actionAngle=0;
! switch(((Action)m_actionList.getFirst()).getActionType())
{
! case KICK:
! try
! {
! m_myCom.kick(( (Action) m_actionList.getFirst() ).getActionValue1(), ( (Action) m_actionList.getFirst() ).getActionValue2());
! //turn our head to where we kicked the ball to
! l_actionAngle=((Action)m_actionList.getFirst()).getActionValue2()/moment();
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send kick action!"+xCom.getMessage());
! }
! // m_myWorld.informKick(( (Action) m_actionList.getFirst() ).getActionValue1(), l_actionAngle );
! break;
! case TURN:
! try
! {
! m_myCom.turn(((Action)m_actionList.getFirst()).getActionValue1());
! l_actionAngle=(((Action)m_actionList.getFirst()).getActionValue1() / moment());
// nop();
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send turn action!"+xCom.getMessage());
! }
// m_myWorld.informTurn(l_actionAngle );
! break;
! case DASH:
! try
! {
! m_myCom.dash(((Action)m_actionList.getFirst()).getActionValue1());
! // m_myWorld.informDash(((Action)m_actionList.getFirst()).getActionValue1());
! if (m_myWorld.getBall().isVisible())
{
! /** @todo turn neck here, so we dont loose ball when dashing */
}
- }
- catch (xCommunication xCom)
- {
- logger.debug("Could not send dash action!"+xCom.getMessage());
- }
! // logger.warn(" --- DASH send to Server ---") ;
! break;
! case MOVE:
! try
! {
! m_myCom.move(((Action)m_actionList.getFirst()).getActionValue1(), ( (Action) m_actionList.getFirst() ).getActionValue2());
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send move action!"+xCom.getMessage());
! }
! // m_myWorld.informMove(((Action)m_actionList.getFirst()).getActionValue1(), ( (Action) m_actionList.getFirst() ).getActionValue2());
! // logger.warn(" --- MOVE send to Server ---") ;
! break;
! case CATCHBALL:
! try
! {
! m_myCom.catchBall(m_myWorld.getBodyDirectionTo(m_myWorld.getBall()));
! // logger.warn(" --- CATCHBALL send to Server ---") ;
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send catch ball action!"+xCom.getMessage());
! }
// m_myWorld.informCatchBall(m_myWorld.getBodyDirectionTo(m_myWorld.getBall()));
! break;
! case SAY:
! try
! {
! m_myCom.say(m_voiceMessage);
! // logger.warn(" --- SAY send to Server ---");
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send say ball action!"+xCom.getMessage());
! }
! break;
! case NOP:
! break;
! default:
! logger.debug("Hier ist was schiefgelaufen :-( Actionmanager.java");
! }//switch
! int l_actionType=((Action)m_actionList.getFirst()).getActionType();
! if (l_actionType==ActionManager.DASH || l_actionType==ActionManager.KICK || l_actionType==ActionManager.TURN)
! {
! try
{
! if (m_visualUpdateHappened && m_myWorld.getBall().isVisible()) //on first step after new see event --> turn neck to ball
{
! double l_angleToBall=m_myWorld.getBall().getDirection();
! m_myCom.turnNeck(l_angleToBall-l_actionAngle);
// m_myWorld.informTurnNeck(l_angleToBall-l_actionAngle);
! m_visualUpdateHappened=false;
! }
! else if (m_myWorld.getBall().isVisible())
! {
! m_myCom.turnNeck(l_actionAngle);
// m_myWorld.informTurnNeck(l_actionAngle);
}
! else
{
! m_myCom.turnNeck(-m_myWorld.getNeckDirection());
! // m_myWorld.informTurnNeck(-m_myWorld.getNeckDirection());
}
}
! catch (xCommunication ex)
! {
! logger.debug("Caugght ex from Communication"+ex.getMessage());
! }
}
- m_actionList.remove(0);
- }
- else //action list is empty
- {
}
}//performAction
--- 218,361 ----
public void performAction()
{
! Action l_currentAction;
! synchronized (m_actionList)
{
! if (!m_actionList.isEmpty())
{
! double l_actionAngle=0;
! l_currentAction=(Action)m_actionList.getFirst();
! switch(l_currentAction.getActionType())
! {
! case KICK:
! try
! {
! m_myCom.kick(l_currentAction.getActionValue1(), l_currentAction.getActionValue2());
! //turn our head to where we kicked the ball to
! l_actionAngle=l_currentAction.getActionValue2()/moment();
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send kick action!"+xCom.getMessage());
! }
! // m_myWorld.informKick(l_currentAction.getActionValue1(), l_actionAngle );
! break;
! case TURN:
! try
! {
! m_myCom.turn(l_currentAction.getActionValue1());
! l_actionAngle=(l_currentAction.getActionValue1() / moment());
// nop();
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send turn action!"+xCom.getMessage());
! }
// m_myWorld.informTurn(l_actionAngle );
! break;
! case DASH:
! try
{
! m_myCom.dash(l_currentAction.getActionValue1());
! // m_myWorld.informDash(l_currentAction.getActionValue1());
! if (m_myWorld.getBall().isVisible())
! {
! /** @todo turn neck here, so we dont loose ball when dashing */
! }
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send dash action!"+xCom.getMessage());
}
! // logger.warn(" --- DASH send to Server ---") ;
! break;
! case MOVE:
! try
! {
! m_myCom.move(l_currentAction.getActionValue1(), l_currentAction.getActionValue2());
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send move action!"+xCom.getMessage());
! }
! // m_myWorld.informMove(l_currentAction.getActionValue1(), l_currentAction.getActionValue2());
! // logger.warn(" --- MOVE send to Server ---") ;
! break;
! case CATCHBALL:
! try
! {
! m_myCom.catchBall(l_currentAction.getActionValue1());
! // logger.warn(" --- CATCHBALL send to Server ---") ;
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send catch ball action!"+xCom.getMessage());
! }
// m_myWorld.informCatchBall(m_myWorld.getBodyDirectionTo(m_myWorld.getBall()));
! break;
! case SAY:
! try
! {
! m_myCom.say(m_voiceMessage);
! // logger.warn(" --- SAY send to Server ---");
! }
! catch (xCommunication xCom)
! {
! logger.debug("Could not send say ball action!"+xCom.getMessage());
! }
! break;
! case NOP:
! break;
! default:
! logger.debug("Hier ist was schiefgelaufen :-( Actionmanager.java");
! }//switch
! int l_actionType=l_currentAction.getActionType();
! if (l_actionType==ActionManager.DASH || l_actionType==ActionManager.KICK || l_actionType==ActionManager.TURN)
{
! try
{
! if (m_visualUpdateHappened && m_myWorld.getBall().isVisible()) //on first step after new see event --> turn neck to ball
! {
! double l_angleToTurnNeck=m_myWorld.getBall().getDirection()-l_actionAngle;
! if (Math.abs(l_angleToTurnNeck+m_myWorld.getNeckDirection())>90) //dont break ya neck
! {
! changeView(++m_myState.m_currentViewWidth,true);
! }
! m_myCom.turnNeck(l_angleToTurnNeck);
// m_myWorld.informTurnNeck(l_angleToBall-l_actionAngle);
! m_visualUpdateHappened=false;
! }
! else if(m_myState.m_searchingBall)
! {
! m_myCom.turnNeck(-m_myWorld.getNeckDirection());
! // m_myWorld.informTurnNeck(-m_myWorld.getNeckDirection());
! }
! else
! {
! m_myCom.turnNeck(l_actionAngle);
! if (Math.abs(l_actionAngle+m_myWorld.getNeckDirection())>90) //dont break ya neck
! {
! changeView(++m_myState.m_currentViewWidth,true);
! }
// m_myWorld.informTurnNeck(l_actionAngle);
+ }
}
! catch (xCommunication ex)
{
! logger.debug("Caugght ex from Communication"+ex.getMessage());
}
}
! m_actionList.remove(0);
! }
! else //action list is empty
! {
}
}
}//performAction
***************
*** 353,358 ****
{
m_actionList.add(m_actionList.size(),new Action(DASH, f_power, 0));
- // nop();
- // nop();
}
--- 370,373 ----
***************
*** 371,393 ****
double l_percentageOfPower=f_power/100;
boolean l_turnHappened=false;
! // Rückwarts rennen
! // if (runAback(f_position)) {
! // f_power = -f_power;
! // l_correctedPower = -l_correctedPower;
! // if (l_deltaAngle > 0)
! // l_deltaAngle -= 180;
! // else
! // l_deltaAngle += 180;
! // }
- // Muss ich mich zum Ball drehen?
- // JA
if(Math.abs(l_deltaAngle)>TOLERANCEANGLE)
{
! m_actionList.add(new Action(TURN,l_moment,0));
l_turnHappened=true;
}
- // logger.fatal("running to ball (turned)?" + l_turnHappened +" cycles "+ f_cycles +" moment "+ l_moment + " l_deltaAngle " +l_deltaAngle );
- // logger.fatal("absbodydirtoball"+m_myWorld.getBodyDirectionTo(m_myWorld.getBall()));
switch(f_cycles)
{
--- 386,403 ----
double l_percentageOfPower=f_power/100;
boolean l_turnHappened=false;
! // Rückwarts rennen
! // if (runAback(f_position)) {
! // f_power = -f_power;
! // if (l_deltaAngle > 0)
! // l_deltaAngle -= 180;
! // else
! // l_deltaAngle += 180;
! // }
if(Math.abs(l_deltaAngle)>TOLERANCEANGLE)
{
! m_actionList.add(m_actionList.size(),new Action(TURN,l_moment,0));
l_turnHappened=true;
}
switch(f_cycles)
{
***************
*** 395,409 ****
if (!l_turnHappened)
{
! l_power=edp2pwr((m_myWorld.getMyDistanceTo(f_position)-ServerConf.BALL_SIZE/2-ServerConf.PLAYER_SIZE/2-m_myWorld.getSenseBodyInfo().m_amountOfSpeed));
! m_actionList.add(new Action(DASH,Math.min(100,l_power),0));
}
break;
case SenseBodyInfo.NORMAL:
if(l_turnHappened)
! m_actionList.add(new Action(DASH,f_power,0));
else
{
! m_actionList.add(new Action(DASH,f_power,0));
! m_actionList.add(new Action(DASH,f_power,0));
}
break;
--- 405,426 ----
if (!l_turnHappened)
{
! l_power=l_percentageOfPower*edp2pwr((m_myWorld.getMyDistanceTo(f_position) - ServerConf.BALL_SIZE/2-ServerConf.PLAYER_SIZE/2)-m_myWorld.getSenseBodyInfo().m_amountOfSpeed);
! // logger.fatal("narrow dash sent"+Math.min(100,l_power));
! m_actionList.add(m_actionList.size(),new Action(DASH,Math.min(100,l_power),0));
}
break;
case SenseBodyInfo.NORMAL:
if(l_turnHappened)
! {
! l_power=l_percentageOfPower*edp2pwr((m_myWorld.getMyDistanceTo(f_position) - ServerConf.BALL_SIZE/2-ServerConf.PLAYER_SIZE/2)-m_myWorld.getSenseBodyInfo().m_amountOfSpeed);
! // logger.fatal("normal dash sent(with turn)"+Math.min(l_power,100));
! m_actionList.add(m_actionList.size(),new Action(DASH,Math.min(100,l_power),0));
! }
else
{
! l_power=l_percentageOfPower*edp2pwr((m_myWorld.getMyDistanceTo(f_position)-ServerConf.BALL_SIZE/2-ServerConf.PLAYER_SIZE/2)-m_myWorld.getSenseBodyInfo().m_amountOfSpeed);
! // logger.fatal("normal dash sent(wo turn)"+Math.min(100,l_power));
! m_actionList.add(m_actionList.size(),new Action(DASH,Math.min(100,l_power),0));
! m_actionList.add(m_actionList.size(),new Action(DASH,Math.min(100,l_power),0));
}
break;
***************
*** 411,422 ****
if(!l_turnHappened)
{
! m_actionList.add(new Action(DASH,f_power,0));
! m_actionList.add(new Action(DASH,f_power,0));
! m_actionList.add(new Action(DASH,f_power,0));
}
else
{
! m_actionList.add(new Action(DASH,f_power,0));
! m_actionList.add(new Action(DASH,f_power,0));
}
break;
--- 428,439 ----
if(!l_turnHappened)
{
! m_actionList.add(m_actionList.size(),new Action(DASH,f_power,0));
! m_actionList.add(m_actionList.size(),new Action(DASH,f_power,0));
! m_actionList.add(m_actionList.size(),new Action(DASH,f_power,0));
}
else
{
! m_actionList.add(m_actionList.size(),new Action(DASH,f_power,0));
! m_actionList.add(m_actionList.size(),new Action(DASH,f_power,0));
}
break;
***************
*** 426,431 ****
}
-
-
/**
* Wrapper for runTo with an ObjectInfo
--- 443,446 ----
***************
*** 448,455 ****
public void turn(double f_angle)
{
! m_actionList.add(m_actionList.size(),new Action(TURN, f_angle*moment(), -100));
! // nop();
! // nop();
! //m_myState.IncActionCounter();
}
--- 463,467 ----
public void turn(double f_angle)
{
! m_actionList.add(m_actionList.size(),new Action(TURN, f_angle*moment(),0));
}
***************
*** 466,471 ****
l_deltaAngle= m_myWorld.getBodyDirectionTo(m_myWorld.getBall());
m_actionList.add(m_actionList.size(),new Action(CATCHBALL, l_deltaAngle, 0));
- // nop();
- // nop();
break;
case 1:
--- 478,481 ----
***************
*** 473,477 ****
nop();
m_actionList.add(m_actionList.size(),new Action(CATCHBALL, l_deltaAngle, 0));
- // nop();
break;
case 2:
--- 483,486 ----
***************
*** 523,527 ****
public void flush()
{
! m_actionList.clear();
}
--- 532,539 ----
public void flush()
{
! synchronized (m_actionList)
! {
! m_actionList.clear();
! }
}
***************
*** 533,537 ****
public boolean listEmpty()
{
! return (m_actionList.isEmpty());
}
--- 545,552 ----
public boolean listEmpty()
{
! synchronized (m_actionList)
! {
! return (m_actionList.isEmpty());
! }
}
***************
*** 659,663 ****
try
{
! sleep(80);
performAction();
// logger.fatal("action performed"+System.currentTimeMillis());
--- 674,678 ----
try
{
! sleep(90);
performAction();
// logger.fatal("action performed"+System.currentTimeMillis());
***************
*** 675,679 ****
while (m_threadSuspended && l_thisThread==m_performerThread) //check again if we should sleep,
{
- //logger.info("\t" + getName() + ": Going to wait now for something new");
wait(); // this command lets our thread sleep until we wake him up
}
--- 690,693 ----
***************
*** 685,689 ****
}
}//of while()
- //logger.info("\t" + getName() + ": i've left my while-loop. run() will stop immediatly
}
--- 699,702 ----
|