{"id":16641824,"url":"https://github.com/samthor/traingraph","last_synced_at":"2025-09-05T03:33:21.312Z","repository":{"id":66115182,"uuid":"376240179","full_name":"samthor/traingraph","owner":"samthor","description":"Train graph 🚂🚋🚋🚋","archived":false,"fork":false,"pushed_at":"2021-08-06T06:10:51.000Z","size":237,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-12T05:29:46.888Z","etag":null,"topics":["choo","choochoo"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samthor.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-12T08:31:53.000Z","updated_at":"2021-08-02T08:00:51.000Z","dependencies_parsed_at":"2023-03-10T23:38:05.505Z","dependency_job_id":null,"html_url":"https://github.com/samthor/traingraph","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/samthor/traingraph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Ftraingraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Ftraingraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Ftraingraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Ftraingraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samthor","download_url":"https://codeload.github.com/samthor/traingraph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samthor%2Ftraingraph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273707323,"owners_count":25153724,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["choo","choochoo"],"created_at":"2024-10-12T07:47:59.906Z","updated_at":"2025-09-05T03:33:21.278Z","avatar_url":"https://github.com/samthor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Work in progress train graph + game demo on top.\n\n# Play\n\nFetch, run `npm install`, and run with `dhost` or something that will rewrite your ESM imports:\n\n```js\ndhost -m\n```\n\nFocus and tap \"a\" to add a line.\nUse your mouse and click to finish the line (potentially joining to other lines).\n\nTap \"s\" to add a train (it's basically a snake).\nTrains just bounce around forever.\n\nTap \"p\" to start pathfinding when focused on a line.\nThis is just a demo and nothing uses this yet.\n\n## Configure\n\nSome constants are in \"src/shared.js\", around units and so on.\n\n# Design\n\nThe `Game` class uses `GraphType` for its graph code, as well as `SnakeMan` to manage trains.\nTrains are basically snakes, and move by growing on one side and shrinking on another.\n\n## Graph\n\nThis is based on a generic `GraphType` interface (and `Graph` implementation in \"src/graph.js\") which contains edges and nodes.\n\n* Each edge has at least two nodes (end nodes) and can be split by adding further nodes.\n\n* These edges don't exist in physical space, and can be joined in non-euclidian ways, although do have physical length (as an integer).\n\n* Nodes can be merged with other nodes (although they don't _have_ to \"pair\"\u0026mdash;think a line crossing over another).\n  * They can be paired via `Graph.join`, which creates a path between them (in the game, this is where a red line appear to show connectivity).\n  * Nodes will be on at least one edge, but perhaps multiple.\n\n* There are some restrictions on graph operations for sanity.\n  * Nodes cannot exist at multiple places on the same edge.\n  * Edges can only be joined together at one place.\n  * Because of this, it's possible to unambiguously match a segment via a request for two distinct nodes on the same edge.\n\n# Goals\n\nThe SVG renderer is really just a demo over the graph code.\nI have a personal goal to write a train game\u0026mdash;while this might be used for casual games, I'm inspiring more from Factorio or similar in terms of the feature set.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamthor%2Ftraingraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamthor%2Ftraingraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamthor%2Ftraingraph/lists"}