Skip to content

An NPM Module used to simulate genetic inheritance using Mendelian inheritance

Notifications You must be signed in to change notification settings

tabone/mendelian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

An NPM Module used to simulate genetic inheritance using Mendelian inheritance

Resources

Stars

Watchers

Forks