[Jais-checkins] jaisteam/src/jais/player KI.java,1.79,1.80 ActionManager.java,1.61,1.62
Status: Beta
Brought to you by:
maestrodd
|
From: <mae...@us...> - 2002-07-15 09:27:26
|
Update of /cvsroot/jais/jaisteam/src/jais/player
In directory usw-pr-cvs1:/tmp/cvs-serv15661/player
Modified Files:
KI.java ActionManager.java
Log Message:
many many cahnges ;) version 1.01 is ready !
Index: KI.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/player/KI.java,v
retrieving revision 1.79
retrieving revision 1.80
diff -C2 -d -r1.79 -r1.80
*** KI.java 14 Jul 2002 22:56:40 -0000 1.79
--- KI.java 15 Jul 2002 09:27:23 -0000 1.80
***************
*** 43,54 ****
private final double MAXPOWER = 100; //ServerConf.MAXPOWER;
! private final int HOMERANGE_R = 5;
private final Coordinate MY_GOAL_POS = new Coordinate(-52.5, 0);
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;
--- 43,53 ----
private final double MAXPOWER = 100; //ServerConf.MAXPOWER;
! private final int HOMERANGE_R = 6;
private final Coordinate MY_GOAL_POS = new Coordinate(-52.5, 0);
private final Coordinate ENEMY_GOAL_POS = new Coordinate(52.5, 0);
! private final int MAX_GOAL_KICK_DISTANCE = 30;
private final int MIN_DISTANCE_FOR_DRIBBEL = 10;
private final int MAX_PASS_DISTANCE =30;
! private final int MAX_LOOKING_FORWARD_TIME = 10;
private final int MAX_ANGLE_FOR_GOAL_KICK = 75;
private final int FREE_ANGLE_FOR_GOAL_KICK = 5;
***************
*** 91,106 ****
//ok, we were waked up, so theres new information avaiable. discard last actions and decide new
m_actions.flush();
! try
! {
! m_actions.InformVisualUpdateHappened();
! m_enemyTeam=m_myWorld.getEnemyPlayers();
! m_ownTeam=m_myWorld.getFriendlyPlayers();
! root(); //Start our tree in the root
! }
! catch (Exception ex)
{
! logger.debug("Caught Execption from root in KI"+ex.getMessage());
! ex.printStackTrace();
! logger.debug("Report this to jai...@li.... KI is still Working!");
}
m_threadSuspended=true; //we want to suspend ourself after one run
--- 90,108 ----
//ok, we were waked up, so theres new information avaiable. discard last actions and decide new
m_actions.flush();
! //if (m_actions.listEmpty())
{
! try
! {
! m_actions.InformVisualUpdateHappened();
! m_enemyTeam=m_myWorld.getEnemyPlayers();
! m_ownTeam=m_myWorld.getFriendlyPlayers();
! root(); //Start our tree in the root
! }
! catch (Exception ex)
! {
! logger.debug("Caught Execption from root in KI"+ex.getMessage());
! //ex.printStackTrace();
! logger.debug("Report this to jai...@li.... KI is still Working!");
! }
}
m_threadSuspended=true; //we want to suspend ourself after one run
***************
*** 251,262 ****
else if (nearestToTheBall()){
if(m_myWorld.getBall().isBallKickableBy(m_myWorld.getMyself()))
! 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);
}
}
else {
// Ich bin nicht dran
! watchBall();
return;
--- 253,264 ----
else if (nearestToTheBall()){
if(m_myWorld.getBall().isBallKickableBy(m_myWorld.getMyself()))
! m_actions.kickTo(MAXPOWER,ENEMY_GOAL_POS,m_myWorld.getViewModeAsInt()); // schön ausrichten und voll draufhauen
else
! m_actions.runTo(NORMPOWER,m_myWorld.getBall(), m_myWorld.getViewModeAsInt());
}
}
else {
// Ich bin nicht dran
! gotoHomePosition();
return;
***************
*** 285,304 ****
if (nearestToTheBall())
{
! if(m_myWorld.getBall().getDistance() < ServerConf.KICKABLE_MARGIN )
{
if(m_myWorld.getMyself().getAbsPosition().getX()<-30)
! l_tempPlayer =checkForPassPartner(20);
else if(m_myWorld.getMyself().getAbsPosition().getX()>40)
! l_tempPlayer =checkForPassPartner(-5);
else
! 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);
}
}
--- 287,310 ----
if (nearestToTheBall())
{
! if (m_myWorld.getMyDistanceTo(m_myWorld.getBall())>3.5)
! {
! m_actions.runTo(MINPOWER+5,new Coordinate(m_myWorld.getBall().getAbsPosition().getX()-3,m_myWorld.getBall().getAbsPosition().getY()),m_myWorld.getViewModeAsInt());
! }
! if(m_myWorld.getBall().getDistance() < ServerConf.KICKABLE_MARGIN + ServerConf.PLAYER_SIZE/2 +ServerConf.BALL_SIZE/2)
{
if(m_myWorld.getMyself().getAbsPosition().getX()<-30)
! l_tempPlayer =checkForPassPartner(25);
else if(m_myWorld.getMyself().getAbsPosition().getX()>40)
! l_tempPlayer =checkForPassPartner(-10);
else
! l_tempPlayer =checkForPassPartner(13);
if (l_tempPlayer != null)
! passTo(l_tempPlayer,m_myWorld.getViewModeAsInt());
else
! kickToCleverPosition(-1);
}
else
{
! m_actions.runTo(MINPOWER, m_myWorld.getBall(), m_myWorld.getViewModeAsInt());
}
}
***************
*** 308,313 ****
{
// Wir sind nicht dran :-(
! // Gehe ein wenig zurück, wenn ich zu bei Abstoss zu nah am Gegener stehe(stamina abzug)
! if(m_myWorld.getMyself().getDistanceTo(m_myWorld.getBall().getAbsPosition()) < 10)
{
m_actions.run((int)-NORMPOWER);
--- 314,319 ----
{
// Wir sind nicht dran :-(
! // Gehe ein wenig zurück, wenn ich zu nah am Gegner stehe(stamina abzug)
! if(m_myWorld.getMyDistanceTo(m_myWorld.getBall()) < 13)
{
m_actions.run((int)-NORMPOWER);
***************
*** 330,351 ****
{
// Is Ball Visible
! if(m_myWorld.getBall().isVisible()){
! if(m_myWorld.getBall().getDistance() < ServerConf.KICKABLE_MARGIN )
{
! 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);
}
-
}
else
searchBall();
-
}
}
--- 336,361 ----
{
// Is Ball Visible
! if(m_myWorld.getBall().isVisible())
! {
! if (m_myWorld.getMyDistanceTo(m_myWorld.getBall())> 3)
{
! m_actions.runTo(MINPOWER+5, new Coordinate(m_myWorld.getBall().getAbsPosition().getX()-2.5,m_myWorld.getBall().getAbsPosition().getY()), m_myWorld.getViewModeAsInt());
! return;
! }
! if(m_myWorld.getBall().getDistance() < ServerConf.KICKABLE_MARGIN + ServerConf.PLAYER_SIZE/2 +ServerConf.BALL_SIZE/2)
! {
! l_tempPlayer =checkForPassPartner(25);
if (l_tempPlayer != null)
! passTo(l_tempPlayer,m_myWorld.getViewModeAsInt());
else
! kickToCleverPosition(-1);
}
else
{
! m_actions.runTo(MINPOWER+5, m_myWorld.getBall(), m_myWorld.getViewModeAsInt());
}
}
else
searchBall();
}
}
***************
*** 384,396 ****
/**
- * Go between the ball and an Enemy
- * @roseuid 3CE80E4F0251
- */
- private void goBetweenBallEnemy()
- {
-
- }
-
- /**
* Watch the ball
* @roseuid 3CE80EAF0138
--- 394,397 ----
***************
*** 440,444 ****
{
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)
--- 441,445 ----
{
l_zaehler++;
! l_myTempPos=l_myTempPos.add(l_diffPos.scaleWith(m_myWorld.getViewModeAsInt()));
l_nextDistance = l_myTempPos.getDistanceTo(getBallPosInRound(l_zaehler));
if (l_nextDistance < l_smallestDistance)
***************
*** 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);
}
--- 450,457 ----
}
}
! m_actions.runTo(MAXPOWER,getBallPosInRound(l_estimatedCyclesToReachTheBall), m_myWorld.getViewModeAsInt());
}
else //ball doesnt move so simply go to its position
! m_actions.runTo(MAXPOWER,m_myWorld.getBall(), m_myWorld.getViewModeAsInt());
}
***************
*** 464,470 ****
// 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);
}
--- 465,471 ----
// if it is behind us, simply run a bit backwards
if (m_myWorld.getBall().getDirection() > 0)
! m_actions.turn(SenseBodyInfo.getAngleFromViewMode(m_myWorld.getViewMode())-15);
else
! m_actions.turn(-SenseBodyInfo.getAngleFromViewMode(m_myWorld.getViewMode())+15);
}
***************
*** 491,495 ****
{
m_actions.kickTo(MAXPOWER, l_tempCoord,l_cycle);
- logger.debug("Goalpos: " + l_tempCoord.getY());
}
else
--- 492,495 ----
***************
*** 497,507 ****
l_tempPlayer =checkForPassPartner(10);
if (l_tempPlayer != null)
passTo(l_tempPlayer,l_cycle);
else
{
if (checkDribble())
dribble(l_cycle);
else
! m_actions.kickTo(MAXPOWER,ENEMY_GOAL_POS,l_cycle); //nix möglich, weghauen
}
}
--- 497,513 ----
l_tempPlayer =checkForPassPartner(10);
if (l_tempPlayer != null)
+ {
passTo(l_tempPlayer,l_cycle);
+ }
else
{
if (checkDribble())
+ {
dribble(l_cycle);
+ }
else
! {
! kickToCleverPosition(l_cycle);
! }
}
}
***************
*** 525,532 ****
else //no enemy in my range.
{
! if (atHomepos())
! watchBall();
! else
! gotoHomePosition();
}
}
--- 531,535 ----
else //no enemy in my range.
{
! gotoHomePosition();
}
}
***************
*** 553,556 ****
--- 556,562 ----
/** @todo do something clever here */
gotoHomePosition();
+ PlayerInfo l_player=enemyInRange();
+ if (l_player!=null) // we should walk free then
+ goBetweenBallAndEnemyAndWatchBall(l_player);
}
***************
*** 561,568 ****
private void gotoHomePosition()
{
double l_offsideBarrier=getOffsideBarrier(m_enemyTeam,m_ownTeam); //seems there are
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())
--- 567,579 ----
private void gotoHomePosition()
{
+ if (m_myState.m_currentViewWidth!=SenseBodyInfo.WIDE)
+ {
+ m_actions.changeView(SenseBodyInfo.WIDE,true);
+ m_myState.m_currentViewWidth=SenseBodyInfo.WIDE;
+ }
double l_offsideBarrier=getOffsideBarrier(m_enemyTeam,m_ownTeam); //seems there are
if(m_myWorld.getMyself().getAbsPosition().getX()>l_offsideBarrier-3)
{
! m_actions.runTo(NORMPOWER , new Coordinate( l_offsideBarrier-5, HOMEPOS[m_myWorld.getMyself().getBackNumber()].getY()), m_myWorld.getViewModeAsInt());
}
else if(atHomepos())
***************
*** 571,576 ****
{
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);
}
}
--- 582,586 ----
{
if (m_myWorld.getSenseBodyInfo().m_stamina > 1500)
! m_actions.runTo(NORMPOWER , HOMEPOS[m_myWorld.getMyself().getBackNumber()], m_myWorld.getViewModeAsInt());
}
}
***************
*** 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 ----
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(NORMPOWER, l_runToPos, m_myWorld.getViewModeAsInt());
else
watchBall();
***************
*** 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);
}
--- 613,617 ----
private void gotoEnemy(PlayerInfo f_player)
{
! m_actions.runTo(NORMPOWER, (f_player.getAbsPositionOfNextRound() != null) ? f_player.getAbsPositionOfNextRound() : f_player.getAbsPosition(), m_myWorld.getViewModeAsInt());
}
***************
*** 613,643 ****
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);
return;
}
else
{
! if (nearestToTheBall())
{
! takeTheBall();
! return;
}
else
! {
! goBetweenBallGoalAndWatchIt(ServerConf.GOAL_WIDTH / 2);
! return;
! }
}
}
--- 623,652 ----
if (m_myWorld.getBall().isVisible())
{
! int l_cycles = isBallCatchable();
! if (l_cycles>=0)
{
! m_actions.catchTheBall(l_cycles);
return;
}
else
{
! int l_cycle=isBallKickableByMe();
! if (l_cycle >= 0)
{
! PlayerInfo l_tempPlayer =checkForPassPartner(30);
! if (l_tempPlayer != null)
! {
! passTo(l_tempPlayer,l_cycle);
! }
! else
! {
! kickToCleverPosition(l_cycle);
! }
}
else
! if (nearestToTheBall())
! takeTheBall();
! else
! goBetweenBallGoalAndWatchIt(ServerConf.GOAL_WIDTH/2);
}
}
***************
*** 645,652 ****
{
searchBall();
- return;
}
}
/**
* Return the best position for a goalkick if a goalkick is posible
--- 654,679 ----
{
searchBall();
}
}
+ private int isBallCatchable()
+ {
+ if ((Math.abs(m_myWorld.getBall().getAbsPosition().getY())<20 && m_myWorld.getBall().getAbsPosition().getX()<-36)
+ && m_myWorld.getMyself().getDistanceTo(getBallPosInRound(0)) <= ServerConf.CATCHABLE_AREA_L )
+ {
+ return 0;
+ }
+ else if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null
+ && (Math.abs(m_myWorld.getBall().getAbsPositionOfNextRound().getY())<20 && m_myWorld.getBall().getAbsPositionOfNextRound().getX()<-36)
+ && m_myWorld.getMyDistanceTo(m_myWorld.getBall().getAbsPositionOfNextRound()) <= ServerConf.CATCHABLE_AREA_L )
+ {
+ return 1;
+ }
+ return -1;
+ }
+
+
+
+
/**
* Return the best position for a goalkick if a goalkick is posible
***************
*** 687,699 ****
{
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;
--- 714,726 ----
{
l_enemyPlayer = (PlayerInfo)it.next();
! if ( l_middleOfGoal!=null && Math.abs(m_myWorld.getBodyDirectionTo(l_enemyPlayer) - m_myWorld.getBodyDirectionTo(l_middleOfGoal)) < FREE_ANGLE_FOR_GOAL_KICK)
{
l_middleOfGoal = null;
}
! if (l_shortCorner != null && Math.abs(m_myWorld.getBodyDirectionTo(l_enemyPlayer) - m_myWorld.getBodyDirectionTo(l_shortCorner)) < FREE_ANGLE_FOR_GOAL_KICK)
{
l_shortCorner = null;
}
! if (l_longCorner!=null && Math.abs(m_myWorld.getBodyDirectionTo(l_enemyPlayer) - m_myWorld.getBodyDirectionTo(l_longCorner)) < FREE_ANGLE_FOR_GOAL_KICK)
{
l_longCorner = null;
***************
*** 784,791 ****
}
*/
! /**
! * Returns true if I am the nearest to the ball in the next cycles
! * @return boolean
! */
private boolean nearestToTheBall()
{
--- 811,818 ----
}
*/
! /**
! * Returns true if I am the nearest to the ball in the next cycles
! * @return boolean
! */
private boolean nearestToTheBall()
{
***************
*** 872,876 ****
if (Math.abs(m_myWorld.getBodyDirectionTo(l_possiblePassPartner)-m_myWorld.getBodyDirectionTo(l_enemyPlayer)) > FREE_ANGLE
|| (Math.abs(m_myWorld.getBodyDirectionTo(l_possiblePassPartner)-m_myWorld.getBodyDirectionTo(l_enemyPlayer)) < FREE_ANGLE
! && m_myWorld.getMyDistanceTo(l_possiblePassPartner) +6 < m_myWorld.getMyDistanceTo(l_enemyPlayer)
)
)
--- 899,903 ----
if (Math.abs(m_myWorld.getBodyDirectionTo(l_possiblePassPartner)-m_myWorld.getBodyDirectionTo(l_enemyPlayer)) > FREE_ANGLE
|| (Math.abs(m_myWorld.getBodyDirectionTo(l_possiblePassPartner)-m_myWorld.getBodyDirectionTo(l_enemyPlayer)) < FREE_ANGLE
! && m_myWorld.getMyDistanceTo(l_possiblePassPartner) +2 < m_myWorld.getMyDistanceTo(l_enemyPlayer)
)
)
***************
*** 977,982 ****
else
{
! if ((m_myWorld.getMyself().getAbsPosition()).getX() < 0) //if i'm in the enemys half, don't go between ball and goal
goBetweenBallGoalAndWatchIt(f_player.getDistanceTo(MY_GOAL_POS) * 0.85);
}
}
--- 1004,1011 ----
else
{
! if ((m_myWorld.getMyself().getAbsPosition()).getX() > 0)
goBetweenBallGoalAndWatchIt(f_player.getDistanceTo(MY_GOAL_POS) * 0.85);
+ else
+ goBetweenBallAndEnemyAndWatchBall(f_player);
}
}
***************
*** 1030,1034 ****
private void passTo(PlayerInfo f_player, int f_cycle)
{
! double l_kickpower = Math.min(100, (m_myWorld.getMyDistanceTo(f_player) * 3.5));
m_actions.kickTo(l_kickpower, f_player, f_cycle);
}
--- 1059,1063 ----
private void passTo(PlayerInfo f_player, int f_cycle)
{
! double l_kickpower = Math.min(100, (m_myWorld.getMyDistanceTo(f_player) * 4.5));
m_actions.kickTo(l_kickpower, f_player, f_cycle);
}
***************
*** 1061,1066 ****
{
l_deltaBall = m_myWorld.getBall().getAbsPositionOfNextRound().sub(m_myWorld.getBall().getAbsPosition());
! l_finalPos = l_deltaBall.scaleWith(f_cycles); // Verlängern
! l_finalPos = l_finalPos.scaleWith(Math.pow(ServerConf.BALL_DECAY,f_cycles-1)); // Verlust
l_finalPos=m_myWorld.getBall().getAbsPosition().add(l_finalPos);
return l_finalPos;
--- 1090,1094 ----
{
l_deltaBall = m_myWorld.getBall().getAbsPositionOfNextRound().sub(m_myWorld.getBall().getAbsPosition());
! l_finalPos = l_deltaBall.scaleWith(f_cycles*Math.pow(ServerConf.BALL_DECAY,f_cycles-1)); // Verlängern
l_finalPos=m_myWorld.getBall().getAbsPosition().add(l_finalPos);
return l_finalPos;
***************
*** 1127,1144 ****
private void manageViewMode()
{
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;
}
}
--- 1155,1177 ----
private void manageViewMode()
{
+
if(!m_myWorld.getBall().isVisible())
{
m_myState.m_searchingBall=true;
! if (m_myWorld.sorry_whatTimeDoWeHave()-m_myWorld.getBall().getTime()> 6)
{
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;
! }
}
}
***************
*** 1146,1168 ****
{
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;
}
}
}
}
--- 1179,1257 ----
{
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())< 35 && 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;
! }
}
}
+ }
+
+ private void kickToCleverPosition(int f_cycles)
+ {
+ PlayerInfo l_enemyPlayer = null;
+ if(f_cycles==-1)
+ f_cycles=m_myWorld.getViewModeAsInt();
+ if (m_myWorld.getMyself().getAbsPosition().getX() > 10 || m_enemyTeam.isEmpty())
+ {
+ if (Math.abs(m_myWorld.getMyself().getAbsPosition().getY()) < 20)
+ m_actions.kickTo(MAXPOWER, ENEMY_GOAL_POS, f_cycles);
+ else
+ m_actions.kickTo(NORMPOWER+15, new Coordinate(45, 0), f_cycles);
+ return;
+ }
+ for (ListIterator it = m_enemyTeam.listIterator(); it.hasNext();)
+ {
+ l_enemyPlayer = (PlayerInfo)it.next();
+ if (m_myWorld.getMyDistanceTo(l_enemyPlayer) < MIN_DISTANCE_FOR_DRIBBEL)
+ {
+ if (l_enemyPlayer.getDirection() < 0)
+ {
+ if (m_myWorld.getMyself().getAbsPosition().getX() > -30)
+ m_actions.kickTo(MAXPOWER-20, new Coordinate(30, 15), f_cycles);
+ else
+ m_actions.kickTo(MAXPOWER-20, new Coordinate(0, 20), f_cycles);
+ }
+ else
+ {
+ if (m_myWorld.getMyself().getAbsPosition().getX() > -30)
+ m_actions.kickTo(MAXPOWER-20, new Coordinate(30, -15), f_cycles);
+ else
+ m_actions.kickTo(MAXPOWER-20, new Coordinate(0, -20), f_cycles);
+ }
+ return;
+ }
+ }
+ m_actions.kickTo(MAXPOWER, ENEMY_GOAL_POS, f_cycles);
+ }
+
+ private void goBetweenBallAndEnemyAndWatchBall(PlayerInfo f_player)
+ {
+ Coordinate l_playerPos=(m_myWorld.getBall().getAbsPositionOfNextRound() != null) ? m_myWorld.getBall().getAbsPositionOfNextRound() : m_myWorld.getBall().getAbsPosition();
+ Coordinate l_coord=l_playerPos.sub((f_player.getAbsPositionOfNextRound()!=null)?f_player.getAbsPositionOfNextRound():f_player.getAbsPosition());
+ //now we've the vector from the guy to the ball, so move onto that, half a meter away from the player
+ l_coord=l_playerPos.add(l_coord.normalize());
+ if (m_myWorld.getMyDistanceTo(l_coord)<2)
+ watchBall();
+ else
+ m_actions.runTo(NORMPOWER,l_coord,m_myWorld.getViewModeAsInt());
}
}
Index: ActionManager.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/player/ActionManager.java,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** ActionManager.java 14 Jul 2002 22:56:40 -0000 1.61
--- ActionManager.java 15 Jul 2002 09:27:23 -0000 1.62
***************
*** 19,23 ****
{
! static final double DRIBBELKICKPOWER = 0.4;
// Params for the RunTo-Method
--- 19,23 ----
{
! static final double DRIBBELKICKPOWER = 0.3;
// Params for the RunTo-Method
***************
*** 77,95 ****
case 0:
// 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));
break;
case 1:
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;
case 2:
nop();
nop();
! m_actionList.add(m_actionList.size(),new Action(KICK, f_power * DRIBBELKICKPOWER ,
m_myWorld.getBodyDirectionTo(f_position)));
break;
--- 77,95 ----
case 0:
// Ball ist nah genug zu kicken
! addLastToActionList(new Action(KICK, f_power * DRIBBELKICKPOWER ,
m_myWorld.getBodyDirectionTo(f_position)));
! addLastToActionList(new Action(TURN, m_myWorld.getBodyDirectionTo(f_position) , 0));
! addLastToActionList(new Action(DASH, f_power , 0));
break;
case 1:
nop();
! addLastToActionList(new Action(KICK, f_power * DRIBBELKICKPOWER ,
m_myWorld.getBodyDirectionTo(f_position)));
! addLastToActionList(new Action(TURN, m_myWorld.getBodyDirectionTo(f_position) , 0));
break;
case 2:
nop();
nop();
! addLastToActionList(new Action(KICK, f_power * DRIBBELKICKPOWER ,
m_myWorld.getBodyDirectionTo(f_position)));
break;
***************
*** 114,123 ****
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;
--- 114,117 ----
***************
*** 131,135 ****
case 0:
l_kickDir=m_myWorld.getBodyDirectionTo(f_position);
! m_actionList.add(m_actionList.size(),new Action(KICK, f_power, l_kickDir ));
break;
case 1:
--- 125,129 ----
case 0:
l_kickDir=m_myWorld.getBodyDirectionTo(f_position);
! addLastToActionList(new Action(KICK, f_power, l_kickDir ));
break;
case 1:
***************
*** 151,162 ****
l_kickDir=m_myWorld.getBodyDirectionTo(f_position)- l_turnedDirection ;
! 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 ));
break;
! /* case 2:
! System.out.println("wanted to kick in 2 cycle");
// 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().
--- 145,155 ----
l_kickDir=m_myWorld.getBodyDirectionTo(f_position)- l_turnedDirection ;
! addLastToActionList(new Action(DASH,l_dashPwr , 0));
! addLastToActionList(new Action(KICK, f_power, l_kickDir ));
break;
! case 2:
// 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().
***************
*** 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();
--- 157,170 ----
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();
***************
*** 183,197 ****
//l_dashPwr=Math.max(0,l_dashPwr);
l_dashPwr=Math.min(100,l_dashPwr);
! m_actionList.add(m_actionList.size(),new Action(TURN, l_moment, 0));
! 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 ));
!
! // logger.debug("Turn: " + l_moment + " DashPwr: " + l_dashPwr + " KickDir: " + l_kickDir );
! // logger.debug("distance: " + m_myWorld.getBall().getDistance()+ " dashpower: " + l_dashPwr);
! // logger.debug("speed: " + m_myWorld.getSenseBodyInfo().m_amountOfSpeed );
break;
default:
logger.debug("Hier hat jemand den falschen Cycle errechnet");
- */
}
}
--- 176,185 ----
//l_dashPwr=Math.max(0,l_dashPwr);
l_dashPwr=Math.min(100,l_dashPwr);
! addLastToActionList(new Action(TURN, l_moment, 0));
! addLastToActionList(new Action(DASH, l_dashPwr,0));
! addLastToActionList(new Action(KICK, f_power, l_kickDir ));
break;
default:
logger.debug("Hier hat jemand den falschen Cycle errechnet");
}
}
***************
*** 327,331 ****
if (Math.abs(l_angleToTurnNeck+m_myWorld.getNeckDirection())>90) //dont break ya neck
{
! changeView(++m_myState.m_currentViewWidth,true);
}
m_myCom.turnNeck(l_angleToTurnNeck);
--- 315,320 ----
if (Math.abs(l_angleToTurnNeck+m_myWorld.getNeckDirection())>90) //dont break ya neck
{
! changeView(m_myState.m_currentViewWidth+1,true);
! m_myState.m_currentViewWidth++;
}
m_myCom.turnNeck(l_angleToTurnNeck);
***************
*** 343,347 ****
if (Math.abs(l_actionAngle+m_myWorld.getNeckDirection())>90) //dont break ya neck
{
! changeView(++m_myState.m_currentViewWidth,true);
}
// m_myWorld.informTurnNeck(l_actionAngle);
--- 332,337 ----
if (Math.abs(l_actionAngle+m_myWorld.getNeckDirection())>90) //dont break ya neck
{
! changeView(m_myState.m_currentViewWidth+1,true);
! m_myState.m_currentViewWidth++;
}
// m_myWorld.informTurnNeck(l_actionAngle);
***************
*** 369,373 ****
public void run(int f_power)
{
! m_actionList.add(m_actionList.size(),new Action(DASH, f_power, 0));
}
--- 359,363 ----
public void run(int f_power)
{
! addLastToActionList(new Action(DASH, f_power, 0));
}
***************
*** 397,401 ****
if(Math.abs(l_deltaAngle)>TOLERANCEANGLE)
{
! m_actionList.add(m_actionList.size(),new Action(TURN,l_moment,0));
l_turnHappened=true;
}
--- 387,391 ----
if(Math.abs(l_deltaAngle)>TOLERANCEANGLE)
{
! addLastToActionList(new Action(TURN,l_moment,0));
l_turnHappened=true;
}
***************
*** 407,411 ****
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;
--- 397,401 ----
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));
! addLastToActionList(new Action(DASH,Math.min(100,l_power),0));
}
break;
***************
*** 415,419 ****
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
--- 405,409 ----
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));
! addLastToActionList(new Action(DASH,Math.min(100,l_power),0));
}
else
***************
*** 421,426 ****
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,416 ----
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));
! addLastToActionList(new Action(DASH,Math.min(100,l_power/2),0));
! addLastToActionList(new Action(DASH,Math.min(100,l_power/2),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;
--- 418,431 ----
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);
! addLastToActionList(new Action(DASH,Math.min(100,l_power),0));
! addLastToActionList(new Action(DASH,Math.min(100,l_power),0));
! addLastToActionList(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);
! addLastToActionList(new Action(DASH,Math.min(100,l_power),0));
! addLastToActionList(new Action(DASH,Math.min(100,l_power),0));
}
break;
***************
*** 463,467 ****
public void turn(double f_angle)
{
! m_actionList.add(m_actionList.size(),new Action(TURN, f_angle*moment(),0));
}
--- 455,459 ----
public void turn(double f_angle)
{
! addLastToActionList(new Action(TURN, f_angle*moment(),0));
}
***************
*** 477,493 ****
case 0:
l_deltaAngle= m_myWorld.getBodyDirectionTo(m_myWorld.getBall());
! m_actionList.add(m_actionList.size(),new Action(CATCHBALL, l_deltaAngle, 0));
break;
case 1:
! l_deltaAngle= m_myWorld.getBodyDirectionTo(m_myWorld.getBall().getAbsPositionOfNextRound());
! nop();
! m_actionList.add(m_actionList.size(),new Action(CATCHBALL, l_deltaAngle, 0));
! break;
! case 2:
! Coordinate l_coord = m_myWorld.getBall().getAbsPositionOfNextRound().sub(m_myWorld.getBall().getAbsPosition());
! l_deltaAngle= m_myWorld.getBodyDirectionTo(m_myWorld.getBall().getAbsPositionOfNextRound().add(l_coord.scaleWith(ServerConf.BALL_DECAY)));
! nop();
nop();
! m_actionList.add(m_actionList.size(),new Action(CATCHBALL, l_deltaAngle, 0));
break;
}
--- 469,478 ----
case 0:
l_deltaAngle= m_myWorld.getBodyDirectionTo(m_myWorld.getBall());
! addLastToActionList(new Action(CATCHBALL, l_deltaAngle, 0));
break;
case 1:
! l_deltaAngle= m_myWorld.getBodyDirectionTo( (m_myWorld.getBall().getAbsPositionOfNextRound()!=null)?m_myWorld.getBall().getAbsPositionOfNextRound():m_myWorld.getBall().getAbsPosition() );
nop();
! addLastToActionList(new Action(CATCHBALL, l_deltaAngle, 0));
break;
}
***************
*** 503,507 ****
public void moveTo(Coordinate f_coord)
{
! m_actionList.add(m_actionList.size(),new Action(MOVE, f_coord.getX(), f_coord.getY()));
}
--- 488,492 ----
public void moveTo(Coordinate f_coord)
{
! addLastToActionList(new Action(MOVE, f_coord.getX(), f_coord.getY()));
}
***************
*** 512,516 ****
public void nop()
{
! m_actionList.add(m_actionList.size(),new Action(NOP, 0,0));
}
--- 497,501 ----
public void nop()
{
! addLastToActionList(new Action(NOP, 0,0));
}
***************
*** 551,554 ****
--- 536,547 ----
}
+ private void addLastToActionList(Action f_action)
+ {
+ synchronized (m_actionList)
+ {
+ m_actionList.add(m_actionList.size(),f_action);
+ }
+ }
+
/**
*
***************
*** 674,678 ****
try
{
! sleep(90);
performAction();
// logger.fatal("action performed"+System.currentTimeMillis());
--- 667,674 ----
try
{
! synchronized(this)
! {
! wait(70);
! }
performAction();
// logger.fatal("action performed"+System.currentTimeMillis());
***************
*** 680,685 ****
catch (Exception ex)
{
! ex.printStackTrace();
! logger.fatal("running on....");
}
m_threadSuspended=true; //we want to suspend ourself after one run
--- 676,681 ----
catch (Exception ex)
{
! // ex.printStackTrace();
! // logger.fatal("running on....");
}
m_threadSuspended=true; //we want to suspend ourself after one run
|