¬ÈçÒÔÖÐÐÄΪµã»®·ÖÏóÏÞÔòµÃµ½ÏÂÃæµÄ½á¹û
            return Math.asin( xo / h );
        }
        if( xo > 0 && yo < 0 )
        {
            return Math.PI - Math.asin( xo / h ); //xΪÕý,yΪ¸ºµÚ¶þÏóÏÞ½Ç
        }
        if( xo < 0 && yo < 0 )
        {
            return Math.PI + Math.asin( -xo / h ); //µÚÈýÏóÏÞÄÚ180+½Ç¶È
        }
        if( xo < 0 && yo > 0 )
        {
            return 2.0*Math.PI - Math.asin( -xo / h ); //ËÄÏóÏÞ360-½Ç¶È
        }
        return 0;
    }
    /**
    * onScannedRobot: What to do when you see another robot
     * ɨÃèʼþ,Ò²Êdzõʼ»¯Ä¿±êÊý¾ÝµÄ¹ý³Ì
    */
    public void onScannedRobot(ScannedRobotEvent e)
    {
        //if we have found a closer robot....
        if ((e.getDistance() < target.distance)||(target.name == e.getName()))
        {
            //the next line gets the absolute bearing to the point where the bot is
            //ÇóµÃ¶ÔÊֵľø¶Ô»¡¶È
            double absbearing_rad = (getHeadingRadians()+e.getBearingRadians())%(2*PI);
            //this section sets all the information about our target
            target.name = e.getName();
            //ÇóµÃ¶ÔÊÖµÄx,y×ø±ê£¬¼û"robocode»ù±¾Ô­ÀíÖ®×ø±êËø¶¨"ÎÄÕÂ
            target.x = getX()+Math.sin(absbearing_rad)*e.getDistance(); //works out the x coordinate of where the target is
            target.y = getY()+Math.cos(absbearing_rad)*e.getDistance(); //works out the y coordinate of where the target is
            target.bearing = e.getBearingRadians();
            target.head = e.getHeadingRadians();
            target.ctime = getTime();               //game time at which this scan was produced ɨÃèµ½»úÆ÷È˵ÄÓÎϷʱ¼ä
            target.speed = e.getVelocity();         //µÃµ½µÐÈËËÙ¶È
            target.distance = e.getDistance();
        }
    }
    public void onRobotDeath(RobotDeathEvent e)
    {
        if (e.getName() == target.name)
        target.distance = 10000; //this will effectively make it search for a new target
    }  
 
}
 
 
/*
* This class holds scan data so that we can remember where enemies were
* and what they were doing when we last scanned then.
* You could make a hashtable (with the name of the enemy bot as key)
* or a vector of these so that you can remember where all of your enemies are
* in relation to you.
* This class also holds the guessX and guessY methods. These return where our targeting
* system thinks they will be if they travel in a straight line at the same speed
* as they are travelling now.  You just need to pass the time at which you want to know
* where they will be.
* ±£´æÎÒÃÇɨÃèµ½µÄÄ¿±êµÄËùÓÐÓÐÓÃÊý¾Ý£¬Ò²¿ÉÓÃhashtable£¬vector·½·¨´¦ÀíËùÓкÍÎÒÃÇÓйصÄÄ¿±êÊý¾Ý(ÓÃÓÚȺս)
* ÖмäµÄguessX,guessY·½·¨ÊÇÕë¶Ô×öÖ±Ïß¾ùËÙÔ˶¯»úÆ÷ÈËÒ»¸ö²ßÂÔ
*/
class Enemy
{
    /*
     * ok, we should really be using accessors and mutators here,
     * (i.e getName() and setName()) but life's too short.
     */
    String name;
    public double bearing;
    public double head;
    public long ctime; //game time that the scan was produced
    public double speed;
    public double x,y;
    public double distance;
    public double guessX(long when)
    {
        //ÒÔɨÃèʱºÍ×Óµ¯µ½´ïµÄʱ¼ä²î £ª ×î´óËÙ¶È=¾àÀë, ÔÙÓöÔÊÖµÄ×ø±ê¼ÓÉÏÒÆ¶¯×ø±êµÃµ½µÐÈËÒÆ¶¯ºóµÄ×ø±ê
        long diff = when - ctime;
        return x+Math.sin(head)*speed*diff; //Ä¿±êÒÆ¶¯ºóµÄ×ø±ê
    }
    public double guessY(long when)
    {
        long diff = when - ctime;
        return y+Math.cos(head)*speed*diff;
    }
}