Some hints about what to pay attention to when making small robots would be appreciated. -- PEZ
Measure your bot's CodeSize with Christian Schnell's codesize tool http://user.cs.tu-berlin.de/~lulli/codesize/
Some general hints for making Micro and Mini bots.
- Keep it simple. You can design a big bot with multiple firing strategies and movements, but you can't with that small bots. Just pick a good movement and a good gun and stick to it.
- Consider always the cost/benefit of adding aditional code. Avoid low value checks or precise calculations that will consume lots of code (you can live with a 5% failures). Some examples for this are variables initialization, some walls checks, some angle calculations, etc.
- Don't get obsessed by size. First implement your bot, then reduce its code size. I easily reduce code size 40% to 50% after finishing the first implementation (altough it probably depends on how you code).
- Take advantage of the forums (specially RobocodeRepository). There are lots of posts about reducing codesize. Ask in the forums if you don't find the answer.
Some tricks to make your bot smaller.
- Avoid using "else" if possible.
if (condition) a = b; else a = c; <- Is bigger
a = c; if (condition) a = b; <- Is smaller
- Make variables static when possible. They take less space.
- Assign the variables inside the formula if possible.
a = b; c = 2 * a; <- Is bigger
c = 2 * (a=b); <- Is smaller
- Clean your code when you finish your bot (make sure there are not unused variables, etc.)
- Calling a method uses more space than using a variable. If you are going to use it many times, assign the result to a variable and use it instead of the method. Also, parameters consume lots of space. Try to reduce them (a good trick is to use global variables instead).
[Jax] might be able to reduce your size even more. I'm not into mini/micro/nano bots myself and didn't test it, but maybe some of you guys want to try it ... -- FnH
If you're coding i MiniBot then I think your best bet is to keep your code clear and understandable. It doesn't really cost that many bytes, but it can gain you bytes because you see better ways to do things. The same things might not be true for micros and certainly not nanos. But in a mini you can afford some overhead and you might have good use for it. It's not true that you can't fit multiple guns and/or movements in a mini. Look at VertiLeach which has two movements and a killer gun to go with them. -- PEZ
Not just minis, nanos have been made with multiple movements and micros with multiple guns. -- Kuuran
With the size that bots are getting (I mean thier getting HUGE), perhaps we should have a even bigger category for them, such that place a upper limit (myself I think about 4500 to 6000 codesize(but i'm not sure of the size of the largest bots)) on what a Megabot is and make a new category (gigabot, superbot, terabot, exabot). But then again these just might be the categories for historical reasons, i'm not sure (but its not like i'm proposing to change the existing ones). -- Chase-san
I agree with Kuuran. The nano version of Squirrel has 2 movements (one anti-HOT and one anti-LT/CT) and 2 guns (LT and Random). --Bayen