1.5.0 • Published 2 years ago

evolution-ai v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago
$ npm install evolution-ai
const evolution = require("evolution-ai")

const world = new evolution.Simulation() //Start simulation
for (let i = 0; i < 100; i++) { // Loop for every generation

    for (let i = 0; i < world.Entities.length; i++) { //Loop for every entity 
        const Genome = world.Entities[i].split(""); //split for better reading of genome
        
        let have = false
        for (let idat = 0; idat < Genome.length; idat++) { //loop for every piece of genome
            const element = Genome[idat];
            
            // ! -- There belongs a "Natural" selection code -- !

            //----EXAMPLE----
            if(element === "A") {
                world.Kill(i) // This function will kill entity, if its has "A" in genome
                have = true
                break; // breaks genome scanning
            }
            //--END-EXAMPLE--
        }
        if(have === false) {
            world.Mutate(i, 3) // If hasnt it will multiply itself three times with little mutations
        }

    }

    console.log(world.Entities.length) //Writes number of nextgen entities to console
    world.NextGen() // Changes next generation to actual generation
}
1.5.0

2 years ago

1.4.0

2 years ago

1.2.2

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago