Ask or search…
Comment on page

3.3 Forging & Traits

This guide offers a comprehensive explanation of how our AIBOLT trait mapping process works. Written in Solidity, our contract takes five AIORBITs to forge a new AIBOLT, where each AIORBIT's traits are used to shape the characteristics of the new AIBOLT.
Read the AIBOLT contract code here.

1. Initialization

Firstly, the contract initiates several variables that will hold the combined values of certain traits from the five AIORBITs involved in the forging.
The traits included are:
  • totalHue: Refers to the total hue from all five AIORBITs.
  • totalRotationSpeed: Refers to the sum of the rotation speed values from all five AIORBITs.
  • totalNumCircles: Refers to the total number of circles from all five AIORBITs.
  • totalRadius, totalDistance, and totalStrokeWidth: These are arrays storing the total values for the radius, distance, and stroke width of each circle from all five AIORBITs. As each AIORBIT can have multiple circles, these traits are stored as arrays.

2. Trait Gathering

The next step involves running a loop over each of the five AIORBITs. For each AIORBIT, the contract retrieves its trait values (hue, rotation speed, number of circles, radius, distance, and stroke width) using the generateAIORBITTraits function from the OrbitProxy library.
The retrieved trait values are then added to their respective total trait variables initiated in the previous step. For instance, the hue value from an AIORBIT is added to totalHue, and the same principle is applied for the rest of the traits.

3. Trait Averaging

Once the contract has gathered all the trait values from the five AIORBITs, it computes the average value for each trait. This process combines the five AIORBITs into a single set of averaged values, which forms the foundational traits for the new AIBOLT.

4. Planet Generation

The number of planets (numPlanets) in an AIBOLT is determined by the average number of circles (averagedValues.numCircles). Here's how it's mapped:
  • If the number of circles is between 1 and 3 (inclusive), the AIBOLT has 1 planet.
  • If the number of circles is greater than 3 but less than or equal to 4, the AIBOLT has 2 planets.
  • If the number of circles is greater than 4 but less than or equal to 5, the AIBOLT has 3 planets.
After determining the number of planets, the contract assigns a unique biome to each planet. Each biome is derived from the AIBOLT's hue attribute, which is then transformed to fit within a predefined biome range.
This biome assignment process involves several steps:
  1. 1.
    Define the range for hue and the range for biomes. In this case, hue ranges from 0 to 359, and biome ranges from 0 to 5.
  2. 2.
    For each planet, calculate its specific hue. This is done by adding an offset (i * 60) to the averaged hue and then applying a modulo operation to keep the result within the hue range. Here 'i' is the index of the planet (0, 1, or 2).
  3. 3.
    Scale the planet-specific hue to fit within the biome range. This is achieved by performing a linear transformation that maps the hue range to the biome range.
  4. 4.
    Make sure the calculated biome is within the valid range (0 to 5). If not, adjust it to either the start or end of the range.

5. Planet Data Generation

With the number of planets and their biomes determined, the generatePlanetData function is used to create detailed data for each planet. Although the code for this function isn't provided, we can infer that it takes the averaged trait values, the number of planets, and the biomes for each planet as inputs to generate the planet data.
Given the context, the generatePlanetData function likely uses these inputs to decide specific attributes for each planet. For instance, the radius, distance, and stroke width of each planet could be derived from the averaged values. The biome of each planet, on the other hand, could dictate its appearance, environmental characteristics, or other aspects.
By compiling the attributes determined through this process, the generatePlanetData function constructs a comprehensive representation of each planet, contributing to the final characteristics of the AIBOLT.

6. Sun Assignment

For assigning the sun type, the contract uses the averaged hue value modulus 4. This operation results in a value between 0 and 3, which is used to select a sun type from four options: "Pulsar", "Red-Giant", "White-Dwarf", or "Neutron-Star".


The planet generation and planet data generation processes are crucial steps in the AIBOLT trait mapping. They incorporate the traits of the five AIORBITs and convert them into meaningful attributes for the AIBOLT's planets. Through these processes, each AIBOLT becomes a unique entity with its own number of planets, each with a distinct biome and specific characteristics. Users looking to forge new AIBOLTs should consider these intricacies, as the AIORBIT traits will directly influence the resulting AIBOLT's composition.