Talk:Code Size

From Robowiki
Revision as of 22:05, 13 March 2009 by Awesomeness (talk | contribs) (Help!)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Codesize for some reason doesn't work for me. Can someone make a GUI version of it? It isn't too hard with Swing. (I've made a compression program with an algorithm of my own invention with a Swing GUI.) Or could someone post a javascript that detects it after you paste code in? Thanks! --Awesomeness 21:05, 13 March 2009 (UTC)

You cannot post new threads to this discussion page because it has been protected from new threads, or you do not currently have permission to edit.

Contents

Thread titleRepliesLast modified
Writing nanobots using Java Assembly directly511:55, 19 May 2024

Writing nanobots using Java Assembly directly

It seems that openjdk has a wonderful tool called asmtools that allows two directional transformation between jasm and .class bytecode

https://wiki.openjdk.java.net/display/CodeTools/asmtools

Has anyone tried writing robocode bots with java assembly directly? Since the relationship between Java and Bytecode is not as direct as jasm and bytecode, writing with jasm directly may be a better way than tricks listed on this wiki.

Xor (talk)14:03, 6 May 2019

Rednaxela did mention on his user page:

Bots[edit]

Figments of my Imagination[edit]

Probably reality within the next year[edit]

  • Fleck - A NanoBot coded in java assembly to have more direct control of how the codesize is used. Might just be my own take on the 'NanoSurfer' concept too...

User:Rednaxela

It seems that he thought of the same idea in 2009, though he never got around to implementing it.

MultiplyByZer0 (talk)09:06, 7 May 2019
 

I believe many of the top nanobots use java assembly or Jikes to shrink their code. I haven't used it in my bots yet, but I plan to.

Slugzilla (talk)12:18, 8 May 2019
 

I've had some success using Proguard to shrink a few bytes off of microbots when they really need it - eg. Yatagan requires this. It usually does it by re-assigning variables into a slot that is no longer used - note that the actual java asm is not type-aware, so you can stick one type of object into the variable you previously used for a different type of variable. This means you can better re-use the initial few variables, which have lower codesize cost.

IMO you'll get better effective shrinking by exploring the library - for example, the pattern matcher nanos are all using string and substring indexOf functions, they would never have space to put all of the actual matching code in.

Skilgannon (talk)20:55, 9 May 2019

I think making use of library may be much useful than micro-optimizing bytecode size. Bytecode tools can be used for a few additional bytes though.

Xor (talk)04:54, 17 May 2019
 

As well as exploring the standard library it's also a good idea to carefully consider the robocode methods as well. For example, I was able to save a few bytes by switching from setTurnRightRadians to setTurnLeftRadians as it allowed me to save the result of getHeadingRadians in a register instead of calling it twice.

I didn't have any success with ProGuard when trying to shrink Quantum but switching to assembly with Krakatau has been quite fruitful. I've been able to save space by using dup to save variables on the stack instead of using local variables, which wouldn't have been possible in plain Java.

After my next update to Quantum I'll write a walkthrough from naive Java to optimised Java and finally down to bytecode. I'll be able to demonstrate most of the techniques listed in this page as well as a few new ideas like my gunheat lock for the radar.

Something I haven't explored yet is whether nested calls to event handlers can be exploited in some way. I don't think I could make use of it in Quantum but if/when I write a nano duelist it might come in handy.

David414 (talk)11:49, 19 May 2024