Byte Battle

From SizeCoding
Revision as of 14:57, 17 February 2022 by Pestis (talk | contribs) (Added an article specifically for bytebattle tricks)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Bytebattles

Bytebattles are a form of live coding, similar to Shader Showdowns, where two contestants compete in writing a visual effect in 25 minutes. The coding environment is the TIC-80 fantasy console. However, unlike Shader Showdowns, there is an additional limit: the final code should be less than 256 characters. This requires the contestants to use efficient code (e.g. single letter variables) and to minimize the code (e.g. remove the whitespace), all within the time limit. Unlike normal TIC-80 coding, there is no compression, so every character counts.

Basic optimizations

- Functions, that are called 3 or more times should be aliased. For example, e=elli with e()e()e() is 3 bytes shorter than elli()elli()elli(). Functions with 5 characters may already benefit from aliasing with 2 calls: r=rectb with r()r() is 1 character shorter than rectb()rectb().

- t=0 with t=t+.1 is 3 bytes shorter than t=time()/399.

- for i=0,32639 do x=i%240y=i/240 end is 2-3 bytes shorter than for y=0,135 do for x=0,239 do end end.

- (x*x+y*y)^.5 is 6 bytes shorter than math.sqrt(x*x+y*y).

- s(w-11) and s(w+8) both approximate math.cos(w), so only math.sin needs to be aliased. s(w-11) is slightly more accurate, with the cost of one more character.

Additional Resources