{"id":15547638,"url":"https://github.com/lucaangioloni/ant_simulation","last_synced_at":"2025-04-23T18:24:33.150Z","repository":{"id":111642483,"uuid":"376361552","full_name":"LucaAngioloni/ant_simulation","owner":"LucaAngioloni","description":"Ant Simulation using P5.js library. Demo: https://lucaangioloni.github.io/ant_simulation/","archived":false,"fork":false,"pushed_at":"2021-08-10T20:04:02.000Z","size":4027,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T02:22:18.419Z","etag":null,"topics":["ant-colony","p5js","simulation"],"latest_commit_sha":null,"homepage":"https://lucaangioloni.github.io/ant_simulation/","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/LucaAngioloni.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-12T18:41:58.000Z","updated_at":"2024-01-08T13:07:04.000Z","dependencies_parsed_at":"2023-05-25T00:30:18.984Z","dependency_job_id":null,"html_url":"https://github.com/LucaAngioloni/ant_simulation","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/LucaAngioloni%2Fant_simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaAngioloni%2Fant_simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaAngioloni%2Fant_simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaAngioloni%2Fant_simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucaAngioloni","download_url":"https://codeload.github.com/LucaAngioloni/ant_simulation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250488591,"owners_count":21438813,"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":["ant-colony","p5js","simulation"],"created_at":"2024-10-02T13:09:53.893Z","updated_at":"2025-04-23T18:24:33.134Z","avatar_url":"https://github.com/LucaAngioloni.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ant Simulation\n\nThis is an Ant simulation using P5.js\n\nThe Ants start from their colony and start searching for food. When they find it they take it back to the colony.\n\n## Demo\n\nA demo is available at: [https://lucaangioloni.github.io/ant_simulation/](https://lucaangioloni.github.io/ant_simulation/)\n\n![ant_gif](imgs/ant_gif.gif)\n\n## Code structure\n\nThe code is subdivided into 3 main js files located in the folder `js`:\n\n- `main.js`: where the P5.js functions are located and where the main logic is written\n\n- `ant.js`: where the `Ant` class is declared.\n\n- `food.js`: where the Food generators are implemented.\n\nTo change the hyperparameters go to `js/main.js` and change them.\n\n```javascript\n// Set maximum frame rate\nconst fr = 30;\n\n// Throttle the keyboard commands\nconst throttle_frames = 5;\nlet throttole = 0;\n\n// Init total food eaten to 0\nlet tot_food = 0;\n\n// Init Parameters and Variables ------------------------------------\nconst background_color = \"#D4B59D\";\n\nconst food_rate = 60;\nconst food_refill = 2;\nconst food_locations = 3;\nconst food_quantity = 20;\nconst food_radius = 10;\nconst food_color = \"#D5EFD5\";\nconst food_stroke = \"#D5EFD5\";\n\nconst ant_number = 100;\nconst ant_radius = 8;\nconst ant_color = \"#572D15\";\nconst ant_stroke = \"#572D15\";\nconst ant_food_color = \"#B64D3A\";\nconst ant_speed = 4;\n\nlet do_pheromones = false;\nlet do_pheromone_draw = false;\n\nlet momentum; // memory\nlet randomness;\nlet home_coeff;\nlet food_coeff;\n\nfunction set_normal_coeff() {\n  momentum = 0.65;\n  randomness = 0.15;\n  home_coeff = 0.2;\n  food_coeff = 0.2;\n}\n\nfunction set_pheromones_coeff() {\n  momentum = 0.2;\n  randomness = 0.2;\n  home_coeff = 0.7;\n  food_coeff = 0.4;\n}\n\nconst pheromones_range = 50;\nconst pheromones_resolution = 10;\nconst pheromones_food_ttl = 50000;\nconst pheromones_home_ttl = 50000 * 5;\nconst home_decay = 0.99;\nconst food_decay = 0.99;\nconst field_of_view = Math.PI / 4;\n\nconst home_radius = 25;\nconst home_color = \"#B64D3A\";\n```\n\n### Pheromones\n\nTo activate the \"pheromone\" mode change these to true:\n\n```javascript\nconst do_pheromones = true;\nconst do_pheromone_draw = true;\n```\n\nOr use the provided keyboard commands:\n\n- **shift** key to toggle the pheromones mode.\n- **D** key to toggle the pheromone drawing feature.\n\nThis feature needs to be tuned to work well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaangioloni%2Fant_simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucaangioloni%2Fant_simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaangioloni%2Fant_simulation/lists"}