Options
All
  • Public
  • Public/Protected
  • All
Menu

Marble Evolution

Index

Enumerations

Classes

Interfaces

Variables

General utils Functions

Genetic Algorithm Functions

Object literals

Variables

Const CSS_STYLE_HIDDEN

CSS_STYLE_HIDDEN: "none" = "none"

Const CSS_STYLE_VISIBLE

CSS_STYLE_VISIBLE: "" = ""

Const HTML_CHECKBOX_HUMAN_MODE

HTML_CHECKBOX_HUMAN_MODE: HTMLInputElement = <HTMLInputElement>document.getElementById('human-mode')

Const HTML_CHECKBOX_VERBOSE_MODE

HTML_CHECKBOX_VERBOSE_MODE: HTMLInputElement = <HTMLInputElement>document.getElementById('verbose-mode')

Const HTML_INPUT_ANGLE_RANGE_LOWER

HTML_INPUT_ANGLE_RANGE_LOWER: HTMLInputElement = <HTMLInputElement>document.getElementById('angle-mutation-range-lower')

Const HTML_INPUT_ANGLE_RANGE_UPPER

HTML_INPUT_ANGLE_RANGE_UPPER: HTMLInputElement = <HTMLInputElement>document.getElementById('angle-mutation-range-upper')

Const HTML_INPUT_FATHER_ANGLE

HTML_INPUT_FATHER_ANGLE: HTMLInputElement = <HTMLInputElement>document.getElementById('father-genes-angle')

Const HTML_INPUT_FATHER_POWER

HTML_INPUT_FATHER_POWER: HTMLInputElement = <HTMLInputElement>document.getElementById('father-genes-power')

Const HTML_INPUT_INDIVIDUAL_COUNT

HTML_INPUT_INDIVIDUAL_COUNT: HTMLInputElement = <HTMLInputElement>document.getElementById('individual-count')

Const HTML_INPUT_MUTATION_ANGLE

HTML_INPUT_MUTATION_ANGLE: HTMLInputElement = <HTMLInputElement>document.getElementById('angle-mutation-probability')

Const HTML_INPUT_MUTATION_GENERAL

HTML_INPUT_MUTATION_GENERAL: HTMLInputElement = <HTMLInputElement>document.getElementById('general-mutation-probability')

Const HTML_INPUT_MUTATION_POWER

HTML_INPUT_MUTATION_POWER: HTMLInputElement = <HTMLInputElement>document.getElementById('power-mutation-probability')

Const HTML_INPUT_POWER_RANGE_LOWER

HTML_INPUT_POWER_RANGE_LOWER: HTMLInputElement = <HTMLInputElement>document.getElementById('power-mutation-range-lower')

Const HTML_INPUT_POWER_RANGE_UPPER

HTML_INPUT_POWER_RANGE_UPPER: HTMLInputElement = <HTMLInputElement>document.getElementById('power-mutation-range-upper')

Const HTML_SELECTOR_CLASS_AI_CONFIGURATION

HTML_SELECTOR_CLASS_AI_CONFIGURATION: ".configuration.ai" = ".configuration.ai"

Const HTML_SELECTOR_CLASS_CONFIGURATION

HTML_SELECTOR_CLASS_CONFIGURATION: ".configuration" = ".configuration"

Const HTML_SELECTOR_ID_CONSOLE_WRAPPER

HTML_SELECTOR_ID_CONSOLE_WRAPPER: "verbose-console-wrapper" = "verbose-console-wrapper"

Const HTML_SELECTOR_ID_STATS_AI

HTML_SELECTOR_ID_STATS_AI: "stats-ai-mode" = "stats-ai-mode"

Const HTML_SELECTOR_ID_STATS_HUMAN

HTML_SELECTOR_ID_STATS_HUMAN: "stats-human-mode" = "stats-human-mode"

Const HTML_SELECTOR_TAG_NUMBER_INPUT

HTML_SELECTOR_TAG_NUMBER_INPUT: "input[type=number]" = "input[type=number]"

Const HTML_TAG_HUMAN_MODE

HTML_TAG_HUMAN_MODE: HTMLElement = document.getElementById('human-mode-tag')

Const HTML_TAG_VERBOSE_CONSOLE_DISABLED

HTML_TAG_VERBOSE_CONSOLE_DISABLED: HTMLElement = document.getElementById('verbose-console-disabled-tag')

Const HTML_TEXT_AI_AVERAGE_DISTANCE

