npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

genetics-ai.js

v2.1.6

Published

A Genetic Algorithm AI lib for JS

Downloads

29

Readme

genetics-ai.js

Installation

npm install genetics-ai

Genetics AI

Here we will use the DNA (now replaced as genome) to refer to the Genetics AI configuration.

The gnome is a sequence of bases that may be connections or biases type.

The connections are the links between sensors, neurons and actions, and the biases are the neurons and actions bias.

Start

You will have to extend the Individual class and implement the fitness method.

import { Individual } from 'genetics-ai'

class Car extends Individual {
  constructor(...args) {
    super(...args)
    this.health = 100
  }
  fitness() {
    return this.health / 100
  }
}

The genome structure

The genome is a sequence of bases as a sequence of 3 or 5 digits.

Each digit is a base 32 number to make the genome more compact. To explore the most of the data structure, we will use the binary of its digits.

Bases definition

const base = "000"

| config | target | |-------:|------------:| | 0 | 00 | | 00000 | 00000 00000 |

Connections Bases

This is the base that connects sensors, neurons and actions.

It has 5 digits, the first one is the config, the second and third ones are the source and the fourth and fifth ones are the target.

Example 1

const base = "00000"

| config | source | target | |-------:|------------:|------------:| | 0 | 00 | 00 | | 00000 | 00000 00000 | 00000 00000 |

Sources can be sensors (0) or neurons (1).

Targets can be neurons (0) or actions (1).

Example 2

const base = "A0B0C"

| config | source | target | |-------:|------------:|------------:| | A | 0B | 0C | | 01010 | 00000 01011 | 00000 01100 |

Connections Bases Limits

You may have at most:

  • 512 Sensors
  • 512 Neurons
  • 512 Actions

The weight is between [0, 15].

| config | source | target | |-------:|------------:|------------:| | U | VU | VU | | 11110 | 11111 11110 | 11111 11110 | | U | VV | VV | | 11110 | 11111 11111 | 11111 11111 |

Highest sensor into the highest neuron:

Highest neuron into the highest action:

Bias Bases

This base set the bias of a sensor, neuron or action.

It has 3 digits, the first one is the config, the second and third ones are the target.

Bias bases are accumulative!

const base = "100"

| config | target | |-------:|------------:| | 1 | 00 | | 00001 | 00000 00000 |

Bias Bases Limits

You may set bies at most:

  • 255 Sensors
  • 255 Neurons
  • 255 Actions

The bias is between [-7, 7].

| config | target | | |-------:|------------:|:----------------------------| | V | VS | bias with -7 for sensor 255 | | 11111 | 11111 11100 | | V | VT | | 11111 | 11111 11101 | | V | VU | | 11111 | 11111 11110 | | V | VV | | 11111 | 11111 11111 |

Appendix

Base 32 table

| b10 | b32 | bin | |:---:|:---:|:-----:| | 0 | 0 | 00000 | | 1 | 1 | 00001 | | 2 | 2 | 00010 | | 3 | 3 | 00011 | | 4 | 4 | 00100 | | 5 | 5 | 00101 | | 6 | 6 | 00110 | | 7 | 7 | 00111 | | 8 | 8 | 01000 | | 9 | 9 | 01001 | | 10 | A | 01010 | | 11 | B | 01011 | | 12 | C | 01100 | | 13 | D | 01101 | | 14 | E | 01110 | | 15 | F | 01111 | | 16 | G | 10000 | | 17 | H | 10001 | | 18 | I | 10010 | | 19 | J | 10011 | | 20 | K | 10100 | | 21 | L | 10101 | | 22 | M | 10110 | | 23 | N | 10111 | | 24 | O | 11000 | | 25 | P | 11001 | | 26 | Q | 11010 | | 27 | R | 11011 | | 28 | S | 11100 | | 29 | T | 11101 | | 30 | U | 11110 | | 31 | V | 11111 |