generated from michael/webpack-base
NEATSnakeBrain rename
This commit is contained in:
parent
08c9a27266
commit
72a761eb3d
@ -1,8 +1,9 @@
|
|||||||
import { Genome, NEATBrain } from './neat';
|
import { Genome } from './neat';
|
||||||
import { BOARD_SQUARES } from './canvas';
|
import { BOARD_SQUARES } from './canvas';
|
||||||
import { vec2, Vec2 } from './game-engine';
|
import { vec2, Vec2 } from './game-engine';
|
||||||
import { completeBipartiteEdges } from './network';
|
import { completeBipartiteEdges } from './network';
|
||||||
import { Snake, SnakeGameState } from './types';
|
import { Snake, SnakeGameState } from './types';
|
||||||
|
import { NEATBrain } from './neat-brain';
|
||||||
|
|
||||||
function isOutOfBounds(square: Vec2) {
|
function isOutOfBounds(square: Vec2) {
|
||||||
return square.x < 0 || square.x >= BOARD_SQUARES || square.y < 0 || square.y >= BOARD_SQUARES;
|
return square.x < 0 || square.x >= BOARD_SQUARES || square.y < 0 || square.y >= BOARD_SQUARES;
|
||||||
@ -54,7 +55,7 @@ const BASE_GENOME_SNAKE_BRAIN_NEAT = _BASE_GENOME_SNAKE_BRAIN_NEAT_EDGES.map((e,
|
|||||||
data: { innovation: -_BASE_GENOME_SNAKE_BRAIN_NEAT_EDGES.length + idx, weight: 0, enabled: true },
|
data: { innovation: -_BASE_GENOME_SNAKE_BRAIN_NEAT_EDGES.length + idx, weight: 0, enabled: true },
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export class SnakeBrainNEAT {
|
export class NEATSnakeBrain {
|
||||||
brain: NEATBrain;
|
brain: NEATBrain;
|
||||||
|
|
||||||
constructor(brain: NEATBrain) {
|
constructor(brain: NEATBrain) {
|
||||||
@ -63,7 +64,7 @@ export class SnakeBrainNEAT {
|
|||||||
|
|
||||||
static fromGenome(genome: Genome) {
|
static fromGenome(genome: Genome) {
|
||||||
const brain = NEATBrain.fromGenome(genome);
|
const brain = NEATBrain.fromGenome(genome);
|
||||||
return new SnakeBrainNEAT(brain);
|
return new NEATSnakeBrain(brain);
|
||||||
}
|
}
|
||||||
|
|
||||||
think(state: SnakeGameState): Vec2 | 'dead' {
|
think(state: SnakeGameState): Vec2 | 'dead' {
|
Loading…
Reference in New Issue
Block a user