[Jais-checkins] jaisteam/src/jais/player KI.java,1.81,1.82
Status: Beta
Brought to you by:
maestrodd
|
From: <mae...@us...> - 2002-07-22 10:06:55
|
Update of /cvsroot/jais/jaisteam/src/jais/player
In directory usw-pr-cvs1:/tmp/cvs-serv26259/src/jais/player
Modified Files:
KI.java
Log Message:
removed the thread in the KI. it isnt needed, as it has to work only
after a see event
Index: KI.java
===================================================================
RCS file: /cvsroot/jais/jaisteam/src/jais/player/KI.java,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -d -r1.81 -r1.82
*** KI.java 15 Jul 2002 09:45:12 -0000 1.81
--- KI.java 22 Jul 2002 10:06:49 -0000 1.82
***************
*** 20,28 ****
! public class KI extends Thread implements Player
!
{
- Thread m_KIThread; // a reference to ourself
- boolean m_threadSuspended=false; //is our thread currently suspended
private static Logger logger=Logger.getLogger("jais.player");
--- 20,25 ----
! public class KI implements Player
{
private static Logger logger=Logger.getLogger("jais.player");
***************
*** 71,75 ****
public KI(WorldModel f_world, Communication f_myCom,int f_playerNumber)
{
- this.setName("KI"+f_playerNumber);
m_myWorld = f_world;
m_myState = new StateManager();
--- 68,71 ----
***************
*** 78,132 ****
/**
- * This method is started after a new visual info
- *
- * @roseuid 3CE80E3F03D8
- */
- public void run()
- {
- Thread l_thisThread = currentThread();
-
- while(l_thisThread==m_KIThread)
- {
- //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
- try
- {
- synchronized(this)
- {
- while (m_threadSuspended && l_thisThread==m_KIThread) //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
- }
- }
- }
- catch(java.lang.Exception ex)
- {
- //logger.info("\t" + getName() + ": ARGG! Got an exception while sleeping ... "+ ex.getMessage());
- }
- }//of while()
- //logger.info("\t" + getName() + ": i've left my while-loop. run() will stop immediatly
-
- }
-
-
- /**
* This "actionListener" waits for our sync-Event and passes it to the ActionManager
*/
--- 74,77 ----
***************
*** 1121,1126 ****
public void startKI()
{
- m_KIThread=this;
- m_KIThread.start();
m_actions.startActionPerformer();
}
--- 1066,1069 ----
***************
*** 1132,1138 ****
public synchronized void endTread()
{
- m_KIThread = null; //get a clean outcome
m_actions.stopActionPerformer();
- notify();
}
--- 1075,1079 ----
***************
*** 1143,1148 ****
public synchronized void onNewData()
{
! m_threadSuspended=false; // ok, he can run again if he wants to
! notify();
}
--- 1084,1092 ----
public synchronized void onNewData()
{
! m_actions.flush();
! m_actions.InformVisualUpdateHappened();
! m_enemyTeam=m_myWorld.getEnemyPlayers();
! m_ownTeam=m_myWorld.getFriendlyPlayers();
! root(); //Start our tree in the root
}
|