Updates Genome Expansion project Weekly Updates


New Member
Hello everyone! This thread serves as an area to post weekly updates of my project with status reports of tasks done as well as expected tasks for the following week. A final blog summary of the entire project will be posted on Medium at https://medium.com/@vedant.294. This forum should contain enough information for people interested in the project but not actively involved with it to understand the status and developments as time passes. Most of the information regarding the tasks lined up is available in the proposal and the Trello board as linked below.

Basic Information :
Project Summary :
My goal for GSoC 2020 is to create a solid foundation with which future modules can implement genomes in an easy manner. Currently, the Genomes module exists in isolation with implementations mostly in the form of unmerged PRs or unused modules. A major focus of this project is to integrate Genomes with SimpleFarming and have it in a usable state at the end of this project. Since this a content-based project, I am also looking to integrate Genomes with other modules which are very close to the player and core elements of the game such as Health, Cooking and Thirst. Another point of work is integrating Genetic Variations in the plants with Biomes and spawning of the different plants in different Biomes. More details on the project can be found in the links above.


New Member
Progress so far:
After studying the subject of genetics and the current implementations of genetics in Terasology, namely Genomes and SoundyGenetics the following conclusions were drawn regarding genetics in Terasology :
  • Rather than merging SoundyGenetics and Genomes as suggested in the proposal, Different implementations of breeding algorithms will be added to Genomes. Traits will be classified as either Continuous or Discrete and corresponding breeding algorithms will be applied as fit.
  • Breeding algorithms are currently registered per-entity in the Genomes module, this should be changed to a per-trait registering system as the breeding algorithm is different for continuous and discrete traits.
  • Discrete traits will breed according to a simple Punnet Square distribution. The exact methodology for breeding continuous traits is yet to be decided.
  • Tinting of items can be done using the implementations in SubstanceMatters. It was done successfully using SubstanceMatters
  • Unsure if tinting of BlockTiles is possible via SubstanceMatters (most probably no). Alternate method should be adopted to tint blocks/parts of blocks. There was some talk of tinting in a PR involving LWJGL3 by @Darkweird, but for the time being, tinting blocks can be ignored/done to the entire block for testing purposes
Details of Meeting #1 - Community Bonding Period (24/05/20)
  • Monoploid and Diploid breeding algorithms need to be studied before changing/adding anything to avoid rewriting any code. Can consult soundwave and casals for this.
  • Might not be a problem to use substance matters right now for tinting items, but can make a new module and remove tinting from substance matters and have substance matters depend on it (in the future)
  • MTE will be used mostly to test new genetics. Can also do standard unit testing for things like the normal function values and stuff, but for events etc, we can use MTE which makes a headless server. Inventory tests should be there by June 7 ish so can refer to that. (discuss with skaldarnar and jellysnake as well)
  • Work with current seed mixer to add breeding (A+A-->A is not possible at the moment. It should be added)
  • An override in genomes which changes UI of seed breeder can be added. This would help the optional dependency of SimpleFarming on Genomes.
  • GenomesAuthoritySystem will go in SimpleFarming, not Genomes. It won't do anything if genomes is not enabled.
  • Need to work on continuous breeding ago. the normal dist stuff will get messed up when parents are not close to avg values. [stochastic simulation or distribution approximation]. Closer to the end, Poisson distribution is better so maybe a combo of two distributions can be used. Also maybe a normal dist with 80% to have in between the parents and 20% outside to add more variation. Maybe normal distribution can be used for now and playtest and then change later based on the observations.


New Member
Week #1 (Coding Period)

So the coding period for GSoC 2020 has begun and week 1 has passed by speedily. This post will contain a progress report of my work during the first week of this coding period and will contain a follow up to add meeting notes for the first meeting during the coding period.

Progress Update:
My work for the first two weeks primarily involves modifying the Genomes module and introducing certain features that allow it to work better with the proposed implementations in the future. Since no real implementation of Genomes exists currently, a test driven approach was followed where a set of tests was written for Genomes, one which worked in the state of Genomes before any modification, and more tests which would work once the work on Genomes was completed. When the first tests are outdated and the second set of tests is working, the work on Genomes is almost complete. The things I worked on this week are as follows :
  • Changed the breeding algorithm registered per organism type everywhere to act as a default breeding algorithm for that type.
  • Added ability to register a specific breeding algorithm per trait to account for different types of traits (continuous and discrete).
  • Wrote multiple tests for the initial Genomes system and for the required genomes system without breeding
  • The first test is based on an existing PR on SimpleFarming which tried to integrate SimpleFarming with Genomes
  • The SimpleGenomeManager is a system that handles all the breeding related events. Here, breeding was done by taking two Strings containing the genes of parent organisms (the genes of an organism are stored as Strings with values appended to it for new traits) and based on the breeding algorithm chosen for the entire organism type, random values were picked from each parent for the Genes. This had to be changed to each gene using its own breeding algorithm to get a proper set of offspring genes following the same trait type (discrete or continuous) as the parents. This was one of the major focuses of the week.
  • A new breeding algorithm, the Discrete breeding algorithm was added to breed discrete traits more effectively and correctly.
  • Testing of the discrete breeding algorithm and the multiple trait breeding was done.
  • Currently working on a Continuous breeding algorithm for continuous traits after which Unit testing of the entire module can be performed.

    PRs made this week :
