[Jais-checkins] jaisteam/src/jais/world WorldModel.java,1.59,1.60 WorldDataAccessInterface.java,1.11
Status: Beta
Brought to you by:
maestrodd
|
From: <mae...@us...> - 2002-07-15 09:27:26
|
Update of /cvsroot/jais/jaisteam/src/jais/world In directory usw-pr-cvs1:/tmp/cvs-serv15661/world Modified Files: WorldModel.java WorldDataAccessInterface.java Log Message: many many cahnges ;) version 1.01 is ready ! Index: WorldModel.java =================================================================== RCS file: /cvsroot/jais/jaisteam/src/jais/world/WorldModel.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** WorldModel.java 14 Jul 2002 22:56:40 -0000 1.59 --- WorldModel.java 15 Jul 2002 09:27:22 -0000 1.60 *************** *** 6,9 **** --- 6,11 ---- import jais.objects.*; import jais.communication.*; + import javax.sound.sampled.*; + import java.io.*; /** *************** *** 22,26 **** private int m_playerNumber; // where the playerNumber is stored ! private final int FORGET_TIME= 3*10; // x-seconds private final double NOT_MOVING=0.01; // if deltaVector is smaller than we say Object did not move --- 24,28 ---- private int m_playerNumber; // where the playerNumber is stored ! private final int FORGET_TIME= 2*10; // x-seconds private final double NOT_MOVING=0.01; // if deltaVector is smaller than we say Object did not move *************** *** 36,39 **** --- 38,42 ---- private LinkedList m_currentlyUsedFlags; private LinkedList m_currentlyUsedLines; + // private short[] m_scoring={0,0}; boolean m_playingOnLeftSide; // where we store on which side we play *************** *** 243,246 **** --- 246,260 ---- } + public int getViewModeAsInt() + { + String l_blub = getViewMode(); + if (l_blub.startsWith("normal")) + return 1; + else if (l_blub.startsWith("wide")) + return 2; + else + return 0; + } + /****************************************************************************************/ /* Here starts the implementation of the WorldUpdateInterface *************** *** 255,258 **** --- 269,282 ---- case AurealInfo.AUREAL_SENDER_REFEREE: m_lastRefereeMessage=l_aurealInfo; + if(m_lastRefereeMessage.m_playmode== AurealInfo.GOAL_L && m_playingOnLeftSide || m_lastRefereeMessage.m_playmode== AurealInfo.GOAL_R && !m_playingOnLeftSide) + { + // m_scoring[0]++; + if (m_playerNumber==1) + { + ClipPlayer l_blub=new ClipPlayer(new File("../ext/1.wav"),1); + } + } + else if (m_lastRefereeMessage.m_playmode== AurealInfo.GOAL_L || m_lastRefereeMessage.m_playmode== AurealInfo.GOAL_R) + // m_scoring[1]++; break; case AurealInfo.AUREAL_SENDER_OTHER: *************** *** 268,277 **** break; } ! logger.info("Player"+m_playerNumber+"added a hearEvent to my list"); } public synchronized void updateVisualInfo(VisualEvent f_visualEvent) { ! logger.info("updating my Visual Info and calculating absolute positions now"); ArrayList l_visualInfos=f_visualEvent.getObjects(); ObjectInfo l_objectInfo; --- 292,301 ---- break; } ! // logger.info("Player"+m_playerNumber+"added a hearEvent to my list"); } public synchronized void updateVisualInfo(VisualEvent f_visualEvent) { ! // logger.info("updating my Visual Info and calculating absolute positions now"); ArrayList l_visualInfos=f_visualEvent.getObjects(); ObjectInfo l_objectInfo; *************** *** 337,341 **** { m_senseBodyInfos.addLast(f_senseBodyEvent.getObjects().get(0)); ! logger.info("added a SenseBodyInfo to my List"); } --- 361,365 ---- { m_senseBodyInfos.addLast(f_senseBodyEvent.getObjects().get(0)); ! // logger.info("added a SenseBodyInfo to my List"); } *************** *** 346,350 **** if (!f_initialEvent.getObjects().isEmpty()) { ! logger.info("updating initial info's"); //get the one and only init info object InitInfo l_initInfo=(InitInfo)f_initialEvent.getObjects().get(0); --- 370,374 ---- if (!f_initialEvent.getObjects().isEmpty()) { ! // logger.info("updating initial info's"); //get the one and only init info object InitInfo l_initInfo=(InitInfo)f_initialEvent.getObjects().get(0); *************** *** 410,414 **** else if(l_tempAngle<-180) m_absBodyDir=360+f_angle; ! logger.debug("abs view angle from inform:"+ getAbsViewAngle()); logger.debug("abs bodyDir from inform:"+ getAbsBodyDir()); */ --- 434,438 ---- else if(l_tempAngle<-180) m_absBodyDir=360+f_angle; ! // logger.debug("abs view angle from inform:"+ getAbsViewAngle()); logger.debug("abs bodyDir from inform:"+ getAbsBodyDir()); */ *************** *** 434,438 **** l_2flagUpdateHappened=true; calculateMyAbsStuffWith2Flags(); ! logger.info("2Flags: Absolute Position : " + "(" + (int) m_myself.getAbsPosition().getX() + "|" +(int) m_myself.getAbsPosition().getY() + ")" + " Abs Angle: " + (int) getAbsViewAngle()); } if(!m_currentlySeenLines.isEmpty()) --- 458,462 ---- l_2flagUpdateHappened=true; calculateMyAbsStuffWith2Flags(); ! // logger.info("2Flags: Absolute Position : " + "(" + (int) m_myself.getAbsPosition().getX() + "|" +(int) m_myself.getAbsPosition().getY() + ")" + " Abs Angle: " + (int) getAbsViewAngle()); } if(!m_currentlySeenLines.isEmpty()) *************** *** 452,456 **** { calculateMyAbsStuffWithLineAndFlag(); ! logger.info("Line+Flag Absolute Position : " + "(" + (int) m_myself.getAbsPosition().getX() + "|" +(int) m_myself.getAbsPosition().getY() + ")" + " Abs Angle: " + (int) getAbsViewAngle()); } if (l_2flagUpdateHappened) --- 476,480 ---- { calculateMyAbsStuffWithLineAndFlag(); ! // logger.info("Line+Flag Absolute Position : " + "(" + (int) m_myself.getAbsPosition().getX() + "|" +(int) m_myself.getAbsPosition().getY() + ")" + " Abs Angle: " + (int) getAbsViewAngle()); } if (l_2flagUpdateHappened) *************** *** 459,468 **** m_absViewAngle=l_oldViewAngle; m_myself.setAbsPosition(l_oldPosition); ! logger.info("Corrected view Angle to " +l_oldViewAngle + "and Pos to" + l_oldPosition); } } else { ! logger.debug("Not enough information in the last see message for updating Position."); } /*set our body direction here and correct if necessary*/ --- 483,492 ---- m_absViewAngle=l_oldViewAngle; m_myself.setAbsPosition(l_oldPosition); ! // logger.info("Corrected view Angle to " +l_oldViewAngle + "and Pos to" + l_oldPosition); } } else { ! // logger.debug("Not enough information in the last see message for updating Position."); } /*set our body direction here and correct if necessary*/ *************** *** 650,699 **** private void updateAbsolutePositions() { ! logger.debug("Going to update my absolute positions"); ! /*************************************************************************************/ ! //update myself here calculateMyAbsStuff(); ! logger.info("Playing left? "+m_playingOnLeftSide); ! logger.info("Pos:" + m_myself.getAbsPosition() + "V Angle" + getAbsViewAngle() +"B Angle" + getAbsBodyDir()); ! /*************************************************************************************/ ! // update the ball here ! if (m_ball.isVisible()) ! { ! calculateAbsPosOfBall(); ! } ! else ! { ! logger.info("I dont see the ball :(("); ! } ! /*************************************************************************************/ ! // update the players here ! double l_absAngle; ! double l_dist; ! ObjectInfo l_tempObject; ! for (ListIterator it=m_currentlySeenPlayers.listIterator();it.hasNext();) { ! l_tempObject=(ObjectInfo)it.next(); //get the next player ! l_absAngle= Angle.toRadian(l_tempObject.getDirection()+getAbsViewAngle()); //get its direction and convert to Radian ! l_dist = l_tempObject.getDistance(); //get its distance ! l_tempObject.setAbsPosition(new Coordinate ( //and write its absPosition ! m_myself.getAbsPosition().getX()+Math.cos(l_absAngle)*l_dist, ! m_myself.getAbsPosition().getY()+Math.sin(l_absAngle)*l_dist ! )); ! if (l_tempObject.getDirChange()!=ObjectInfo.NOT_EXISTING && l_tempObject.getDistChange()!=ObjectInfo.NOT_EXISTING) ! { ! l_absAngle=Angle.toRadian(l_tempObject.getDirection()+l_tempObject.getDirChange() + getAbsViewAngle()); ! l_dist = l_tempObject.getDistance()+l_tempObject.getDistChange(); ! l_tempObject.setAbsPositionOfNextRound(new Coordinate( ! m_myself.getAbsPositionOfNextRound().getX()+Math.cos(l_absAngle)*l_dist, ! m_myself.getAbsPositionOfNextRound().getY()+Math.sin(l_absAngle)*l_dist) ! ); ! if (Math.abs(l_tempObject.getAbsPositionOfNextRound().getX()-l_tempObject.getAbsPosition().getX())<NOT_MOVING ! && Math.abs(l_tempObject.getAbsPositionOfNextRound().getY()-l_tempObject.getAbsPosition().getY())<NOT_MOVING) ! l_tempObject.setAbsPositionOfNextRound(null); ! } ! else ! l_tempObject.setAbsPositionOfNextRound(null); } ! l_tempObject=null; //dont need it anymore } --- 674,728 ---- private void updateAbsolutePositions() { ! // logger.debug("Going to update my absolute positions"); ! /*************************************************************************************/ ! //update myself here calculateMyAbsStuff(); ! // logger.info("Playing left? "+m_playingOnLeftSide); ! // logger.info("Pos:" + m_myself.getAbsPosition() + "V Angle" + getAbsViewAngle() +"B Angle" + getAbsBodyDir()); ! /*************************************************************************************/ ! // update the ball here ! if (m_ball.isVisible()) ! { ! calculateAbsPosOfBall(); ! } ! /*else if (sorry_whatTimeDoWeHave()-m_ball.getTime()< 7) { ! Coordinate l_nextRound =(m_ball.getAbsPositionOfNextRound()!=null)? m_ball.getAbsPositionOfNextRound() : m_ball.getAbsPosition(); ! Coordinate l_moving=l_nextRound.sub(m_ball.getAbsPosition()); ! m_ball.setAbsPosition(l_nextRound); ! m_ball.setAbsPositionOfNextRound(m_ball.getAbsPosition().add(l_moving.scaleWith(ServerConf.BALL_DECAY))); ! // logger.info("I dont see the ball :(("); } ! */ ! /*************************************************************************************/ ! // update the players here ! double l_absAngle; ! double l_dist; ! ObjectInfo l_tempObject; ! for (ListIterator it=m_currentlySeenPlayers.listIterator();it.hasNext();) ! { ! l_tempObject=(ObjectInfo)it.next(); //get the next player ! l_absAngle= Angle.toRadian(l_tempObject.getDirection()+getAbsViewAngle()); //get its direction and convert to Radian ! l_dist = l_tempObject.getDistance(); //get its distance ! l_tempObject.setAbsPosition(new Coordinate ( //and write its absPosition ! m_myself.getAbsPosition().getX()+Math.cos(l_absAngle)*l_dist, ! m_myself.getAbsPosition().getY()+Math.sin(l_absAngle)*l_dist ! )); ! if (l_tempObject.getDirChange()!=ObjectInfo.NOT_EXISTING && l_tempObject.getDistChange()!=ObjectInfo.NOT_EXISTING) ! { ! l_absAngle=Angle.toRadian(l_tempObject.getDirection()+l_tempObject.getDirChange() + getAbsViewAngle()); ! l_dist = l_tempObject.getDistance()+l_tempObject.getDistChange(); ! l_tempObject.setAbsPositionOfNextRound(new Coordinate( ! m_myself.getAbsPositionOfNextRound().getX()+Math.cos(l_absAngle)*l_dist, ! m_myself.getAbsPositionOfNextRound().getY()+Math.sin(l_absAngle)*l_dist) ! ); ! if (Math.abs(l_tempObject.getAbsPositionOfNextRound().getX()-l_tempObject.getAbsPosition().getX())<NOT_MOVING ! && Math.abs(l_tempObject.getAbsPositionOfNextRound().getY()-l_tempObject.getAbsPosition().getY())<NOT_MOVING) ! l_tempObject.setAbsPositionOfNextRound(null); ! } ! else ! l_tempObject.setAbsPositionOfNextRound(null); ! } ! l_tempObject=null; //dont need it anymore } *************** *** 726,731 **** else m_ball.setAbsPositionOfNextRound(null); ! logger.debug("Pos of ball"+m_ball.getAbsPosition()); ! logger.debug("Pos of ball next round:"+m_ball.getAbsPositionOfNextRound()); } --- 755,760 ---- else m_ball.setAbsPositionOfNextRound(null); ! // logger.debug("Pos of ball"+m_ball.getAbsPosition()); ! // logger.debug("Pos of ball next round:"+m_ball.getAbsPositionOfNextRound()); } *************** *** 847,851 **** m_enemyTeam.remove(l_oldPlayer); m_enemyTeam.add(l_newPlayer); ! logger.info("we found someone cause of its position"); } else //maybe he is in our team --- 876,880 ---- m_enemyTeam.remove(l_oldPlayer); m_enemyTeam.add(l_newPlayer); ! // logger.info("we found someone cause of its position"); } else //maybe he is in our team *************** *** 856,860 **** m_ownTeam.remove(l_oldPlayer); m_ownTeam.add(l_newPlayer); ! logger.info("we found someone cause of its position"); } } --- 885,889 ---- m_ownTeam.remove(l_oldPlayer); m_ownTeam.add(l_newPlayer); ! // logger.info("we found someone cause of its position"); } } *************** *** 922,926 **** }//playerIsInList() ! /** * Sets a whole ObjectInfo list to visible true or false * @param f_objectInfoList list to modify --- 951,955 ---- }//playerIsInList() ! /** * Sets a whole ObjectInfo list to visible true or false * @param f_objectInfoList list to modify *************** *** 940,943 **** --- 969,1031 ---- } return f_objectInfoList; + } + } + class blub implements LineListener + { + public void update (LineEvent f_event) + { + } + } + + class ClipPlayer implements LineListener + { + private Clip m_clip; + + + /* + *The clip will be played nLoopCount + 1 times. + */ + public ClipPlayer(File clipFile, int nLoopCount) + { + AudioInputStream audioInputStream = null; + try + { + audioInputStream = AudioSystem.getAudioInputStream(clipFile); + } + catch (Exception e) + { + //e.printStackTrace(); + } + if (audioInputStream != null) + { + AudioFormat format = audioInputStream.getFormat(); + DataLine.Info info = new DataLine.Info(Clip.class, format); + try + { + m_clip = (Clip) AudioSystem.getLine(info); + m_clip.addLineListener(this); + m_clip.open(audioInputStream); + } + catch (LineUnavailableException e) + { + //e.printStackTrace(); + } + catch (IOException e) + { + //e.printStackTrace(); + } + m_clip.loop(nLoopCount); + } + } + public void update(LineEvent event) + { + if (event.getType().equals(LineEvent.Type.STOP)) + { + m_clip.close(); + } + else if (event.getType().equals(LineEvent.Type.CLOSE)) + { + } + } } Index: WorldDataAccessInterface.java =================================================================== RCS file: /cvsroot/jais/jaisteam/src/jais/world/WorldDataAccessInterface.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** WorldDataAccessInterface.java 14 Jul 2002 22:56:40 -0000 1.11 --- WorldDataAccessInterface.java 15 Jul 2002 09:27:22 -0000 1.12 *************** *** 136,139 **** --- 136,142 ---- public String getViewMode(); + + public int getViewModeAsInt(); + /** * |