1#ifndef SCUBYWASM_ENGINE_H
2#define SCUBYWASM_ENGINE_H
84# define FREESTANDING 1
380[[nodiscard]] uint32_t
add_agent(
struct Context *ctx,
const struct Pose *pose);
429uint32_t
tick(
struct Context *ctx, uint32_t n_times);
491[[nodiscard]] int32_t
is_alive(
const struct Context *ctx, uint32_t agent_id);
509[[nodiscard]] int32_t
get_score(
const struct Context *ctx, uint32_t agent_id);
ActionFlags
Action bitmask.
Definition scubywasm_agent.h:153
struct Pose * get_pose_buffer(void)
Return a pointer to a module-owned Pose singleton buffer.
float ship_hit_radius
Ship hit radius (in torus-units).
Definition scubywasm_engine.h:197
int32_t get_score(const struct Context *ctx, uint32_t agent_id)
Get the current score of a ship.
float heading
Heading in degrees in [0, 360).
Definition scubywasm_engine.h:239
float x
x-position in [0, 1).
Definition scubywasm_engine.h:233
int32_t set_action(struct Context *ctx, uint32_t agent_id, enum ActionFlags flags)
Process an agent action for the next tick.
void free_context(struct Context *ctx)
Destroy a context created by create_context().
int32_t shot_lifetime
Shot lifetime / end-of-life (in ticks).
Definition scubywasm_engine.h:212
uint32_t tick(struct Context *ctx, uint32_t n_times)
Advance the simulation by one or more ticks.
struct Config * get_config_buffer(void)
Return a pointer to a module-owned Config singleton buffer.
void get_ship_pose(const struct Context *ctx, uint32_t agent_id, struct Pose *pose)
Get the current pose of a ship.
float shot_velocity
Shot velocity (in torus-units per tick).
Definition scubywasm_engine.h:205
uint32_t add_agent(struct Context *ctx, const struct Pose *pose)
Add a new ship/agent to the round.
float y
y-position in [0, 1).
Definition scubywasm_engine.h:236
int32_t get_shot_pose(const struct Context *ctx, uint32_t agent_id, struct Pose *pose)
Get the current pose of the active shot of a ship.
int32_t is_alive(const struct Context *ctx, uint32_t agent_id)
Check whether a ship is alive.
struct Context * create_context(const struct Config *cfg)
Create a new engine context (start a new round).
float ship_max_velocity
Ship speed when thrust is enabled (in torus-units per tick).
Definition scubywasm_engine.h:189
float ship_max_turn_rate
Ship turn rate per tick (in degrees per tick).
Definition scubywasm_engine.h:180
ActionFlags
Action bitmask.
Definition scubywasm_engine.h:109
@ ACTION_TURN_LEFT
Turn left for this tick.
Definition scubywasm_engine.h:130
@ ACTION_THRUST
Enable thrust for this tick.
Definition scubywasm_engine.h:121
@ ACTION_TURN_RIGHT
Turn right for this tick.
Definition scubywasm_engine.h:139
@ ACTION_NONE
Do nothing this tick.
Definition scubywasm_engine.h:111
@ ACTION_FIRE
Fire a shot.
Definition scubywasm_engine.h:148
void set_default_config(struct Config *cfg)
Initialize a Config to engine defaults.
Engine configuration.
Definition scubywasm_engine.h:173
Pose on the unit torus.
Definition scubywasm_engine.h:231