HTML_TEXT_AI_AVERAGE_DISTANCE: HTMLElement = document.getElementById('distance-avg-last-iteration')

Const HTML_TEXT_AI_BEST_DISTANCE_LAST

HTML_TEXT_AI_BEST_DISTANCE_LAST: HTMLElement = document.getElementById('distance-best-last-iteration')

Const HTML_TEXT_AI_BEST_DISTANCE_OVERALL

HTML_TEXT_AI_BEST_DISTANCE_OVERALL: HTMLElement = document.getElementById('distance-best-overall')

Const HTML_TEXT_AI_ITERATION_COUNT

HTML_TEXT_AI_ITERATION_COUNT: HTMLElement = document.getElementById('iteration-number')

Const HTML_TEXT_HUMAN_CURRENT_BEST

HTML_TEXT_HUMAN_CURRENT_BEST: HTMLElement = document.getElementById('human-current-best')

Const HTML_TEXT_HUMAN_DISTANCE

HTML_TEXT_HUMAN_DISTANCE: HTMLElement = document.getElementById('human-distance')

Const HTML_TEXT_HUMAN_TRY_COUNT

HTML_TEXT_HUMAN_TRY_COUNT: HTMLElement = document.getElementById('try-number')

Const HTML_TEXT_LEVEL_NAME

HTML_TEXT_LEVEL_NAME: HTMLElement = document.getElementById('levelName')

Const HTML_VERBOSE_CONSOLE

HTML_VERBOSE_CONSOLE: HTMLElement = document.getElementById('verbose-console')

Const HTML_VERBOSE_CONSOLE_WRAPPER

HTML_VERBOSE_CONSOLE_WRAPPER: HTMLElement = document.getElementById('verbose-console-wrapper')

Const PRECISION

PRECISION: 4 = 4

Let aiBestDistance

aiBestDistance: number

Holds the best distance to the goal in the ai mode. (i.e. not in human mode - performed by the genetic algorithm).

note

The lower the distance is, the better.

Const columnWidth

columnWidth: number = document.getElementById('game-column').offsetWidth

Let demo

demo: MarbleEvolution = null

Let game

game: MarbleEvolution = null

Actual phaser game object.

Const gameSize

gameSize: 500 = 500

Let humanBestDistance

humanBestDistance: number

Holds the best distance to the goal in the human mode.

note

The lower the distance is, the better.

Let iterationCounter

iterationCounter: number

Holds the number of tries/iterations performed.

If the human mode is enabled, the number corresponds to the tries made by the human player, if the human mode is disabled, the number corresponds to the population-iteration of the genetic algorithm.

Let population

population: MarbleIndividual[]

List containing the individuals of the current iteration.

Let scenes

scenes: ScenePlugin

The scenes to which the utils belongs.

note

From the official documentation of Phaser.Scenes.ScenePlugin:

A reference to the Scene Manager Plugin. This property will only be available if defined in the Scene Injection Map.

Let zoomFactor

zoomFactor: number = 1

General utils Functions

appendLineToVerboseConsole

  • appendLineToVerboseConsole(text: string): void
  • Appends the given text in a new line to the verbose console.

    Parameters

    • text: string

      Text which should be appended to the console.

    Returns void

appendToVerboseConsole

  • appendToVerboseConsole(text: string): void
  • Appends the given text to the verbose console.

    Parameters

    • text: string

      Text which should be appended to the console.

    Returns void

convertToPercentage

  • convertToPercentage(value: number, precision?: number): number
  • Converts a given value in the range from 0 to 100 to a percentage value used in the configuration (range 0 to 1) with a given precision.

    Parameters

    • value: number

      The value which should be converted to a percentage value. Must be between 0 and 100.

    • Default value precision: number = 4

      The precision of the percentage (i.e. how many places after the decimal point).

    Returns number

fillHTMLWithConfiguration

  • fillHTMLWithConfiguration(): void
  • Fills the HTML-elements with the configuration values.

    Returns void

initializeConfiguration

  • initializeConfiguration(configText: string): void
  • Performs any work needed for initializing the ConfigurationHandler.

    note

    Must only be called once.

    Parameters

    • configText: string

      The content of the configuration.

    Returns void

initializeEventListeners

  • initializeEventListeners(): void
  • Initializes all event listeners.

    note

    Must only be called once otherwise the game breaks.

    Returns void

