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

32
docs/en/algorithms.md Normal file
View file

@ -0,0 +1,32 @@
# Algorithms
In this document are listed some of algorithms for the sake of planning.
# Genome
## Generation examples
Examples section's goal is to document standard plant generation process.
Documented generation process is easier to visualize.
### Peashooter example
1. Create [generator] root
2. Add [transfer] stem
3. Add [transfer] head
4. Add [modifier] leaf
5. Return to head
6. Add [output] face
### Sunflower example
1. Create [dummy] root
2. Add [dummy] stem
3. Add [mixed] head
4. Add [output] face
### Cherry bomb example
1. Create [generator] root
2. Add [output] head
3. Add [dummy] face
4. Return to root
5. Repeat steps 3 and 4
### Potato mine example
1. Create [generator] root
2. Add [trigger] head
3. Add [dummy] face
### Wall-nut example
1. Create [dummy] root
2. Create [dummy] face

62
docs/en/genome.md Normal file
View file

@ -0,0 +1,62 @@
# 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 is mostly for me to remember things.
## Used terms and placeholders
(Very WIP) - This section is subject to change.
<Context> - Placeholder for context arguments. Currently I didn't think of this but I acknowledge that I might need them.
<T> - Type that doesn't exist yet but is obvious in context of section.
## The core principles are:
- Every plant can be represented as graph (sometimes as a tree).
- Every value of a node can be also a node (I might iterate on this one).
- Every node can have input and output.
- If node has input, and parent has output, parent must spread its output.
## Genome
### Gene
Genes are main logic elements of a plant. They're nodes of genetics graph.
I might iterate over this, but in current implementation is a little bit functional due to complications of OOP in Rust.
Gene structure consists of variables specific to gene, type and overridable methods for displaying itself and its children.
(Very WIP) Variables:
- Dictionary with some string type as a key and Argument enum.
- Argument enum consists of f32 and i64.
Type of gene is enum that provides different functions. Here is (Very WIP) list of every type and its provided functions:
Dummy - gene without behaviour.
Transport - gene that defines rules of flow.
- `distribute_between_children(<context>) -> ChildDistribution`
Pure Producer - gene that only creates flow.
- `create_flow(<context>,current_flow: mut Flow) -> Flow` - won't be called if flow isn't empty.
Producer - gene that creates or modifies 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.
- `consume(<context>)`
Trigger - gene that interacts with context to conditionally progress flow.
- `check_trigger(<context>) -> bool`
- `distribute_between_children(<context>) -> ChildDistribution` - same as Transport
Observer - gene that observes flow.
- `observe(<context>)`
- `distribute_between_children(<context>) -> ChildDistribution` - same as Transport
### Flow
Flow is data that circulates across genome. If not consumed, goes to the void.
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