Actions and input files¶
An input is an Action: a race tick, a kind and a value. The keyword arguments of Gym.step() cover a plain
control loop; explicit actions are for inputs at chosen ticks inside a step’s window, and they are what a recorded race
is made of.
from tickgym import Action, InputText
# Two inputs at chosen ticks inside a 10-tick step.
t = gym.step(10, [Action.steer(gym.next_tick, -40), Action.brake(gym.next_tick + 5)])
# The whole race so far, saved as TICK input text.
InputText.write("records/best.txt", gym.export().actions)
- class Action(tick: int, kind: InputActionKind, value: int = 0)¶
One input event at a race tick. A value holds until the next event of the same kind, as in the game. Build them with the factories below.
- kind: InputActionKind¶
What the input is.
- value: int¶
The input’s value. A steer runs from -127 to 127, a pressed control is 1 or 0, a seed or flags word is as is.
- static accelerate(tick: int, on: bool = True) Action¶
The accelerator pressed (or released) at
tick.
- class InputActionKind(value)¶
- ACCELERATE = 1¶
- BRAKE = 2¶
- STEER = 3¶
- SEED = 4¶
- RESPAWN = 5¶
- FLAGS = 6¶
- STANDING_RESPAWN = 7¶
- GAME_SPEED = 8¶
Input text¶
- class InputText¶
TICK’s input text, the format its editor loads and saves, to and from
Actionvalues.One input per line,
<time> <action> [<value>]; blank lines and#comments are skipped. A time is milliseconds (1500), a clock (1:02.50) or seconds (1.5), and aligns to 10 ms ticks. The actions areaccel,brake,steer,respawn,srespawn,seed,flagsandspeed:0 seed 1 0 accel 1 1500 steer -40 2:10.50 brake 1
- static parse(text: str) tuple[Action, ...]¶
The actions in a text, in line order.
- Raises:
InputTextError – A line is not input text.
- static format(items: Sequence[Action]) str¶
The text of these actions: one line each, milliseconds first.