{"id":21201697,"url":"https://github.com/oleander/trainspotting","last_synced_at":"2026-04-25T08:32:57.258Z","repository":{"id":1322865,"uuid":"1267999","full_name":"oleander/Trainspotting","owner":"oleander","description":"Trainspotting using Java","archived":false,"fork":false,"pushed_at":"2011-02-01T20:06:32.000Z","size":464,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-17T05:09:11.478Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/oleander.png","metadata":{"files":{"readme":"README.markdown","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}},"created_at":"2011-01-18T18:24:32.000Z","updated_at":"2013-12-21T23:27:58.000Z","dependencies_parsed_at":"2022-08-16T13:05:20.696Z","dependency_job_id":null,"html_url":"https://github.com/oleander/Trainspotting","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oleander/Trainspotting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FTrainspotting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FTrainspotting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FTrainspotting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FTrainspotting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oleander","download_url":"https://codeload.github.com/oleander/Trainspotting/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FTrainspotting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32255255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T04:23:17.126Z","status":"ssl_error","status_checked_at":"2026-04-25T04:21:53.360Z","response_time":59,"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":[],"created_at":"2024-11-20T20:10:35.076Z","updated_at":"2026-04-25T08:32:57.227Z","avatar_url":"https://github.com/oleander.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trainspotting\n\n## Post-submit found errors (PLEASE READ)\n\nUnfortunately our submitted code had a minor error in it. The trains don't sleep\nenough when they turn around. We would highly appreciate it if you could\nmake this very minor edit yourself, instead of instantly rejecting the solution.\n\nIn Train.java, please change **line 111*** from\n\n\t\tsleep(1000);\n\nto \n\n\t\tsleep(3000);\n\nOr something like that.\n\n## READ FIRST\n\nPlease consider reading this README-file at our github repo, where it is\nformatted in a more pleasent way.\n\n[Click here](https://github.com/oleander/Trainspotting) \n\n## Authors\n\nArash Rouhani, cid rarash\n\nLinus Oleander, cid oleander\n\n## Background\n\nWe've implemented trainspotting generally. That means we have not hardcoded anything.\nConsequently, the program must read the train-file, and it must be passed as an argument.\n\nOur solution can handle almost any map, as long the sensors are sensibly placed and the\nmax velocities are reasonable.\n\n## Sensors\n\nWe first specify how our general solution expects the sensor placement, then we\ncontinue to discuss the sensor placement for the particular map (that was the actual assignment)\n\n### Placements of Sensors\n\nPlacing of the sensors must be sensible, formally:\n\n- Before each crossing, in all four directions.\n- Before each switch, in all three directions.\n- Before each turn-around point.\n\nOne single sensor can safely act as both a Crossing-sensor and Switch-sensor.\nSensors not abiding the bullets above will be ignored in that diretion that\nthey are not abiding a rule. (Which is of course very common, used as a margin)\n\n### Sensors in the particular map\n\nThe placement has been done to abide the rules above in one direction, which leads to using many sensors. \nOne could conversely let each Sensor act as a bi-directional Sensor, that would lead to less sensors.\n\nWe choose many sensors which effectivly means good train flow, rather than few\nsensors which would end in bad train flow, but high maximum velocity.\n\n## How the solution uses semaphores\n\nWe've realized by studying the general case that each sensor could correspond\nto three actions:\n\n- If near the edge, turn around\n- If near a crossing, grab a crossing-semaphore and then drive\n- If about to switch segment, *safely* switch current segment-semaphore to the new one the train is about to enter.\n\nHence this description clearly indicates how we use semaphores. Put short: For each crossing and for each segment.\n\nBy segment we mean any region which is bound by switches or endpoints. (There are 8 in the original map)\n\nTotally the solution uses up to 9 semaphores for the given railmap. (upto because they are created dynamically)\n\n## Maximum train speed\n\nWe have already discussed that the submitted railway has many sensors which ultimately lead to lower maximum train speed\nbut better trainflow.\n\nWe do not try to temporairly slow down or halfen the speed at any time to increase the maximum train speed, as that would\nmake the already complicated general solution more complicated.\n\nWe confidently say that the maximum speed is 14, however, it could easily be increased by using the more sparing\nsensor placenment, an example of that is highlighed in the file **origfast**.\n\n## Command line usage\n\nOut implementation must read the file as input, therfor it must be passed to the program.\n\nHere is an example of starting the simulation: \n\n\t\t$ 2 \"tsim bana -s 3\" \"java Lab1 bana 15 7\"\n\t\t=\u003e Starting java Lab1 bana 15 7\n\t\t=\u003e Starting tsim bana -s 3\n\t\t=\u003e Parse complete!\n\t\t=\u003e ...\n\n## How our code works\n\nWe have a class that contains all the data about the railmap, **Railmap**.\nIt is also responsible for parsing the railway-map.\n\nThe train class contains information about the train and useful methods.\n\nThe sensor class contains almost no information, it's primarly the place for\nsensor-related code.\n\nThe other classes are of a lower level and are not mentioned.\n\n## Included maps\n\nSince we have a general solution, we couldn't resist to try out our solution\non more \"fun\" maps\n\n\n## Bloopers\n\nThe four trains in the top left have \"stucked\" eachother, they have\ntaken semaphores in a cyclic way.\n\n![The train](https://github.com/oleander/Trainspotting/raw/master/Screenshot-tsim.png)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleander%2Ftrainspotting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleander%2Ftrainspotting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleander%2Ftrainspotting/lists"}