code/__DEFINES/rust_g.dm
/proc/rustg_get_version | Gets the version of rust_g |
---|---|
rustg_setup_acreplace | Sets up the Aho-Corasick automaton with its default options. |
rustg_setup_acreplace_with_options | Sets up the Aho-Corasick automaton using supplied options. |
rustg_acreplace | Run the specified replacement engine with the provided haystack text to replace, returning replaced text. |
rustg_acreplace_with_replacements | Run the specified replacement engine with the provided haystack text to replace, returning replaced text. |
rustg_bsp_generate | This proc generates rooms in a specified area of random size and placement. Essential for procedurally generated areas, BSP works by cutting a given area in half, then cutting one of those subsections in half, and repeating this process until a minimum size is reached, then backtracking to other subsections that are not of the minimum size yet. These cuts are offset by small random amounts so that the sections are all varied in size and shape. |
rustg_cnoise_generate | This proc generates a cellular automata noise grid which can be used in procedural generation methods. |
rustg_dbp_generate | This proc generates a grid of perlin-like noise |
rustg_register_nodes_astar | Register a list of nodes into a rust library. This list of nodes must have been serialized in a json.
Node {// Index of this node in the list of nodes
unique_id: usize,
// Position of the node in byond
x: usize,
y: usize,
z: usize,
// Indexes of nodes connected to this one
connected_nodes_id: Vec |
rustg_add_node_astar | Add a new node to the static list of nodes. Same rule as registering_nodes applies. This node unique_id must be equal to the current length of the static list of nodes |
rustg_remove_node_astart | *² |
rustg_generate_path_astar | Compute the shortest path between start_node and goal_node using A*. Heuristic used is simple geometric distance |
rustg_random_room_generate | This proc generates rooms in a specified area of random size and placement. Used in procedural generation, but far less intensively than Binary Space Partitioning due to Random Room Placement being far more simple and unreliable for area coverage. These rooms will not overlap one another, but that is the only logic they do. The room dimensions returned by this call are hardcoded to be the dimensions of maint ruins so that I could sprinkle pre-generated areas over the binary space rooms that are random. These dimensions are: |
rustg_worley_generate | This proc generates a noise grid using worley noise algorithm |
Define Details
rustg_acreplace
Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
Arguments:
- key - The key for the automaton
- text - Text to run replacements on
rustg_acreplace_with_replacements
Run the specified replacement engine with the provided haystack text to replace, returning replaced text.
Arguments:
- key - The key for the automaton
- text - Text to run replacements on
- replacements - Replacements for this call. Must be the same length as the set-up patterns
rustg_add_node_astar
Add a new node to the static list of nodes. Same rule as registering_nodes applies. This node unique_id must be equal to the current length of the static list of nodes
rustg_bsp_generate
This proc generates rooms in a specified area of random size and placement. Essential for procedurally generated areas, BSP works by cutting a given area in half, then cutting one of those subsections in half, and repeating this process until a minimum size is reached, then backtracking to other subsections that are not of the minimum size yet. These cuts are offset by small random amounts so that the sections are all varied in size and shape.
BSP excels at creating rooms or areas with a relatively even distribution over an area, so there won't be too much blank open area. However if you discard rooms that overlap pre-existing map structures or areas, you may still get blank areas where nothing interesting appears.
Return:
- a json list of room data to be processed by json_decode in byond and further processed there.
Arguments:
- width: the width of the area to generate in
- height: the height of the area to generate in
- hash: the rng seed the generator will use for this instance
- map_subsection_min_size: The minimum size of a map subsection. When using this for rooms with walls, the minimum possible square will be a 5x5 room. Barring walls, this will be a 3x3 room. The maximum size will be 9x9, because a further cut could reduce this size beneath the minimum size.
- map_subsection_min_room_width: The minimum room width once the subsections are finalized. Room width and height are random between this amount, and the subsection max size
- map_subsection_min_room_height: The minimum room height once the subsections are finalized. Room width and height are random between this amount, and the subsection max size
rustg_cnoise_generate
This proc generates a cellular automata noise grid which can be used in procedural generation methods.
Returns a single string that goes row by row, with values of 1 representing an alive cell, and a value of 0 representing a dead cell.
Arguments:
- percentage: The chance of a turf starting closed
- smoothing_iterations: The amount of iterations the cellular automata simulates before returning the results
- birth_limit: If the number of neighboring cells is higher than this amount, a cell is born
- death_limit: If the number of neighboring cells is lower than this amount, a cell dies
- width: The width of the grid.
- height: The height of the grid.
rustg_dbp_generate
This proc generates a grid of perlin-like noise
Returns a single string that goes row by row, with values of 1 representing an turned on cell, and a value of 0 representing a turned off cell.
Arguments:
- seed: seed for the function
- accuracy: how close this is to the original perlin noise, as accuracy approaches infinity, the noise becomes more and more perlin-like
- stamp_size: Size of a singular stamp used by the algorithm, think of this as the same stuff as frequency in perlin noise
- world_size: size of the returned grid.
- lower_range: lower bound of values selected for. (inclusive)
- upper_range: upper bound of values selected for. (exclusive)
rustg_generate_path_astar
Compute the shortest path between start_node and goal_node using A*. Heuristic used is simple geometric distance
rustg_random_room_generate
This proc generates rooms in a specified area of random size and placement. Used in procedural generation, but far less intensively than Binary Space Partitioning due to Random Room Placement being far more simple and unreliable for area coverage. These rooms will not overlap one another, but that is the only logic they do. The room dimensions returned by this call are hardcoded to be the dimensions of maint ruins so that I could sprinkle pre-generated areas over the binary space rooms that are random. These dimensions are:
- 3x3
- 3x5
- 5x3
- 5x4
- 10x5
- 10x10
Return:
- a json list of room data to be processed by json_decode in byond and further processed there.
Arguments:
- width: the width of the area to generate in
- height: the height of the area to generate in
- desired_room_count: the number of rooms you want generated and returned
- hash: the rng seed the generator will use for this instance
rustg_register_nodes_astar
Register a list of nodes into a rust library. This list of nodes must have been serialized in a json.
Node {// Index of this node in the list of nodes
unique_id: usize,
// Position of the node in byond
x: usize,
y: usize,
z: usize,
// Indexes of nodes connected to this one
connected_nodes_id: Vec
rustg_remove_node_astart
*²
- Remove every link to the node with unique_id. Replace that node by null
rustg_setup_acreplace
Sets up the Aho-Corasick automaton with its default options.
The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call Arguments:
- key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
- patterns - A non-associative list of strings to search for
- replacements - Default replacements for this automaton, used with rustg_acreplace
rustg_setup_acreplace_with_options
Sets up the Aho-Corasick automaton using supplied options.
The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call Arguments:
- key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls
- options - An associative list like list("anchored" = 0, "ascii_case_insensitive" = 0, "match_kind" = "Standard"). The values shown on the example are the defaults, and default values may be omitted. See the identically named methods at https://docs.rs/aho-corasick/latest/aho_corasick/struct.AhoCorasickBuilder.html to see what the options do.
- patterns - A non-associative list of strings to search for
- replacements - Default replacements for this automaton, used with rustg_acreplace
rustg_worley_generate
This proc generates a noise grid using worley noise algorithm
Returns a single string that goes row by row, with values of 1 representing an alive cell, and a value of 0 representing a dead cell.
Arguments:
- region_size: The size of regions
- threshold: the value that determines wether a cell is dead or alive
- node_per_region_chance: chance of a node existiing in a region
- size: size of the returned grid
- node_min: minimum amount of nodes in a region (after the node_per_region_chance is applied)
- node_max: maximum amount of nodes in a region