{"id":18790559,"url":"https://github.com/lubosgarancovsky/lifesim","last_synced_at":"2026-02-12T22:04:32.365Z","repository":{"id":155428910,"uuid":"534395780","full_name":"lubosgarancovsky/LifeSim","owner":"lubosgarancovsky","description":"Simple ecosystem simulation made with Typescript and HTML canvas","archived":false,"fork":false,"pushed_at":"2025-01-15T20:19:29.000Z","size":204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-13T03:43:02.405Z","etag":null,"topics":["canvas","decision-tree","pathfinding","simulation","typescript"],"latest_commit_sha":null,"homepage":"https://lubosgarancovsky.github.io/LifeSim/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lubosgarancovsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-09-08T21:15:28.000Z","updated_at":"2025-01-15T20:19:30.000Z","dependencies_parsed_at":"2025-02-19T18:42:56.079Z","dependency_job_id":null,"html_url":"https://github.com/lubosgarancovsky/LifeSim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lubosgarancovsky/LifeSim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lubosgarancovsky%2FLifeSim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lubosgarancovsky%2FLifeSim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lubosgarancovsky%2FLifeSim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lubosgarancovsky%2FLifeSim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lubosgarancovsky","download_url":"https://codeload.github.com/lubosgarancovsky/LifeSim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lubosgarancovsky%2FLifeSim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29382901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T20:34:40.886Z","status":"ssl_error","status_checked_at":"2026-02-12T20:23:00.490Z","response_time":55,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["canvas","decision-tree","pathfinding","simulation","typescript"],"created_at":"2024-11-07T21:12:42.277Z","updated_at":"2026-02-12T22:04:32.334Z","avatar_url":"https://github.com/lubosgarancovsky.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LifeSim\nSimple ecosystem simulation, where actors collect food, water and procreate.\n\n\n## Description\n\n### World creation\nIn the beginning, a world is created randomly using **Perlin's noise**. It consists of ground and water tiles.\nSources of food are randomly distributed between the grass tiles.\n\nFood sources ( green circles ) have a fixed amout of food they can hold.\nWhen they are eaten, they shrink in size and slowly regrow back to their original size and original amount.\n\n### Actors\nActors, who are put into this world then wander around, collecting food, water and procreating. They have an inventory with maximum amount of food and water they can hold.\nWhen they have nothing to do and inventory is not full, they collect resources around them and store them for a difficult time that might come.\nActors have 3 needs:\n    + Hunger\n    + Thirst\n    + Mating urge\n\nHunger is the most important need, and when it gets over 50%, actor starts looking for food, or eating from inventory, if it has a food in it.\nThirst comes next with the same process, and mating urge kicks makes actor look for mating partner when bigger than 90%.\n\nActors needs build up at speed that is determined by their genetic information. The first actors that appear randomly in the beginning of a simulation have randomized genes,\nbut actors who are born after succesfull mating have their genes calculated based on a genes of the parents.\n\nGenes also contain information about fertility, viewrange and speed.\n\nEvery actor has a randomly chosen **name**, **id** and a **gender**.\n\n### Ageing\nActors start with an age of 0, and the age is slowly incremented every update.\nThey became adult at 18, and will become able to mate.\n\nWith increasing age, a chance for an actor to die also increases, and no actor can live longer than 120 years.\n\n### Eating\nFood resources have an amount and maximum amount of food they can carry. If an actors hunger reaches 50%, a choice is made. If an actor has a food in his inventory, he will eat it on the spot and\nthe amout he eats is subtracted from the inventory. If his hunger is at 58%, he will eat up to 58 units of food.\n\nIf the actors inventory is empty, he will look for sources of food within his view range. When a food source is found, he will navigate towards it and if the source is reached, he starts eating.\nWhen the actor eats, every frame a little amout of food is transfered from its source to the actor.\nIf a food supply gets depleted or if actors hunger is fully satisfied, he stops eating and starts wandering around.\nFood source then start slowly growing back to its maximum amount.\n\n### Drinking\nDrinking works in very similar way as eating does, but the source of water is a tile of the world grid marked as water tile. It has no maximum amount and it is drank from until actors thirst\nis fully satisfied.\n\nActors are forbidden to navigate in the water, so when they are thirsty, they navigate towards the ground tile neighbouring the water tile, they are about to drink from.\n\n### Mating\nWhen two adult actors reach 90% of mating urge, and the find each other. The find a tile within their viewrange and move towards it. When the target tile is reached, they start the proccess of mating. After mating, a female actor has a chance to get pregnant. If a female gets pregnant, after a while she will spawn from 1 to 3 children, while 1 being most common and 3 being very rare.\nChildren then continue on ther own.\n\n### Collecting resources\nActors have an inventory with some space for food and water. If the actors has no needs to satify at the moment. He starts looking for closest resources and collects them into his inventory.\nWhen he has a need to eat or drink, he first looks into his inventory for resources. Only if its empty, he starts looking outside for new resources.\n\n### Movement\nFor movement, actors use an **Astar pathfinding** alghoritm. They navigate a subgrid of a world grid.\nThis subgrid is calculated based on a `viewrange` of an actor. If a viewrange is 4, then the viewrange subgrid is (4 + 1) * (4 + 1) tiles big and centered around an actor.\nThis means, that in this situation, actor is able to see 4 tiles to the left 4 tiles to the right, 4 tiles up, and 4 tiles down. The extra tile in the equation is the one he is standing on.\n\nActors only see and can only interact with actors and resources withing the subgrd.\n\nAlso, they are only allowed to navigation the ground tiles, but they can see water tiles too, so they can find a water source.\nWhen actor has no food or water resource to move towards, or a partner to mate with, he starts moving randomly by choosing a random tile within its viewrange subgrid.\nEvery time he reaches this random tile, he chooses a new one. Position within the tile is also chosen randomly.\n\n### Decision making\nActors make their decisions using a simple **decision tree**.\n\n### HUD\nIf hud is enabled, it displayes the age and a name in the first row above every actor.\nCurrent action that is being performed is displayed below.\n\nOn the right of an actor, there are 3 bars indicating hunger, thirst and mating urge of an actor.\nProgress bar that shows the current state of an performed action is shown as a black bar below the actor event if HUD is disabled.\nChild actors have smaller radius that adult actors to make them easer to distinguish.\n\nAcors gender is displayed by a thin outline with **blue** color for **male** and **purple** for a **female**\n\n### UI\nAt the top of a screen, there is a black bar with a count of all actors in the scene.\nIn the right top corner. There are two buttons. The left button shows a screen with cards that hold informations about actors.\nRight button shows a screen with the settings. This allows user to change the behavior of a simulation. Debug mode can also be enabled here.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flubosgarancovsky%2Flifesim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flubosgarancovsky%2Flifesim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flubosgarancovsky%2Flifesim/lists"}