Scubywasm API
C ABI for WebAssembly agents and engine
Loading...
Searching...
No Matches
scubywasm_agent.h
Go to the documentation of this file.
1#ifndef SCUBYWASM_AGENT_H
2#define SCUBYWASM_AGENT_H
3
131#include <stdint.h>
132
133#ifdef __cplusplus
134extern "C"
135{
136#endif
137
152enum ActionFlags : unsigned int
153{
156
166
175
184
193};
194
248
260struct Context;
261
271struct Context *
272init_agent(uint32_t n_agents, uint32_t agent_multiplicity, uint32_t seed);
273
282void free_context(struct Context *ctx);
283
294void set_config_parameter(struct Context *ctx,
295 enum ConfigParameter param,
296 float value);
297
305void clear_world_state(struct Context *ctx);
306
319void update_ship(struct Context *ctx,
320 uint32_t agent_id,
321 int32_t hp,
322 float x,
323 float y,
324 float heading);
325
342void update_shot(struct Context *ctx,
343 uint32_t agent_id,
344 int32_t lifetime,
345 float x,
346 float y,
347 float heading);
348
358void update_score(struct Context *ctx, uint32_t agent_id, int32_t score);
359
371uint32_t make_action(struct Context *ctx, uint32_t agent_id, uint32_t tick);
372
373#ifdef __cplusplus
374}
375#endif
376#endif // SCUBYWASM_AGENT_H
void free_context(struct Context *ctx)
Destroy an agent context created by init_agent().
void update_score(struct Context *ctx, uint32_t agent_id, int32_t score)
Provide the current score for one agent.
void update_shot(struct Context *ctx, uint32_t agent_id, int32_t lifetime, float x, float y, float heading)
Provide the current state of a shot.
struct Context * init_agent(uint32_t n_agents, uint32_t agent_multiplicity, uint32_t seed)
Create a new per-round agent context.
ConfigParameter
Engine configuration parameters.
Definition scubywasm_agent.h:208
@ CFG_SHIP_HIT_RADIUS
Ship hit radius (in torus-units).
Definition scubywasm_agent.h:231
@ CFG_SHOT_LIFETIME
Shot lifetime / end-of-life (in ticks).
Definition scubywasm_agent.h:246
@ CFG_SHOT_VELOCITY
Shot velocity (in torus-units per tick).
Definition scubywasm_agent.h:239
@ CFG_SHIP_MAX_TURN_RATE
Ship turn rate per tick (in degrees per tick).
Definition scubywasm_agent.h:215
@ CFG_SHIP_MAX_VELOCITY
Ship speed when thrust is enabled (in torus-units per tick).
Definition scubywasm_agent.h:223
ActionFlags
Action bitmask.
Definition scubywasm_agent.h:153
@ ACTION_TURN_LEFT
Turn left for this tick.
Definition scubywasm_agent.h:174
@ ACTION_THRUST
Enable thrust for this tick.
Definition scubywasm_agent.h:165
@ ACTION_TURN_RIGHT
Turn right for this tick.
Definition scubywasm_agent.h:183
@ ACTION_NONE
Do nothing this tick.
Definition scubywasm_agent.h:155
@ ACTION_FIRE
Fire a shot.
Definition scubywasm_agent.h:192
void update_ship(struct Context *ctx, uint32_t agent_id, int32_t hp, float x, float y, float heading)
Provide the current state of a ship.
uint32_t make_action(struct Context *ctx, uint32_t agent_id, uint32_t tick)
Compute the action for one controlled team member.
void clear_world_state(struct Context *ctx)
Clear all observations for the next tick.
void set_config_parameter(struct Context *ctx, enum ConfigParameter param, float value)
Set an immutable configuration parameter.
uint32_t tick(struct Context *ctx, uint32_t n_times)
Advance the simulation by one or more ticks.