{"id":13793725,"url":"https://github.com/jonatan5524/SnakeAI","last_synced_at":"2025-05-12T20:31:11.531Z","repository":{"id":148374221,"uuid":"295199550","full_name":"jonatan5524/SnakeAI","owner":"jonatan5524","description":"Snake game self played with genetic algorithm and neural network - NEAT","archived":false,"fork":false,"pushed_at":"2021-09-11T17:15:18.000Z","size":592,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"gh-pages","last_synced_at":"2024-11-18T08:55:25.655Z","etag":null,"topics":["javascript","neat-algorithm"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonatan5524.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-09-13T17:13:25.000Z","updated_at":"2023-03-01T11:41:28.000Z","dependencies_parsed_at":"2023-05-19T22:15:45.873Z","dependency_job_id":null,"html_url":"https://github.com/jonatan5524/SnakeAI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonatan5524%2FSnakeAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonatan5524%2FSnakeAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonatan5524%2FSnakeAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonatan5524%2FSnakeAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonatan5524","download_url":"https://codeload.github.com/jonatan5524/SnakeAI/tar.gz/refs/heads/gh-pages","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253816714,"owners_count":21968871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","neat-algorithm"],"created_at":"2024-08-03T23:00:30.176Z","updated_at":"2025-05-12T20:31:10.283Z","avatar_url":"https://github.com/jonatan5524.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# SnakeAI\nSnake game self played with genetic algorithm and neural network - NEAT. the game is developed using p5.js framework for the canvas and the game and the tensorflow.js library for the neural network.\n\n## Live demo:\n\nhttps://jonatan5524.github.io/SnakeAI/Snake\n\n## Installation:\n\n### Required:\n\n    npm\n\n### Installing:\n    git clone https://github.com/jonatan5524/SnakeAI\n    cd SnakeAI\n    npm install -g p5-manager\n    p5 server\n\n## Usage:\nAfter running the local server for the snake AI, go to the address with the port that presented in the terminal and to the path Snake\n\n## Example:\n![example](README_Images/Capture.PNG)\n\n## Algorithm:\nthere are multiple snake game, as the number of population count, for each game there is a snake and an apple with its own score, for each snake there is a \"brain\" - a neural network that decide each turn what move to play.\n\n### Neural Network\n\ninputs:\n* 0 or 1 if the block on the left is free\n* 0 or 1 if the block on the right is free\n* 0 or 1 if the block above is free\n* 0 or 1 if the block below is free\n* the angle to the apple\n* suggestion what action to do\n\nthe suggestion is decided by where is the apple where need to turn.\n\noutputs:\n* turn left\n* turn right\n* defualt (dont turn)\n\n### Genetic Algorithm \n* population: array of snake games.\n* fitness: gitness is increased when the snake as eaten an apple and increase when the snake is moving toward the snake and decrease when the snake moving ןn the opposite direction of the apple.\n* mutation: changing the weight of on the neural network by mutation rate.\n* selection: the parent for the next generation is selected by the highest fitness.\n\nthere is one more factor for the snake, hunger, each turn the snake hunger is decreased and increased when the snake is eating an apple. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonatan5524%2FSnakeAI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonatan5524%2FSnakeAI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonatan5524%2FSnakeAI/lists"}