Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Chrispresso/SnakeAI
/ functions
Functions
89 in github.com/Chrispresso/SnakeAI
⨍
Functions
89
◇
Types & classes
12
↓ 26 callers
Method
_create_label_widget_in_grid
(self, string_label: str, font: QtGui.QFont, grid: QtWidgets.QGridLayou
snake_app.py:464
↓ 7 callers
Method
copy
(self)
misc.py:16
↓ 4 callers
Method
_create_label_widget
(self, string_label: str, font: QtGui.QFont)
snake_app.py:457
↓ 4 callers
Function
gaussian_mutation
Perform a gaussian mutation for each gene in an individual with probability, prob_mutation. If mu and sigma are defined then the gaussian
genetic_algorithm/mutation.py:10
↓ 4 callers
Function
random_uniform_mutation
Randomly mutate each gene in an individual with probability, prob_mutation. If a gene is selected for mutation it will be assigned a value
genetic_algorithm/mutation.py:34
↓ 2 callers
Method
__init__
(self, settings, show=True, fps=200)
snake_app.py:26
↓ 2 callers
Method
_calc_distance
(self, x1, x2, y1, y2)
snake_app.py:606
↓ 2 callers
Method
calculate_fitness
(self)
snake.py:130
↓ 2 callers
Method
feed_forward
(self, X: np.ndarray)
neural_network.py:43
↓ 2 callers
Method
generate_apple
(self)
snake.py:256
↓ 2 callers
Function
get_activation_by_name
(name: str)
neural_network.py:68
↓ 2 callers
Function
single_point_binary_crossover
(parent1: np.ndarray, parent2: np.ndarray, major='r')
genetic_algorithm/crossover.py:38
↓ 2 callers
Method
update
(self)
snake.py:294
↓ 1 callers
Function
_calc_stats
(data: List[Union[int, float]])
snake_app.py:614
↓ 1 callers
Method
_crossover
(self, parent1_weights: np.ndarray, parent2_weights: np.ndarray, parent1_bias: np.ndarray,
snake_app.py:270
↓ 1 callers
Method
_increment_generation
(self)
snake_app.py:265
↓ 1 callers
Method
_is_apple_location
(self, position: Point)
snake.py:375
↓ 1 callers
Method
_is_body_location
(self, position: Point)
snake.py:378
↓ 1 callers
Method
_is_valid
Determine whether a given position is valid. Return True if the position is on the board and does not intersect the snake.
snake.py:381
↓ 1 callers
Method
_mutation
(self, child1_weights: np.ndarray, child2_weights: np.ndarray, child1_bias: np.ndarray, chi
snake_app.py:292
↓ 1 callers
Method
_vision_as_input_array
(self)
snake.py:227
↓ 1 callers
Method
_within_wall
(self, position: Point)
snake.py:251
↓ 1 callers
Method
draw_apple
(self, painter: QtGui.QPainter)
snake_app.py:573
↓ 1 callers
Method
draw_border
(self, painter: QtGui.QPainter)
snake_app.py:498
↓ 1 callers
Method
draw_snake
(self, painter: QtGui.QPainter)
snake_app.py:512
↓ 1 callers
Function
elitism_selection
(population: Population, num_individuals: int)
genetic_algorithm/selection.py:8
↓ 1 callers
Method
from_dict
(cls, d: Dict[str, int])
misc.py:28
↓ 1 callers
Method
init_snake
Initialize teh snake. starting_direction: ('u', 'd', 'l', 'r') direction that the snake should start facing. Whatever
snake.py:269
↓ 1 callers
Method
init_velocity
(self, starting_direction, initial_velocity: Optional[str] = None)
snake.py:402
↓ 1 callers
Method
init_window
(self)
snake_app.py:95
↓ 1 callers
Method
look
(self)
snake.py:163
↓ 1 callers
Method
look_in_direction
(self, slope: Slope)
snake.py:174
↓ 1 callers
Method
move
(self)
snake.py:304
↓ 1 callers
Method
next_generation
(self)
snake_app.py:175
↓ 1 callers
Function
roulette_wheel_selection
(population: Population, num_individuals: int)
genetic_algorithm/selection.py:12
↓ 1 callers
Method
show_network
(self, painter: QtGui.QPainter)
nn_viz.py:32
↓ 1 callers
Method
to_dict
(self)
misc.py:21
↓ 1 callers
Method
update
(self)
snake_app.py:117
Method
__eq__
(self, other: Union['Point', Tuple[int, int]])
misc.py:31
Method
__hash__
(self)
misc.py:54
Method
__init__
(self, parent, snake: Snake)
nn_viz.py:10
Method
__init__
(self, rise: int, run: int)
misc.py:6
Method
__init__
(self, x: int, y: int)
misc.py:12
Method
__init__
(self, dist_to_wall: Union[float, int], dist_to_apple: Union[float, int],
snake.py:18
Method
__init__
(self, wall_location: Point, apple_location: Optional[Point] = None,
snake.py:29
Method
__init__
(self, board_size: Tuple[int, int], chromosome: Optional[Dict[str, List[np.ndarray]]] = None
snake.py:40
Method
__init__
(self, parent, settings)
snake_app.py:327
Method
__init__
(self, parent, board_size=(50, 50), snake=None)
snake_app.py:475
Method
__init__
(self, layer_nodes: List[int], hidden_activation: ActivationFunction,
neural_network.py:16
Method
__init__
(self)
genetic_algorithm/individual.py:6
Method
__init__
(self, individuals: List[Individual])
genetic_algorithm/population.py:7
Method
__rsub__
(self, other: Tuple[int, int])
misc.py:49
Method
__str__
(self)
misc.py:57
Method
__sub__
(self, other: Union['Point', Tuple[int, int]])
misc.py:38
Method
_draw_line_to_apple
(painter: QtGui.QPainter, start_x: int, start_y: int, drawable_vision: DrawableVision)
snake_app.py:523
Method
_draw_line_to_self
(painter: QtGui.QPainter, start_x: int, start_y: int, drawable_vision: DrawableVision)
snake_app.py:530
Method
average_fitness
(self)
genetic_algorithm/population.py:27
Method
calculate_fitness
(self)
genetic_algorithm/individual.py:10
Method
calculate_fitness
(self)
genetic_algorithm/population.py:42
Function
cauchy_mutation
(individual: np.ndarray, scale: float)
genetic_algorithm/mutation.py:65
Method
chromosome
(self)
snake.py:137
Method
chromosome
(self)
genetic_algorithm/individual.py:33
Method
decode_chromosome
(self)
snake.py:151
Method
decode_chromosome
(self)
genetic_algorithm/individual.py:28
Method
encode_chromosome
(self)
snake.py:141
Method
encode_chromosome
(self)
genetic_algorithm/individual.py:24
Function
exponential_mutation
(chromosome: np.ndarray, xi: Union[float, np.ndarray], prob_mutation: float)
genetic_algorithm/mutation.py:68
Method
fitness
(self)
snake.py:127
Method
fitness
(self)
genetic_algorithm/individual.py:15
Method
fittest_individual
(self)
genetic_algorithm/population.py:35
Method
get_fitness_std
(self)
genetic_algorithm/population.py:46
Method
keyPressEvent
(self, event: QtGui.QKeyEvent)
snake_app.py:595
Function
load_snake
(population_folder: str, individual_name: str, settings: Optional[Union[Dict[str, Any], str]] = None)
snake.py:453
Function
load_stats
(path_to_stats: str, normalize: Optional[bool] = True)
snake_app.py:661
Function
mmo_mutation
(chromosome: np.ndarray, prob_mutation: float)
genetic_algorithm/mutation.py:96
Method
new_game
(self)
snake_app.py:487
Method
num_genes
(self)
genetic_algorithm/population.py:19
Method
num_individuals
(self)
genetic_algorithm/population.py:11
Method
paintEvent
(self, event: QtGui.QPaintEvent)
nn_viz.py:21
Method
paintEvent
(self, event: QtGui.QPaintEvent)
snake_app.py:585
Function
save_snake
(population_folder: str, individual_name: str, snake: Snake, settings: Dict[str, Any])
snake.py:412
Function
save_stats
(population: Population, path_to_dir: str, fname: str)
snake_app.py:623
Function
simulated_binary_crossover
This crossover is specific to floating-point representation. Simulate behavior of one-point crossover for binary representations. Fo
genetic_algorithm/crossover.py:4
Method
softmax
(self, X: np.ndarray)
neural_network.py:65
Function
tournament_selection
(population: Population, num_individuals: int, tournament_size: int)
genetic_algorithm/selection.py:26
Function
uniform_binary_crossover
(parent1: np.ndarray, parent2: np.ndarray)
genetic_algorithm/crossover.py:28
Function
uniform_mutation_with_respect_to_best_individual
Ranomly mutate each gene in an individual with probability, prob_mutation. If a gene is selected for mutation it will nudged towards the ge
genetic_algorithm/mutation.py:54
Method
update
(self)
nn_viz.py:29
Method
update
(self)
snake_app.py:490