https://github.com/tabone/mendelian
An NPM Module used to simulate genetic inheritance using Mendelian inheritance
https://github.com/tabone/mendelian
Last synced: 8 months ago
JSON representation
An NPM Module used to simulate genetic inheritance using Mendelian inheritance
- Host: GitHub
- URL: https://github.com/tabone/mendelian
- Owner: tabone
- Created: 2024-03-22T18:27:51.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-08T19:45:05.000Z (about 2 years ago)
- Last Synced: 2025-10-12T13:57:15.672Z (9 months ago)
- Language: TypeScript
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
mendelian

This package provides functionality for simulating genetic inheritance in creatures using [Mendelian inheritance](https://en.wikipedia.org/wiki/Mendelian_inheritance) principles. It facilitates the creation of genes, genotypes, and creatures with customizable genetic properties.
## Installation
You can install the package via npm:
```bash
yarn add mendelian
```
## Usage
### Creating a new seeded `Genetics` instance
```javascript
import { Genetics } from "mendelian";
const genetics = new Genetics({ seed: "idrinkandiknowthings" });
```
### Creating `Gene`s
```javascript
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 `Creature`s with `Gene`s
```javascript
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
```javascript
console.log(creatureOne.mate(creatureTwo).genes.eye.phenotype.description); // => brown
```