Talk:Kitten

From Robowiki
Revision as of 13:46, 18 June 2009 by Rednaxela (talk | contribs) (StringBuffer speed)
Jump to navigation Jump to search

Thanks you :) --Miked0801 01:01, 18 June 2009 (UTC)

no problem at all. Spinnercat 01:09, 18 June 2009 (UTC)

Ah, I'm enlightened. :) First codesize-reducing tip: (I haven't looked at the code yet) Use WeekendObsession's gun instead of Assertive's which is Funkychicken's which is... etc. :D I suggest looking at BlackWidow 1.3's code. It's very tidy and well-commented and it has WeekendObsession's gun. You will gain some bytes and the execution of your bot will be a lot faster. :) StringBuffers are very slow, at least use StringBuilder. --HUNRobar 08:28, 18 June 2009 (UTC)

Actually, for repeated appending, StingBuffer is FAR faster than a normal String once the string gets large. This is because a normal String will have to re-allocate a bigger chunk of memory, and re-copy EVERYTHING every time the string goes past container size. The reason that the FunkyChicken gun is slow, is because of enemyLog.toString().indexOf(), because that forces it to re-copy the string every tick no matter what, which is worse than the occasional re-copy that String appending forces. Funny thing is, StringBuffer has it's own indexOf() method, so really, that line in the various FunkyChicken guns should really be enemyLog.indexOf(), which is both slightly lower codesize AND will make the gun have less spikes in time used than WeekendObsession, due to any and all re-copies being totally eliminated. --Rednaxela 12:46, 18 June 2009 (UTC)