Socket
Book a DemoInstallSign in
Socket

mendelian

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mendelian

mendelian

latest
Source
npmnpm
Version
0.2.3
Version published
Maintainers
1
Created
Source

mendelian


Logo

This package provides functionality for simulating genetic inheritance in creatures using Mendelian inheritance principles. It facilitates the creation of genes, genotypes, and creatures with customizable genetic properties.

Installation

You can install the package via npm:

yarn add mendelian

Usage

Creating a new seeded Genetics instance

import { Genetics } from "mendelian";

const genetics = new Genetics({ seed: "idrinkandiknowthings" });

Creating Genes

const blueEye = genetics.createAllele({
  trait: "eye-color",
  dominance: 3,
  description: "blue",
});

const greenEye = genetics.createAllele({
  trait: "eye-color",
  dominance: 5,
  description: "green",
});

const brownEye = genetics.createAllele({
  trait: "eye-color",
  dominance: 8,
  description: "brown",
});

Creating Creatures with Genes

const creatureOne = genetics.createCreature({
  genes: {
    eye: genetics.createGene({
      trait: "eye-color",
      alleles: [brownEye, blueEye],
    }),
  },
});

const creatureTwo = genetics.createCreature({
  genes: {
    eye: genetics.createGene({
      trait: "eye-color",
      alleles: [brownEye, blueEye],
    }),
  },
});

Reproducing a child

console.log(creatureOne.mate(creatureTwo).genes.eye.phenotype.description); // => brown
Demo

FAQs

Package last updated on 08 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts