Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public final class InputLog
- Object
- InputLog
A recorded run: one Input value per tick, run-length encoded.
A player rarely changes buttons, so a minute of play (3600 ticks) is typically a
few hundred bytes of text. The text form, bits*count pairs in hexadecimal
separated by commas ("2*3c,12*8,2*40"), is what the app uploads and the server
replays with Replay.
Constructors
public InputLog() |
Methods
public void add(int bits) | Appends one tick. |
public int length() | The number of ticks recorded. |
public int get(int tick) | The input at a tick. |
public int[] toArray() | Expands the log into one value per tick. |
public String encode() | The compact text form. |
public static InputLog decode(String text, int maxTicks) | Reads the text form. |
Inherited methods
Constructor details
InputLog
public InputLog()Method details
add
public void add(int bits)Appends one tick.
Parameters
bitsint- the tick’s
Inputbits
length
public int length()The number of ticks recorded.
Returns
the tick count
get
public int get(int tick)The input at a tick.
Parameters
tickint- a tick in
[0, length())
Returns
the
Input bitstoArray
public int[] toArray()Expands the log into one value per tick.
Returns
a new array of
length() valuesencode
public String encode()The compact text form.
Returns
the encoded log
decode
public static InputLog decode(String text, int maxTicks)Reads the text form.
Parameters
textString- an encoded log
maxTicksint- the longest log accepted, so a hostile upload cannot claim billions of ticks
Returns
the log
Throws
IllegalArgumentException- on malformed text or a log over
maxTicks