generated from michael/webpack-base
enable full sized snake genome
This commit is contained in:
parent
b33ffc3baa
commit
a69af98250
@ -135,6 +135,8 @@ export default function runCanvas(canvas: HTMLCanvasElement, pipeRef: MutableRef
|
|||||||
const STARVE_STEPS = BOARD_SQUARES * 6;
|
const STARVE_STEPS = BOARD_SQUARES * 6;
|
||||||
|
|
||||||
// neat configuration ------------------------------------------------------
|
// neat configuration ------------------------------------------------------
|
||||||
|
// TODO: this configuration is not learning
|
||||||
|
// figure out why, maybe scoring is not proper -- or speciation is too forced
|
||||||
const FC: FertilityConfig = {
|
const FC: FertilityConfig = {
|
||||||
fertile_threshold: 0.6,
|
fertile_threshold: 0.6,
|
||||||
champion_min_species_size: 3,
|
champion_min_species_size: 3,
|
||||||
|
@ -25,10 +25,10 @@ const FEATURES = {
|
|||||||
HEAD_Y: 'HEAD_Y',
|
HEAD_Y: 'HEAD_Y',
|
||||||
APPLE_REL_X: 'APPLE_REL_X',
|
APPLE_REL_X: 'APPLE_REL_X',
|
||||||
APPLE_REL_Y: 'APPLE_REL_Y',
|
APPLE_REL_Y: 'APPLE_REL_Y',
|
||||||
// TAIL_ABOVE: 'TAIL_ABOVE',
|
TAIL_ABOVE: 'TAIL_ABOVE',
|
||||||
// TAIL_BELOW: 'TAIL_BELOW',
|
TAIL_BELOW: 'TAIL_BELOW',
|
||||||
// TAIL_LEFT: 'TAIL_LEFT',
|
TAIL_LEFT: 'TAIL_LEFT',
|
||||||
// TAIL_RIGHT: 'TAIL_RIGHT',
|
TAIL_RIGHT: 'TAIL_RIGHT',
|
||||||
};
|
};
|
||||||
const OUTPUTS = {
|
const OUTPUTS = {
|
||||||
U: 'U',
|
U: 'U',
|
||||||
@ -43,10 +43,10 @@ const _BASE_GENOME_SNAKE_BRAIN_NEAT_EDGES = completeBipartiteEdges(
|
|||||||
FEATURES.HEAD_Y,
|
FEATURES.HEAD_Y,
|
||||||
FEATURES.APPLE_REL_X,
|
FEATURES.APPLE_REL_X,
|
||||||
FEATURES.APPLE_REL_Y,
|
FEATURES.APPLE_REL_Y,
|
||||||
// FEATURES.TAIL_ABOVE,
|
FEATURES.TAIL_ABOVE,
|
||||||
// FEATURES.TAIL_BELOW,
|
FEATURES.TAIL_BELOW,
|
||||||
// FEATURES.TAIL_LEFT,
|
FEATURES.TAIL_LEFT,
|
||||||
// FEATURES.TAIL_RIGHT,
|
FEATURES.TAIL_RIGHT,
|
||||||
],
|
],
|
||||||
[OUTPUTS.U, OUTPUTS.D, OUTPUTS.L, OUTPUTS.R],
|
[OUTPUTS.U, OUTPUTS.D, OUTPUTS.L, OUTPUTS.R],
|
||||||
);
|
);
|
||||||
@ -108,10 +108,10 @@ export class NEATSnakeBrain {
|
|||||||
act.set(FEATURES.HEAD_Y, head.y);
|
act.set(FEATURES.HEAD_Y, head.y);
|
||||||
act.set(FEATURES.APPLE_REL_X, appleRel.x);
|
act.set(FEATURES.APPLE_REL_X, appleRel.x);
|
||||||
act.set(FEATURES.APPLE_REL_Y, appleRel.y);
|
act.set(FEATURES.APPLE_REL_Y, appleRel.y);
|
||||||
// act.set(FEATURES.TAIL_ABOVE, Math.max(...above, BOARD_SQUARES));
|
act.set(FEATURES.TAIL_ABOVE, Math.max(...above, BOARD_SQUARES));
|
||||||
// act.set(FEATURES.TAIL_BELOW, Math.max(...below, BOARD_SQUARES));
|
act.set(FEATURES.TAIL_BELOW, Math.max(...below, BOARD_SQUARES));
|
||||||
// act.set(FEATURES.TAIL_LEFT, Math.max(...left, BOARD_SQUARES));
|
act.set(FEATURES.TAIL_LEFT, Math.max(...left, BOARD_SQUARES));
|
||||||
// act.set(FEATURES.TAIL_RIGHT, Math.max(...right, BOARD_SQUARES));
|
act.set(FEATURES.TAIL_RIGHT, Math.max(...right, BOARD_SQUARES));
|
||||||
|
|
||||||
this.brain.think(act);
|
this.brain.think(act);
|
||||||
|
|
||||||
|
@ -594,18 +594,12 @@ export function mutate(genome: Genome, config: MutateConfig): Genome {
|
|||||||
if (Math.random() < new_connection_rate) {
|
if (Math.random() < new_connection_rate) {
|
||||||
// create a new connection between two *previously unconnected* nodes
|
// create a new connection between two *previously unconnected* nodes
|
||||||
const options = findAcyclicInternalNewConns(newGenome);
|
const options = findAcyclicInternalNewConns(newGenome);
|
||||||
if (options.length === 0) {
|
if (options.length > 0) {
|
||||||
// TODO: remove this warn once this starts working
|
|
||||||
// this is mostly a sanity check / useful for metrics
|
|
||||||
console.warn('could not find a valid new connection!');
|
|
||||||
} else {
|
|
||||||
// choose a random connection
|
// choose a random connection
|
||||||
const newConn = randchoice(options);
|
const newConn = randchoice(options);
|
||||||
const newGene = mutateNewConn(newConn, assign_mag * randomNegPos());
|
const newGene = mutateNewConn(newConn, assign_mag * randomNegPos());
|
||||||
newGenome.push(newGene);
|
newGenome.push(newGene);
|
||||||
}
|
}
|
||||||
|
|
||||||
findAcyclicInternalNewConns(newGenome);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newGenome;
|
return newGenome;
|
||||||
|
Loading…
Reference in New Issue
Block a user