documented genome tools

This commit is contained in:
Rendo 2026-03-31 17:42:53 +05:00
commit fc4d9d2ee3
4 changed files with 106 additions and 11 deletions

View file

@ -1,4 +1,4 @@
# Principles # Genome
This document describes principles I have came up with. I don't think I'd be angry if you use them in your projects. This document describes principles I have came up with. I don't think I'd be angry if you use them in your projects.
This document is mostly for me to remember things. This document is mostly for me to remember things.
@ -28,25 +28,35 @@ Type of gene is enum that provides different functions. Here is (Very WIP) list
Dummy - gene without behaviour. Dummy - gene without behaviour.
Transfer - gene that defines rules of flow. Transport - gene that defines rules of flow.
- `distribute_between_children(<context>,flow: mut <Flow>) -> <Distribution>` - `distribute_between_children(<context>) -> ChildDistribution`
Pure Generator - gene that only creates flow. Pure Producer - gene that only creates flow.
- `create_flow(<context>,current_flow: mut <Flow>) -> <Flow>` - won't be called if flow isn't empty. - `create_flow(<context>,current_flow: mut Flow) -> Flow` - won't be called if flow isn't empty.
Modifier - gene that modifies or creates flow. Producer - gene that creates or modifies flow.
- `modify_flow(<context>,current_flow: mut <Flow>) -> <Flow>` - `create_flow(<context>) -> Flow` - called if ProduceDecision::CreateFlow
- `modify_single(<context>) -> Flow` - called if ProduceDecision::ModifySingle
- `modify_all(<context>) -> Flow` - called if ProduceDecision::ModifyAll
Modifier - gene that only modifies flow.
- `modify_flow(<context>) -> Flow`
Consumer - gene that consumes flow. Consumer - gene that consumes flow.
- `consume(<context>)` - `consume(<context>)`
Trigger - gene that interacts with context to conditionally progress flow. Trigger - gene that interacts with context to conditionally progress flow.
- `check_trigger(<context>) -> bool` - `check_trigger(<context>) -> bool`
- `distribute_between_children(<context>) -> ChildDistribution` - same as Transport
Observer - gene that observes flow. Observer - gene that observes flow.
- `observe(<context>,current_flow: mut <Flow>)` - `observe(<context>)`
- `distribute_between_children(<context>) -> ChildDistribution` - same as Transport
### Flow ### Flow
Flow is data that circulates across genome. If not consumed, goes to the void. Flow is data that circulates across genome. If not consumed, goes to the void.
Currently it is something like Vec<ProjectileData> Currently it is struct containing Vec<ProjectileData>
### Context
<context> consists of current Flow struct and Godot context. Godot context should at least be Plant node.

View file

@ -0,0 +1,85 @@
# Genome and player
This document describes principles I have came up with. I don't think I'd be angry if you use them in your projects.
This document is mostly for me to remember things.
## Used terms
MC - Modification Currency. Currency that player spends on modifications
## The core principles are:
- Every plant that is represented as graph can be drawn.
- Player should have all necessary instruments to create anything he likes by the end of his playthrough.
- Player's tools should progress through game
## Progression
- Player should start small
- Player starts with somewhat of a currency to spend on modifications each level
- Player starts with allelic crossingover and "combine" tools
- Progressing through the levels, player gains the most important instruments
- Optional instruments and template plants are bought through shop
## Levels
- Before level, player may adjust his plants collection through experimentation.
## Planned tools
Early game:
- Allelic crossingover
- Player picks two plants, and they exchange genes that are on the same places.
- As an output, player gets two plants.
- Upgrades to "Swap places" tool
- Costs 1 MC
- Categoric crossingover
- Player picks two plants, and they exchange genes that hold the same label.
- As an output, player gets two plants.
- Upgrades to "Swap" tool
- Costs 1 MC
- Combine tool
- Player picks donor and recipient plant. Then, algorithm decides whether to replace one node or to add as a child. Then, algorithm picks subgraph from donor, and applies it to recipient.
- As an output, player gets two plants - recipient and donor.
- Upgrades to "Add" tool
- Costs 1 MC
- Random deletion tool
- Player picks one plant, and algorithm randomly deletes genes from it.
- As an output, player gets one plant.
- Upgrades to "Remove" tool
- Costs 1 MC
- Random mutation tool
- Player picks one plant. Then, algorithm mutates it randomly and uncontrollably.
- As an output, player gets one plant.
- Upgrades to "Batch mutation" tool.
- Costs 1 MC
Midgame
- Remove tool
- Player picks one plant. They might pick one or more nodes to delete. Then, selected genes are deleted.
- As an output, player gets one plant.
- Costs 1.5 MC
- Add tool
- Player picks donor and recipient plant. Then, player selects one or more genes. Then, player selects to replace or position subgraph.
- As an output, player gets two plants - recipient and donor.
- Costs 2 MC
- Upgrades to "Create" tool
- Swap tool
- Player picks two plants. They must pick first and second genes.
- As an output, player gets two plants with swapped genes.
- Costs 0.25 MC
- The cost is low because it was meant to be applied multiple times
- Swap places tool
- Player picks two plants. Then, player selects one or more genes that will be swapped.
- As an output, Player gets two plants with swapped genes.
- Costs 1.5 MC
- Batch mutation tool
- Player picks one plant. Then, player selects amount of mutations.
- As an output, Player gets one plant.
- Upgrades to "Batch controlled mutation" tool
- Costs 3 MC
- Batch controlled mutation tool
- Player picks one plant. Then, Player selects genes to mutate.
- As an output, player gets one plant.
- Costs 5 MC
Endgame
- Create tool
- Player has genes dock. Player constructs tree from them, and then attaches it to selected plant, or creates new.
- As an output, player gets one plant.
- Costs 10 MC

View file

@ -39,7 +39,7 @@ pub enum GeneType {
}, },
/// Modifies flow /// Modifies flow
Modifier { Modifier {
modify_flow: fn(GeneContext) -> Option<Flow> modify_flow: fn(GeneContext) -> Flow
}, },
/// Conditionally passes through flow. Acts like transport. /// Conditionally passes through flow. Acts like transport.
Trigger { Trigger {
@ -101,7 +101,7 @@ impl GeneType {
Self::Consumer { consume: consumer_function } Self::Consumer { consume: consumer_function }
} }
/// Creates modifier with modifier function. /// Creates modifier with modifier function.
pub fn modifier(modifier_function: fn(GeneContext) -> Option<Flow>) -> Self { pub fn modifier(modifier_function: fn(GeneContext) -> Flow) -> Self {
Self::Modifier { modify_flow: modifier_function } Self::Modifier { modify_flow: modifier_function }
} }
/// Creates trigger with distribution between all children. /// Creates trigger with distribution between all children.