[Jais-checkins] jaisteam/src/jais/player StateManager.java,1.12,1.13 KI.java,1.76,1.77 ActionManager
Status: Beta
Brought to you by:
maestrodd
|
From: <mae...@us...> - 2002-07-13 20:29:27
|
Update of /cvsroot/jais/jaisteam/src/jais/player
In directory usw-pr-cvs1:/tmp/cvs-serv2840/player
Modified Files:
StateManager.java KI.java ActionManager.java
Log Message:
set storage time to 2 seconds
changeViewModes implemented (all modes supported now)
Index: StateManager.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/player/StateManager.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** StateManager.java 13 Jul 2002 16:21:51 -0000 1.12
--- StateManager.java 13 Jul 2002 20:29:24 -0000 1.13
***************
*** 19,22 ****
--- 19,24 ----
boolean m_athome=false;
int m_state= 1;
+ public static final int[] VIEW_ANGLES={45,90,180};
+ public int m_currentViewMode=1;
int m_actionCounter = 0;
***************
*** 66,71 ****
return m_athome;
}
-
-
-
}
--- 68,70 ----
Index: KI.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/player/KI.java,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -d -r1.76 -r1.77
*** KI.java 13 Jul 2002 16:21:51 -0000 1.76
--- KI.java 13 Jul 2002 20:29:24 -0000 1.77
***************
*** 41,47 ****
private final Coordinate GOALIE_HOME_POS = new Coordinate(-50, 0);
- private final double GOALIE_RANGE = 3;
- private final double MYMAXSPEED = 0.8;
private final double NORMPOWER = 50; //(ServerConf.MAXPOWER / 2);
private final double MINPOWER = 25; //(ServerConf.MAXPOWER / 4);
--- 41,45 ----
***************
*** 49,63 ****
private final int HOMERANGE_R = 5;
- private final int MAXRANGE_R = 25;
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 = 3;
private final int MAX_PASS_DISTANCE =30;
private final int MAX_LOOKING_FORWARD_TIME = 20;
! private final int FREE_ANGLE = 18;
! private final double MIN_SPACE_IN_GOAL = 3.0;
! private final double DISTANCE_TO_BALL = 0.5;
ArrayList m_enemyTeam;
ArrayList m_ownTeam;
--- 47,61 ----
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 = 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;
ArrayList m_ownTeam;
***************
*** 66,70 ****
StateManager m_myState;
-
/**
* Creates a new <code>KI</code> instance.
--- 64,67 ----
***************
*** 106,111 ****
{
logger.debug("Caught Execption from root in KI"+ex.getMessage());
! if(logger.getLevel().isGreaterOrEqual(Level.toPriority(Level.WARN_INT)))
! ex.printStackTrace();
logger.debug("Report this to jai...@li.... KI is still Working!");
}
--- 103,107 ----
{
logger.debug("Caught Execption from root in KI"+ex.getMessage());
! ex.printStackTrace();
logger.debug("Report this to jai...@li.... KI is still Working!");
}
***************
*** 146,149 ****
--- 142,146 ----
private void root()
{
+ manageViewMode();
switch(m_myWorld.getPlaymode())
{
***************
*** 293,297 ****
if(m_myWorld.getBall().getDistance() < ServerConf.KICKABLE_MARGIN )
{
! if(m_myWorld.getMyself().getAbsPosition().getX()<20)
l_tempPlayer =checkForPassPartner(20);
else if(m_myWorld.getMyself().getAbsPosition().getX()>40)
--- 290,294 ----
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)
***************
*** 470,476 ****
//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(SenseBodyInfo.getAngleFromViewMode(m_myWorld.getViewMode())-10);
else
! m_actions.turn(-SenseBodyInfo.getAngleFromViewMode(m_myWorld.getViewMode())+10);
}
--- 467,473 ----
//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);
}
***************
*** 574,580 ****
private void gotoHomePosition()
{
! ArrayList l_enemyTeam=(ArrayList)m_myWorld.getEnemyPlayers().clone();
! ArrayList l_ownTeam=(ArrayList)m_myWorld.getFriendlyPlayers().clone();
! double l_offsideBarrier=getOffsideBarrier(l_enemyTeam,l_ownTeam); //seems there are
if(m_myWorld.getMyself().getAbsPosition().getX()>l_offsideBarrier-3)
{
--- 571,575 ----
private void gotoHomePosition()
{
! double l_offsideBarrier=getOffsideBarrier(m_enemyTeam,m_ownTeam); //seems there are
if(m_myWorld.getMyself().getAbsPosition().getX()>l_offsideBarrier-3)
{
***************
*** 796,810 ****
{
//get a cleosan copy of our ownTeam
- ArrayList l_ownTeam=(ArrayList)m_myWorld.getFriendlyPlayers().clone();
- ArrayList l_enemyTeam=(ArrayList)(m_myWorld.getEnemyPlayers().clone());
//Search pass partners
! if (!l_ownTeam.isEmpty())
{
PlayerInfo l_passPartner=null; // the one we pass to
PlayerInfo l_possiblePassPartner; //this would be a possibility
PlayerInfo l_enemyPlayer; //used later
! double l_offsideBarrier=this.getOffsideBarrier(l_enemyTeam,l_ownTeam); //get the Offside Barrier
! for (ListIterator it = l_ownTeam.listIterator(); it.hasNext();)
{
l_possiblePassPartner = (PlayerInfo) it.next();
--- 791,803 ----
{
//get a cleosan copy of our ownTeam
//Search pass partners
! if (!m_ownTeam.isEmpty())
{
PlayerInfo l_passPartner=null; // the one we pass to
PlayerInfo l_possiblePassPartner; //this would be a possibility
PlayerInfo l_enemyPlayer; //used later
! double l_offsideBarrier=this.getOffsideBarrier(m_enemyTeam,m_ownTeam); //get the Offside Barrier
! for (ListIterator it = m_ownTeam.listIterator(); it.hasNext();)
{
l_possiblePassPartner = (PlayerInfo) it.next();
***************
*** 817,823 ****
)
{
! if (!l_enemyTeam.isEmpty())
{
! for(ListIterator enemyIterator = l_enemyTeam.listIterator();it.hasNext();)
{
l_enemyPlayer=(PlayerInfo)it.next();
--- 810,816 ----
)
{
! if (!m_enemyTeam.isEmpty())
{
! for(ListIterator enemyIterator = m_enemyTeam.listIterator();it.hasNext();)
{
l_enemyPlayer=(PlayerInfo)it.next();
***************
*** 976,980 ****
}
-
/**
* Kick to a given Coordinate in a given cycle
--- 969,972 ----
***************
*** 985,993 ****
{
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()));
m_actions.kickTo(l_kickpower, f_coord, f_cycle);
}
-
/**
* Passto to a given player in a given cycle
--- 977,985 ----
{
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);
}
/**
* Passto to a given player in a given cycle
***************
*** 1022,1026 ****
* @return int
*/
! private int ballAvailibleInNextRounds()
{
if (m_myWorld.getBall().isBallKickableBy(m_myWorld.getMyself()))
--- 1014,1018 ----
* @return int
*/
! private int ballAvailableInNextRounds()
{
if (m_myWorld.getBall().isBallKickableBy(m_myWorld.getMyself()))
***************
*** 1092,1097 ****
{
m_threadSuspended=false; // ok, he can run again if he wants to
! if (!m_threadSuspended) //check if we are suspended
! notify();
}
--- 1084,1088 ----
{
m_threadSuspended=false; // ok, he can run again if he wants to
! notify();
}
***************
*** 1128,1132 ****
return -1;
}
- }
--- 1119,1146 ----
return -1;
}
+ private void manageViewMode()
+ {
+ if(!m_myWorld.getBall().isVisible())
+ {
+ m_actions.changeView(SenseBodyInfo.WIDE,true);
+ m_myState.m_currentViewMode=SenseBodyInfo.WIDE;
+ }
+ else if (m_myWorld.getMyDistanceTo(m_myWorld.getBall())< 5)
+ {
+ m_actions.changeView(SenseBodyInfo.NARROW,true);
+ m_myState.m_currentViewMode=SenseBodyInfo.NARROW;
+ }
+ else if (m_myWorld.getMyDistanceTo(m_myWorld.getBall())< 20)
+ {
+ m_actions.changeView(SenseBodyInfo.NORMAL,true);
+ m_myState.m_currentViewMode=SenseBodyInfo.NORMAL;
+ }
+ else
+ {
+ m_actions.changeView(SenseBodyInfo.WIDE,true);
+ m_myState.m_currentViewMode=SenseBodyInfo.WIDE;
+ }
+ }
+ }
Index: ActionManager.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/player/ActionManager.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** ActionManager.java 13 Jul 2002 16:21:51 -0000 1.58
--- ActionManager.java 13 Jul 2002 20:29:24 -0000 1.59
***************
*** 47,52 ****
private int m_neckTurnDirection=1;
private boolean m_visualUpdateHappened=false;
- private boolean m_changeViewSend=false;
-
private static Logger logger=Logger.getLogger("jais.player");
--- 47,50 ----
***************
*** 127,135 ****
l_kickDir=m_myWorld.getBodyDirectionTo(f_position);
m_actionList.addLast(new Action(KICK, f_power, l_kickDir ));
! nop();
! nop();
break;
case 1:
// Is Ball moving?
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null)
{
--- 125,134 ----
l_kickDir=m_myWorld.getBodyDirectionTo(f_position);
m_actionList.addLast(new Action(KICK, f_power, l_kickDir ));
! // nop();
! // nop();
break;
case 1:
// Is Ball moving?
+ System.out.println("wanted to kick in 1 cycle");
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null)
{
***************
*** 152,158 ****
m_actionList.addLast(new Action(DASH,l_dashPwr , 0));
m_actionList.addLast(new Action(KICK, f_power, l_kickDir ));
! nop();
break;
case 2:
// Is Ball moving?
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null) {
--- 151,158 ----
m_actionList.addLast(new Action(DASH,l_dashPwr , 0));
m_actionList.addLast(new Action(KICK, f_power, l_kickDir ));
! // nop();
break;
case 2:
+ System.out.println("wanted to kick in 2 cycle");
// Is Ball moving?
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null) {
***************
*** 218,226 ****
l_kickDir=m_myWorld.getBodyDirectionTo(f_Object );
m_actionList.addLast(new Action(KICK, f_power, l_kickDir ));
! nop();
! nop();
break;
case 1:
// Is Ball moving?
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null)
{
--- 218,227 ----
l_kickDir=m_myWorld.getBodyDirectionTo(f_Object );
m_actionList.addLast(new Action(KICK, f_power, l_kickDir ));
! // nop();
! // nop();
break;
case 1:
// Is Ball moving?
+ System.out.println("wanted to kick in 1 cycle");
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null)
{
***************
*** 242,249 ****
m_actionList.addLast(new Action(DASH,l_dashPwr , 0));
m_actionList.addLast(new Action(KICK, f_power, l_kickDir ));
! nop();
break;
case 2:
// Is Ball moving?
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null) {
// Position of the ball when finally kicking
--- 243,251 ----
m_actionList.addLast(new Action(DASH,l_dashPwr , 0));
m_actionList.addLast(new Action(KICK, f_power, l_kickDir ));
! // nop();
break;
case 2:
// Is Ball moving?
+ System.out.println("wanted to kick in 2 cycle");
if (m_myWorld.getBall().getAbsPositionOfNextRound()!=null) {
// Position of the ball when finally kicking
***************
*** 293,307 ****
public void performAction()
{
- if(!m_changeViewSend)
- {
- try
- {
- m_myCom.changeView("wide",true);
- }
- catch (xCommunication xCom)
- {
- logger.debug("caught exception from commu while sending changeView"+xCom.getMessage());
- }
- }
if (!m_actionList.isEmpty())
{
--- 295,298 ----
***************
*** 451,456 ****
{
m_actionList.addLast(new Action(DASH, f_power, 0));
! nop();
! nop();
}
--- 442,447 ----
{
m_actionList.addLast(new Action(DASH, f_power, 0));
! // nop();
! // nop();
}
***************
*** 579,585 ****
public void turn(double f_angle)
{
! m_actionList.addLast(new Action(TURN, f_angle, -100));
! nop();
! nop();
//m_myState.IncActionCounter();
}
--- 570,576 ----
public void turn(double f_angle)
{
! m_actionList.addLast(new Action(TURN, f_angle*moment(), -100));
! // nop();
! // nop();
//m_myState.IncActionCounter();
}
***************
*** 597,602 ****
l_deltaAngle= m_myWorld.getBodyDirectionTo(m_myWorld.getBall());
m_actionList.addLast(new Action(CATCHBALL, l_deltaAngle, 0));
! nop();
! nop();
break;
case 1:
--- 588,593 ----
l_deltaAngle= m_myWorld.getBodyDirectionTo(m_myWorld.getBall());
m_actionList.addLast(new Action(CATCHBALL, l_deltaAngle, 0));
! // nop();
! // nop();
break;
case 1:
***************
*** 604,608 ****
nop();
m_actionList.addLast(new Action(CATCHBALL, l_deltaAngle, 0));
! nop();
break;
case 2:
--- 595,599 ----
nop();
m_actionList.addLast(new Action(CATCHBALL, l_deltaAngle, 0));
! // nop();
break;
case 2:
***************
*** 627,632 ****
{
m_actionList.addLast(new Action(MOVE, f_coord.getX(), f_coord.getY()));
! nop();
! nop();
//m_myState.IncActionCounter();
}
--- 618,623 ----
{
m_actionList.addLast(new Action(MOVE, f_coord.getX(), f_coord.getY()));
! // nop();
! // nop();
//m_myState.IncActionCounter();
}
***************
*** 772,775 ****
{m_visualUpdateHappened=true;}
!
}
--- 763,783 ----
{m_visualUpdateHappened=true;}
! public void changeView(int f_viewMode,boolean f_highViewQuality)
! {
! String l_viewModeString;
! if (f_viewMode==SenseBodyInfo.NARROW)
! l_viewModeString="narrow";
! else if(f_viewMode==SenseBodyInfo.WIDE)
! l_viewModeString="wide";
! else
! l_viewModeString="normal";
! try
! {
! m_myCom.changeView(l_viewModeString,f_highViewQuality);
! }
! catch (xCommunication ex)
! {
! logger.warn("changeViewQuality could not be send to server");
! }
! }
}
|