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

  1. Object
  2. 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

bits int
the tick’s Input bits

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

tick int
a tick in [0, length())

Returns

the Input bits

toArray

public int[] toArray()
Expands the log into one value per tick.

Returns

a new array of length() values

encode

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

text String
an encoded log
maxTicks int
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