I have implemented an interpreter for a custom "bytecode". The interpreter is just over 700 bytes of bytecode so it fits in a microbot. I think java put a limit of 64Kb on strings so thats the limit of how advanced the bot can be. Well, the interpreted language puts a lot of constraints on what can be done.
The custom bytecode looks a bit like [funge]. It is hard to write, harder to read and probably impossible to debug, so don't expect any killer bot comming out of this. =)
Size optimizations for the interpreter are very welcome.
Have anybody tried something like this before? -- Strider
The code is here now! -- Strider
Actually, I'm looking at a similar, smaller system for my next bot. What I was making, though, was a command queue, which would include commands like ahead(x), fire(y), turnRight(z). The idea was to set up an exact future for my bot. --Goofy
I just had the same idea and implemented an interpreter robot which fits into a MicroBot and can do theoretical everything a MegaBot can. I saw how you access the setters and getters - very flexible and small. We should take a look at the java API, perhaps java byte code can be executed from an byte array ( converted from String at runtime ) without SecurityException? If not, perhaps classes can be instantiated from a string ( especially Math and Streams ) --Sin Varg
My first thought would be the reflection API... --Alphax
You need a class loader to load from a byte array, and the security manager won't let you make your own class loader. So you have to interpret your byte or string manually. --David Alves
I have implemented a nano interpreter which runs a bit slowly and "requires" a compiler. The source is available here: Interpreter/NanoInterpreter. Comments? -- Kinsen
Uh oh. -- Simonton
You should get rid of the quotation marks. -- Zian
Has anyone tried writing a compiler to generate the shrunken bytecode String (besides Kinsen and I)? -- Zian
Not in my time here. -- Simonton