Meeting Notes: (Coding period #1 07/06/2020)
Topics discussed :

  • Unit tests
  • Swapping tasks for weeks mentioned in proposal
  • Tinting method
  • Trait randomizing at spawn
  • Trello board
  • Genome check command
Notes :
  • Push the discrete breeding algorithm test, no matter how small the test is, it serves as a way of checking if the code is broken in the future.
  • Changes in the schedule in terms of swapping the weeks is fine, the tasks of next week will be more in relation to SimpleFarming and EdibleFlora restructure along with some Genome integration aspects.
  • GenomeAuthoritySystem work will be done this week as well
  • For now the tinting of items can be done via SubstanceMatters, however since there is no real connection between the two modules, at some point it would make sense to remove the tinting mechanism from SubstanceMatters and have SubstanceMatters as well as SimpleFarming depend on that instead.
  • The randomizing of values at spawn can be done via the BushRasterizer code and the SeedBasedGenomeMap. More research needs to be done on the exact structure of this code.
  • Use the progress column of the trello board to put cards of active tasks as well as PRs that are currently open and need review/merging. This would allow other mentors to get an idea of what I am working on
  • The HeldGenomeCheck command will be created which uses the HandHeld component and returns the Genes from the GenomeComponent of the held item.
Last edited:


New Member
Week #2 (Coding Period)

Week 2 of my GSoC project was primarily focused on SimpleFarming and EdibleFlora and adding Genomes to work with these 2 modules. Multiple events were defined to work with the two modules as well as the GenomeAuthoritySystem to handle most of the Genome events. A point to note here is that Genomes is intended to be an optional dependency of EdibleFlora and not a compulsory one.

Progress Update:
The first few days of the week were spent on adding the Continuous Breeding Algorithm to Genomes along with unit tests for this and units tests for multiple traits together. Good amount of time this week was also spent on planning and thinking about the method of adding Genetics in the bushes and seeds, how/when they should be randomized and how the traits are to be passed from one generation to the next. This has made the work for the coming week more straightforward(hopefully) and well planned out. Following are the tasks I accomplished this week :
  • Added a Continuous breeding algorithm to Genomes to work with Continuous traits like rate of growth of bushes etc. It relies on mutation to produce values outside of the boundaries of the parents genes.
  • https://github.com/Terasology/Genome/pull/10 was merged, after which certain issues were identified. Therefore https://github.com/Terasology/Genome/pull/12 was created to fix these issues. Final changes on this PR are pending and will be done in a day or so.
  • Added events to EdibleFlora like onSpawn which is fired when bushes are spawned in the world. The handler for these events is present in the GenomeAuthoritySystem
  • Added Genomes as an optional dependency to EdibleFlora
  • Created the GenomeAuthoritySystem to handle Genetics related tasks in EdibleFlora and SimpleFarming
  • Added the capability for GenomeComponent to be added and passed from Bushes to seed and seeds to bushes and so on when they are planted/harvested.
  • Added the heldGenomeCheck in game console command which uses the heldItemComponent of the player and returns the GenomeComponent if it exists

    PRs made this week :
Meeting Notes: (Coding period Week #2 14/06/2020)
Topics discussed :

  • Best time to add GenomeComponent to bushes
  • Randomizing the Genes
  • Registering traits of different plants
  • Prioritizing tasks
  • EntityRef in events
  • Event chaining
  • Components and Events
Notes :
  • BushRasterizer works at worldGen and architecture wise this would probably be the best place to add it, but there are some possible issues which may cause a timeout of world generation which need looking into
  • Randomizing of traits should be done at spawn using Seed based random values
  • Register plants when they are discovered to reduce code duplication
  • Good to prioritize tasks and keep some for possible additions if time permits during the week
  • Tinting will be a good visual indicator for the player if its linked to filling
  • Events called on particular entities is based on intuition and design thoughts for the event. No hard and fast rule about this
  • Event handlers are chained. Default behavior of event chaining is unsure
  • For both ways, components in signature or in the annotation, the entity MUST have the components for that handler to be triggered.


New Member
Week #3 (Coding Period)

Week 3 was primarily focused with integrating Genomes with SimpleFarming and EdibleFlora. The creation of the GenomeAuthoritySystem was a major achievement this week and a few roadblocks along the way made this a hard task

Progress Update:
The entire week was spent creating events for SimpleFarming to be handled by the GenomeAuthoritySystem in EdibleFlora so that Genomes sits at the EdibleFlora level as an optional dependency. The GenomeAuthoritySystem was also developed and this had multiple challenges that had to be overcome during the week. Following are the tasks I accomplished this week :
  • Added 3 new Events to SimpleFarming to be handled by the GenomeAuthoritySystem
  • Created the GenomeAuthoritySystem in EdibleFlora to handle these Genome related events and transfer the GenomeComponent from bush->seed->bush and so on
  • Major debugging and fixing was required for this as multiple problems arose. Problems listed below.
  • Did some work with Tinting to finalize the method of tinting to be used for items

    PRs made this week : (Both draft PRs, will be ready for review once certain things are completed in the coming week)
  • https://github.com/Terasology/EdibleFlora/pull/5
  • https://github.com/Terasology/SimpleFarming/pull/93
Problems Faced:
  • First, It was decided that the GenomeComponent would be assigned to the bushes on spawn in the BushRasterizer, however the GenomeComponent did not stay on the block after it was added through an event handler. The reason for this was discovered much later to be a problem with the RetainComponent not containing the GenomeComponent
  • Then the multiple events in the SimpleFarming module had to have proper transfer of GenomeComponent from seed->bush when the seed is planted and from bush->seed on harvested. Due to the number of different ways this is handled, it created problems that required lot of debugging
  • The GenomeComponent of a seed when planted, was not being transferred correctly to the bush. This turned out to be a major problem and multiple days were spent debugging this. Finally the cause has been determined as the RetainComponents list in the EntityAwareWorldProvider not containing the GenomeComponent. Thus when a half bush grows to a full bush, it loses all its components including the GenomeComponent. The exact solution to this has not been implemented yet but it will involve adding the GenomeComponent to the RetainComponent list in the world provider.
Tasks remaining before merging:
  • Write modifications for non sustainable bushes to inherit GenomeComponent and not throw NPE
  • Fix RetainComponents problem
  • Major Code Cleanup
  • Optional dependency of Genomes must be enforced
  • Add JavaDoc in the new Handlers and events
Last edited:


New Member
Week #4 (Coding Period)

Week 4 was all about finishing up remaining work and clearing the roadblocks that prevented everything from going forward. The work with SimpleFarming and EdibleFlora is almost complete, as most of the implementation work is completed barring some design issues which need to be handled.

Progress Update:
Following are the tasks I accomplished this week :
  • The RetainComponentsComponent was not reflecting its values in the RetainComponentsList in the EntityAwareWorldProvider, but was rather being passed as a null set on every call. This could be due to certain deprecated method calls in SimpleFarming. This was fixed which allowed the Genome work of SimpleFarming and EdibleFlora to function as intended
  • SeedBreeder work has begun, allowing seeds to breed with like seeds and also breed with genetics is an ongoing task
  • Code cleanup for both draft PRs made last week was done to make it ready for review
  • Support for non sustainable bushes was added so it does not throw NPEs when parents are destroyed
  • Javadoc was added to all the new handlers and events so it is clear what each one is intended for
  • All Genome mentions were removed from SimpleFarming and EdibleFlora, except for the GenomeAuthoritySystem in EdibleFlora
  • Both PRs of last week were marked as ready for review, changes based on the design have been suggested and they will be worked on. Many parts of the GenomeAuthoritySystem will now be moved to SimpleFarming

    PRs made this week :
  • https://github.com/MovingBlocks/Terasology/pull/4060
  • https://github.com/Terasology/EdibleFlora/pull/5
  • https://github.com/Terasology/SimpleFarming/pull/93
Work for the upcoming week:
  • Start with the changes suggested in the two genomes related PRs to redesign the interaction between genomes, SimpleFarming and EdibleFlora so the GenomeAuthoritySystem resides in SimpleFarming
  • Move the heldGenomeCheck to Genomes
  • Complete seed breeder work so it can breed like seeds with genetics
  • Start work with the Cooking module and Health module to identify how the cooking module can be used with genetics and the exact structure of the approach
  • The week after this will be mainly focused on Cooking, Health and Tinting