resetForNewGame

  • resetForNewGame(): void
  • Performs any actions needed to restart a new game (i.e. resets all variables).

    Returns void

setScenes

  • setScenes(newScenes: ScenePlugin): void
  • Sets the scenes.

    note

    Must be called before referencing to the scenes.

    Parameters

    • newScenes: ScenePlugin

      The new scenes.

    Returns void

updateAIDistance

  • updateAIDistance(averageDistance: number, bestDistance: number): void
  • Updates the necessary HTMLElements with the new distance. Note: Must only be called once the current iteration has come to a complete stop.

    Parameters

    • averageDistance: number

      Number holding the average distance to the goal of the population of the last iteration.

    • bestDistance: number

      Number holding the best distance to the goal of the population of the last iteration.

    Returns void

updateConfigurationFromHTML

  • updateConfigurationFromHTML(): void
  • Updates the configuration handler with the new values from the HTML input elements.

    Returns void

updateHumanDistance

  • updateHumanDistance(newDistance: number, final?: boolean): void
  • Updates the necessary HTMLElements with the new distance.

    Parameters

    • newDistance: number

      New distance in pixels.

    • Default value final: boolean = false

      If true the humanBestDistance will also be updated, if necessary, else not. Should only be true if the marble has stopped.

    Returns void

updateIterationCount

  • updateIterationCount(iterationDelta?: number): void
  • Updates the iterationCounter and all relevant HTMLElements to the updated iteration count.

    Parameters

    • Default value iterationDelta: number = 1

      The delta by which the iteration count should increase/decrease.

    Returns void

vectorToPointer

  • vectorToPointer(pointer: Pointer, startPoint?: Point): Vector2
  • Sets up a vector pointing from a given start point to the current pointer position (mostly the mouse).

    Parameters

    • pointer: Pointer

      The pointer which is currently active.

    • Default value startPoint: Point = Coordinate.of(ConfigurationHandler.getLevel().marble.position).toPoint()

      Start point of the vector.

    Returns Vector2

    Returns the created vector.

writeToVerboseConsole

  • writeToVerboseConsole(text: string): void
  • Writes the given text to the verbose console.

    note

    Erases any previous text.

    Parameters

    • text: string

      Text which should be written to the console.

    Returns void

Genetic Algorithm Functions

allStopped

  • allStopped(): boolean
  • Checks whether all individuals are stopped or not.

    Returns boolean

    Returns true if all individuals have stopped, else false.

computeAvgDistance

  • computeAvgDistance(): number
  • Computes the average distance to the goal of the current population.

    Returns number

    Returns the average distance to the goal.

getBestDistance

  • getBestDistance(): number
  • Fetches the best (i.e. lowest) distance to the goal of the current population.

    Returns number

    Returns the best (i.e. lowest) to the goal.

initializeAlgorithm

iterationFinished

  • iterationFinished(): void
  • Performs action needed to conclude an iteration.

    Calls the fitness function for each individual and generates based on the fitness values a new generation.

    see

    Configuration: Please refer to the configuration for limitations and probabilities that may apply.

    Returns void

killAll

  • killAll(): void

randomSelect

  • Performs the random select of an individual for the reproduction.

    The random select uses the fitness function of each individual to select among the population one of the fittest individuals.

    The individual gets chosen according to the Fitness proportionate selection also known as roulette wheel selection algorithm (See the Wikipedia article for further details).

    That means, that the individual with the highest fitness has the highest probability that it will be chosen. Nevertheless, also a 'non-fit-individual' has a, of course small, chance that it will be selected for reproduction.

    Parameters

    • fitnessValues: number[]

      List containing the fitness values of all individuals of the population. The first value of the fitness list is the fitness value of the first individual in the population, the second from the second and so forth.

    Returns MarbleIndividual

    The individual which is chosen for reproduction.

startIteration

  • startIteration(): void

stopIteration

  • stopIteration(): void

Object literals

Const config

config: object

Configuration for the gaaaaame.

backgroundColor

backgroundColor: string = "#eee"

parent

parent: string = "game"

scene

scene: Main[] = [Main]

title

title: string = "Marble Evolution"

type

type: number = Phaser.AUTO

physics

physics: object

default

default: string = "matter"

matter

matter: object

debug

debug: false = false

gravity

gravity: object

x

x: number = 0

y

y: number = 0

scale

scale: object

height

height: number = gameSize

width

width: number = gameSize

zoom

zoom: number = zoomFactor

Generated using TypeDoc