Changeset 1781

Show
Ignore:
Timestamp:
08/20/07 13:28:48 (3 years ago)
Author:
dugwyler
Message:

Re-enabled player position tracking by default due to the discovery of its very low overhead (setup.cfg can be used to turn on or off all tracking by default, and at what rate);
updated Player to reset bounty to 0 in appropriate places, and then wait until next position packet to confirm actual bounty, as well as JavaDoc updates;
updated Arena with more accurate information about the problem with playerIDs;
renamed PlayerDeath's getScore() method to more accurately reflect its actual purpose. (Another revision will follow to conform to this update.)

Location:
trunk/twcore/src/twcore/core
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/twcore/src/twcore/core/BotAction.java

    r1740 r1781  
    9191        m_positionTask = null; 
    9292        DefaultSpectateTime = getCoreData().getGeneralSettings().getInt( "DefaultSpectateTime" ); 
     93        setPlayerPositionUpdating(DefaultSpectateTime); 
    9394    } 
    9495 
     
    22592260    /** 
    22602261     * Turns automatic player position updating on and off.  By default it is ON, 
    2261      * and set to change between the players it spectates for packets every 5000ms. 
    2262      * The lower the number, the more reliable any position information stored in 
     2262     * and set to change between the players it spectates for packets at the rate 
     2263     * specified in setup.cfg under the DefaultSpectateTime field (in ms).  Clearly 
     2264     * the lower the number, the more reliable any position information stored in 
    22632265     * Player will be, and the more frequently and reliably will the bot receive 
    2264      * PlayerPosition events.  It is strongly advised that if you do not use 
    2265      * position packets that you set the time to 0 (completely off). 
     2266     * PlayerPosition events.  The network load is almost inconsequential, 
     2267     * particularly with DefaultSpectateTime at values >1000 -- it requires only 3 
     2268     * bytes sent each specified tick -- but it is recommended to turn this feature 
     2269     * off by using a 0 value if you will not need reliable information in Player 
     2270     * classes.  (Name, playerID, ship type, wins and losses do not rely on this.)   
    22662271     * <p>Note that because TWCore is a client emulator (does not operate on the 
    22672272     * server side but logs in as a bot) it only receives position packets from 
    22682273     * the server about players within radar range.  This is why it must switch 
    2269      * who is being spectated in order to get as many packets as possible.  This 
    2270      * process may be CPU-intensive when done rapidly. 
     2274     * who is being spectated in order to get as many packets as possible.  Fortunately 
     2275     * this process requires only minimal load. 
    22712276     * <p>If the arena the bot operates in is small, you may want to manually 
    2272      * adjust its position using the move() methods for efficiency. 
     2277     * adjust its position using the move() methods to most effectively receive packets. 
    22732278     * @param milliseconds - specified time to update player positions at 
    22742279     * 0     : turns tracking off and has the bot spectate its current area (change with move()) 
     
    23022307 
    23032308    /** 
    2304      * Starts the automatic player position updating system with the most reliable 
    2305      * positioning TWCore offers (switching between players every 200ms).  This 
    2306      * will cause the bot to switch which players it is spectating once every 5 
    2307      * seconds.  On slower systems and older network connections this may be 
    2308      * quite taxing. 
    2309      * <p>If you wish to switch faster than every 200ms, you must manually edit 
    2310      * Arena.java and hardcore a new value. 
     2309     * Starts the automatic player position updating system at the default 
     2310     * rate in setup.cfg.  The load on the network is a fairly trivial 3 bytes sent 
     2311     * at each change of player that the bot is spectating. 
     2312     * <p>Note that 200ms is the default floor value.  If you wish to switch faster 
     2313     * than every 200ms, you must edit the setPlayerPositionUpdating method manually. 
    23112314     */ 
    23122315    public void startReliablePositionUpdating() { 
     
    23182321     * stop spectating the player it is currently spectating on, and cease 
    23192322     * switching between players to update position packets.  Use this if your 
    2320      * bot will not be receiving position packets. 
     2323     * bot will not be receiving any position packets. 
    23212324     */ 
    23222325    public void stopReliablePositionUpdating() { 
  • trunk/twcore/src/twcore/core/events/PlayerDeath.java

    r1535 r1781  
    7373 
    7474    /** 
    75      * Gets the score resulting from the kill. NOTE: this currently 
    76      * just returns the bounty and not the entire score. 
    77      * @return the points gotten from the kill 
     75     * Gets the bounty of the player who was killed.  This is not the amount of bounty 
     76     * added to the player who made the kill, or the amount of points to add. 
     77     * @return Bounty of the player who was killed. 
    7878     */ 
    79     public short getScore(){ 
     79    public short getKilledPlayerBounty(){ 
    8080        return m_score; 
    8181    } 
  • trunk/twcore/src/twcore/core/game/Arena.java

    r1679 r1781  
    3636 * "Player ID" refers to the internal packet ID used by the SS protocol rather than 
    3737 * the player's UserID found in ?userid.  IDs are assigned sequentially arena-wide 
    38  * rather than zone-wide.  In almost all cases, an ID is sent as 2 bytes; however, 
    39  * short position packets, used to update frequent info on a player, send ID as 1 byte. 
    40  * This doesn't become a problem until we have >255 people in an arena, after which a 
    41  * client with a movement prediction algorithm has no real trouble distinguishing between 
    42  * two players with the same 1-byte ID, but a bot core does.  Fair warning!  -qan 
     38 * rather than zone-wide.  Large position packets send 2 bytes for ID, and small 
     39 * position packets send only 1; on the offchance that more than 256 players are in 
     40 * the arena at the same time, the server will begin sending only large position 
     41 * packets to alleviate potential problems with the same lower byte in two IDs.<br> 
     42 * However, if a player leaves the arena, their ID is freed up to be used by another 
     43 * player.  This can cause confusion in bots attempting to remember players primarily 
     44 * by their ID -- and for the reason that only 19 of a possible 23 characters of a 
     45 * player's name is accessible (aside from using *info) name is also not reliable. 
     46 * A combination of the two may be used, or just fairly meticulous planning.<br> 
     47 * A last word: using Arena's getPlayer(ID) method is more reliable than getPlayer(name), 
     48 * for the reasons described above.  If you need to get a Player object, try to do 
     49 * so by player ID rather than name.  For utmost security also compare the name in 
     50 * the Player object with the expected one.   
    4351 */ 
    4452public class Arena { 
     
    353361        return list.size(); 
    354362    } 
     363     
     364    // *** EVENT PROCESSING *** 
    355365 
    356366    /** 
     
    678688    } 
    679689 
     690    // *** PLAYER OBJECT UPDATING *** 
     691     
    680692    /** 
    681693     * Adds a playing player into the tracker queue to be spectated by the bot 
     
    735747    } 
    736748 
     749    /** 
     750     * Turns on or off the system of changing the bot's spectating target.  Each time a 
     751     * change is made in who is being spectated, 3 bytes are sent -- plan accordingly. 
     752     * @param enable 
     753     */ 
    737754    public void setEnableSpectating(boolean enable) { 
    738755        synchronized(m_tracker) { 
  • trunk/twcore/src/twcore/core/game/Player.java

    r1630 r1781  
    1818 * relevant or useful being stored here. 
    1919 * <p> 
    20  * A VERY IMPORTANT consideration is that a player's X & Y location, X & Y velocities & rotation 
    21  * amount may not be accurate / updated.  Use BotAction's setPlayerPositionUpdating() to make 
    22  * this information more reliable. 
     20 * A <b>VERY IMPORTANT<b> consideration is that a player's X & Y location, X & Y velocities, rotation 
     21 * amount, weapons and accessories data (XRadar, shields, etc) may not be accurate / updated. 
     22 * Use BotAction's setPlayerPositionUpdating() to make this information more reliable. 
     23 * <p> 
     24 * Also note that <b>using the player's name is not a reliable method of identification</b>. 
     25 * Only 19 of a possible 23 characters are stored; two players whose first 19 characters 
     26 * of the name are identical can not be separated by the bot except by their player ID. 
     27 * This brings the <i>additional<i> problem of player ID being represented in a single byte, 
     28 * or 256 possible values, with ID re-use being possible -- this means that ID is also not 
     29 * a reliable method of identification; it is useless if the player is not in the arena, and 
     30 * it is not static in any sense.     
    2331 */ 
    2432public class Player { 
     
    5260    private LinkedList<Integer> m_turrets;       // List of player IDs (Integer) that are attached 
    5361 
     62 
     63    // The following data is generally considered so unreliably tracked as to be almost meaningless -- 
     64    // even moreso than standard position data found in a short position packet.  It is supplied for the 
     65    // sake of completeness only, and it's not recommended anyone attempt to use it.  Coder beware. 
     66     
    5467    private boolean m_stealthOn;        // Status of Stealth 
    5568    private boolean m_cloakOn;          // Status of Cloaking 
     
    204217        if( message.getKillerID() == m_playerID ){ 
    205218            m_wins++; 
    206             m_score += message.getScore(); 
     219            // This particular operation (adding bounty of the killed to score) is questionable; 
     220            // we should be using settings to properly adjust the score.  We should also update 
     221            // bounty as appropriate. 
     222            // TODO: When arena settings storage class is implemented, use to properly update score & bounty. 
     223            m_score += message.getKilledPlayerBounty(); 
    207224        } else if( message.getKilleeID() == m_playerID ){ 
    208225            m_losses++; 
     226            m_bounty = 0;       // As a precaution; we will retrieve bounty at next position packet 
    209227        } 
    210228    } 
     
    260278 
    261279        m_frequency = message.getFrequency(); 
     280        m_bounty = 0;       // As a precaution; we will retrieve bounty at next position packet 
    262281    } 
    263282 
     
    270289        m_frequency = message.getFrequency(); 
    271290        m_shipType = message.getShipType(); 
     291        m_bounty = 0;       // As a precaution; we will retrieve bounty at next position packet 
    272292    } 
    273293 
     
    402422 
    403423    /** 
    404      * @return Name of the player 
     424     * Gets a String of the first 19 out of a possible 23 characters of this player's name. 
     425     * Note that <b>using the player's name is not a reliable method of identification</b>. 
     426     * Only 19 of a possible 23 characters are stored; two players whose first 19 characters 
     427     * of the name are identical can not be separated by the bot except by their player ID. 
     428     * @return First 19 out of 23 possible characters of the name of the player 
    405429     */ 
    406430    public String getPlayerName(){ 
     
    574598 
    575599    /** 
    576      * @return Player's last recorded amount of energy left 
     600     * @return Player's last recorded amount of energy left.  Not reliable 
    577601     */ 
    578602    public short getEnergy(){ 
     
    645669 
    646670    /** 
     671     * Returns the score as tracked by TWCore.  TWCore does <b>NOT</b> currently track 
     672     * score properly -- this is provided as a working approximation only.  
    647673     * @return Overall point score of the player 
    648674     */ 
     
    653679 
    654680    /** 
    655      * @return True if player has shields 
     681     * @return True if player has shields (UNRELIABLE; DO NOT USE) 
    656682     */ 
    657683    public boolean hasShields(){ 
     
    660686 
    661687    /** 
    662      * @return True if player has super 
     688     * @return True if player has super (UNRELIABLE; DO NOT USE) 
    663689     */ 
    664690    public boolean hasSuper(){ 
     
    667693 
    668694    /** 
    669      * @return Total number of bursts player currently possesses 
     695     * @return Total number of bursts player currently possesses (UNRELIABLE; DO NOT USE) 
    670696     */ 
    671697    public int getBurstCount(){ 
     
    674700 
    675701    /** 
    676      * @return Total number of bursts player currently possesses 
     702     * @return Total number of bursts player currently possesses (UNRELIABLE; DO NOT USE) 
    677703     */ 
    678704    public int getRepelCount(){ 
     
    681707 
    682708    /** 
    683      * @return Total number of bursts player currently possesses 
     709     * @return Total number of bursts player currently possesses (UNRELIABLE; DO NOT USE) 
    684710     */ 
    685711    public int getThorCount(){ 
     
    688714 
    689715    /** 
    690      * @return Total number of bricks player currently possesses 
     716     * @return Total number of bricks player currently possesses (UNRELIABLE; DO NOT USE) 
    691717     * @deprecated "Walls" is not a clear term.  Made this a wrapper for getBrickCount 
    692718     */ 
     
    697723 
    698724    /** 
    699      * @return Total number of bricks player currently posesses 
     725     * @return Total number of bricks player currently posesses (UNRELIABLE; DO NOT USE) 
    700726     */ 
    701727    public int getBrickCount(){ 
     
    704730 
    705731    /** 
    706      * @return Total number of decoys player currently possesses 
     732     * @return Total number of decoys player currently possesses (UNRELIABLE; DO NOT USE) 
    707733     */ 
    708734    public int getDecoyCount(){ 
     
    711737 
    712738    /** 
    713      * @return Total number of rockets player currently possesses 
     739     * @return Total number of rockets player currently possesses (UNRELIABLE; DO NOT USE) 
    714740     */ 
    715741    public int getRocketCount(){ 
     
    718744 
    719745    /** 
    720      * @return Total number of portals player currently possesses 
     746     * @return Total number of portals player currently possesses (UNRELIABLE; DO NOT USE) 
    721747     */ 
    722748    public int getPortalCount(){ 
     
    725751 
    726752    /** 
    727      * @return True if ship has Stealth on 
     753     * @return True if ship has Stealth on (UNRELIABLE; DO NOT USE) 
    728754     */ 
    729755    public boolean isStealthed(){ 
     
    732758 
    733759    /** 
    734      * @return True if ship has Cloaking on 
     760     * @return True if ship has Cloaking on (UNRELIABLE; DO NOT USE) 
    735761     */ 
    736762    public boolean isCloaked(){ 
     
    739765 
    740766    /** 
    741      * @return True if ship has X-Radar on 
     767     * @return True if ship has X-Radar on (UNRELIABLE; DO NOT USE) 
    742768     */ 
    743769    public boolean hasXRadarOn(){ 
     
    746772 
    747773    /** 
    748      * @return True if ship has Antiwarp on 
     774     * @return True if ship has Antiwarp on (UNRELIABLE; DO NOT USE) 
    749775     */ 
    750776    public boolean hasAntiwarpOn(){ 
     
    753779 
    754780    /** 
    755      * @return True if ship is warping in/cloaking/uncloaking (display flash on client) 
     781     * @return True if ship is warping in/cloaking/uncloaking (display flash on client) (UNRELIABLE; DO NOT USE) 
    756782     */ 
    757783    public boolean isWarpingIn(){ 
     
    760786 
    761787    /** 
    762      * @return True if ship is currently in safe 
     788     * @return True if ship is currently in safe (UNRELIABLE; DO NOT USE) 
    763789     */ 
    764790    public boolean isInSafe(){ 
     
    767793 
    768794    /** 
    769      * @return True if ship has UFO on 
     795     * @return True if ship has UFO on (UNRELIABLE; DO NOT USE) 
    770796     */ 
    771797    public boolean isUFO(){ 
     
    788814 
    789815        /** 
    790          * Gets a String representation (name) of this player 
     816         * Gets a String of the first 19 out of a possible 23 characters of this player's name. 
     817     * Note that <b>using the player's name is not a reliable method of identification</b>. 
     818     * Only 19 of a possible 23 characters are stored; two players whose first 19 characters 
     819     * of the name are identical can not be separated by the bot except by their player ID. 
    791820         * @return the player's name 
    792821         */