API for creating and running game of life simulations.
More...
|
| gol_result | gol_simulation_create (gol_simulation *simulation) |
| | Creates new simulation.
|
| |
| gol_result | gol_simulation_query_property (gol_simulation simulation, gol_simulation_property_type property, gol_size *bytes, void *data) |
| | Query simulation property.
|
| |
| gol_result | gol_simulation_next_frame (gol_simulation simulation) |
| | Progress simulation to next time step.
|
| |
| gol_result | gol_simulation_query_cells (gol_simulation simulation, gol_size size, const gol_grid_position *positions, gol_cell *cells) |
| | Query cells at multiple positions.
|
| |
| gol_result | gol_simulation_set_cells (gol_simulation simulation, gol_size size, const gol_cell *cells) |
| | Update multiple simulation cells.
|
| |
| gol_result | gol_simulation_get_alive_cells (gol_simulation simulation, gol_size *size, gol_cell *cells) |
| | Query all alive cells.
|
| |
| gol_result | gol_simulation_get_updated_cells (gol_simulation simulation, gol_size *size, gol_cell *cells) |
| | Query cells updated by the simulation in last time step.
|
| |
| gol_result | gol_simulation_destroy (gol_simulation simulation) |
| | Destroys existing simulation.
|
| |
API for creating and running game of life simulations.
◆ GOL_FALSE
◆ GOL_TRUE
◆ gol_bool
◆ gol_grid_scalar
Position in single grid dimension.
- Since
- 1.0.0
◆ gol_handle
Generic opaque handle.
- Since
- 1.0.0
◆ gol_simulation
Handle for simulation resource.
- Since
- 1.0.0
◆ gol_simulation_property_frame_count
Count of time steps processed by the simulation.
- Since
- 1.0.0
◆ gol_size
Type representing nonnegative size of collections.
- Since
- 1.0.0
◆ gol_result
Defines possible operation results.
- Since
- 1.0.0
| Enumerator |
|---|
| GOL_RESULT_SUCCESS | Operation succeded.
|
| GOL_RESULT_ERROR | Operation failed.
|
| GOL_RESULT_UNKNOWN_SIMULATION_PROPERTY | Operation failed because of unknown simulation property.
|
◆ gol_simulation_property_type
Lists available simulation properties.
- Since
- 1.0.0
◆ gol_simulation_create()
Creates new simulation.
- Since
- 1.0.0
- Created simulation is empty - all cells are in dead state.
- Application is responsible for destroying simulation with gol_simulation_destroy().
- Application may call this function from simultaneus threads.
- Parameters
-
| [in,out] | simulation | Pointer for writing new simulation handle. |
- Return values
-
| GOL_RESULT_SUCCESS | Operation succeeded. |
◆ gol_simulation_destroy()
Destroys existing simulation.
- Since
- 1.0.0
- All resources owned by the simulation are immediately released.
- Application must not use simulation handle or resources after it was destroyed.
- Simultaneus threads may call this function only with different simulation handles.
- Parameters
-
| [in] | simulation | Handle to destroy. |
- Return values
-
| GOL_RESULT_SUCCESS | Operation succeeded. |
◆ gol_simulation_get_alive_cells()
Query all alive cells.
- Since
- 1.0.0
- This operation does not mutate simulation state.
- Simultaneus threads may call this function with different simulation handles.
- Simultaneus threads may call this and other functions that do not modify simulation state with the same simulation handle.
- Parameters
-
| [in] | simulation | Simulation to query. |
| [out] | size | Pointer for writing number of alive cells. Ignored if NULL. |
| [out] | cells | Pointer for writing alive cells. Ignored if NULL. |
- Return values
-
| GOL_RESULT_SUCCESS | Operation succeeded. |
◆ gol_simulation_get_updated_cells()
Query cells updated by the simulation in last time step.
- Since
- 1.0.0
- This operation does not mutate simulation state.
- Simultaneus threads may call this function with different simulation handles.
- Simultaneus threads may call this and other functions that do not modify simulation state with the same simulation handle.
- Parameters
-
| [in] | simulation | Simulation to query. |
| [out] | size | Pointer for writing number of updated cells. Ignored if NULL. |
| [out] | cells | Pointer for writing updated cells. Ignored if NULL. |
- Return values
-
| GOL_RESULT_SUCCESS | Operation succeeded. |
◆ gol_simulation_next_frame()
Progress simulation to next time step.
- Since
- 1.0.0
- Simulation state is updated according to simulation rules.
- This operation mutates simulation state.
- Simultaneus threads may call this function only with different simulation handles.
- Parameters
-
| [in] | simulation | Simulation to progress. |
- Return values
-
| GOL_RESULT_SUCCESS | Operation succeeded. |
◆ gol_simulation_query_cells()
Query cells at multiple positions.
- Since
- 1.0.0
- This operation does not mutate simulation state.
- Simultaneus threads may call this function with different simulation handles.
- Simultaneus threads may call this and other functions that do not modify simulation state with the same simulation handle.
- Parameters
-
| [in] | simulation | Simulation to query. |
| [in] | size | Number of positions to query. |
| [in] | positions | Pointer for reading queried positions. |
| [out] | cells | Pointer for writing queried cells. Order of written cells corresponds to order of queried positions. |
- Return values
-
| GOL_RESULT_SUCCESS | Operation succeeded. |
◆ gol_simulation_query_property()
Query simulation property.
- Since
- 1.0.0
See gol_simulation_property_type for available properties.
- This operation does not mutate simulation state.
- Simultaneus threads may call this function with different simulation handles.
- Simultaneus threads may call this and other functions that do not modify simulation state with the same simulation handle.
- Parameters
-
| [in] | simulation | Simulation to query. |
| [in] | property | Property to query. |
| [out] | bytes | Pointer for writing size of query results in bytes. Ignored if NULL. |
| [out] | data | Pointer for writing query results. Ignored if NULL. |
- Return values
-
| GOL_RESULT_SUCCESS | Operation succeeded. |
| GOL_RESULT_UNKNOWN_SIMULATION_PROPERTY | Queried unknown property. |
◆ gol_simulation_set_cells()
Update multiple simulation cells.
- Since
- 1.0.0
- Modyfing same cell multiple times within a single call is allowed.
- All updates are applied in order of cells array.
- This operation mutates simulation state.
- Simultaneus threads may call this function only with different simulation handles.
- Parameters
-
| [in] | simulation | Simulation to update. |
| [in] | size | Number of cells to update. |
| [in] | cells | Pointer for reading cells to update. |
- Return values
-
| GOL_RESULT_SUCCESS | Operation succeeded. All updates were applied. |