2.1.6 • Published 4 months ago

genetics-ai.js v2.1.6

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
4 months ago

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"
configtarget
000
0000000000 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"
configsourcetarget
00000
0000000000 0000000000 00000

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

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

Example 2

const base = "A0B0C"
configsourcetarget
A0B0C
0101000000 0101100000 01100

Connections Bases Limits

You may have at most:

  • 512 Sensors
  • 512 Neurons
  • 512 Actions

The weight is between 0, 15.

configsourcetarget
UVUVU
1111011111 1111011111 11110
UVVVV
1111011111 1111111111 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"
configtarget
100
0000100000 00000

Bias Bases Limits

You may set bies at most:

  • 255 Sensors
  • 255 Neurons
  • 255 Actions

The bias is between -7, 7.

configtarget
VVSbias with -7 for sensor 255
1111111111 11100
VVT
1111111111 11101
VVU
1111111111 11110
VVV
1111111111 11111

Appendix

Base 32 table

b10b32bin
0000000
1100001
2200010
3300011
4400100
5500101
6600110
7700111
8801000
9901001
10A01010
11B01011
12C01100
13D01101
14E01110
15F01111
16G10000
17H10001
18I10010
19J10011
20K10100
21L10101
22M10110
23N10111
24O11000
25P11001
26Q11010
27R11011
28S11100
29T11101
30U11110
31V11111
2.1.2

4 months ago

2.1.1

4 months ago

2.1.4

4 months ago

2.1.3

4 months ago

2.0.4

4 months ago

2.1.6

4 months ago

2.1.5

4 months ago

2.1.0

4 months ago

2.0.3

4 months ago

2.0.2

4 months ago

2.0.1

4 months ago

2.0.0

4 months ago

1.2.0

1 year ago

1.2.1

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago