{"id":16942641,"url":"https://github.com/defnull/choice","last_synced_at":"2025-10-26T21:37:52.926Z","repository":{"id":955119,"uuid":"738435","full_name":"defnull/choice","owner":"defnull","description":"A simple multiple-choice game.","archived":false,"fork":false,"pushed_at":"2010-06-25T19:56:29.000Z","size":104,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-26T03:45:14.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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/defnull.png","metadata":{"files":{"readme":"README.rst","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":"2010-06-24T21:23:08.000Z","updated_at":"2018-02-07T23:11:49.000Z","dependencies_parsed_at":"2022-07-20T06:32:10.328Z","dependency_job_id":null,"html_url":"https://github.com/defnull/choice","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/defnull%2Fchoice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defnull%2Fchoice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defnull%2Fchoice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defnull%2Fchoice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defnull","download_url":"https://codeload.github.com/defnull/choice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244752356,"owners_count":20504255,"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":[],"created_at":"2024-10-13T21:12:32.535Z","updated_at":"2025-10-16T01:54:48.475Z","avatar_url":"https://github.com/defnull.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Multiple-Choice Game Engine\n===========================\n\nThis is a very simple text-based multiple-choice game which\nparses an easy-to-read plot-file syntax. An embedded language to support more\ncomplex game logic (variables, conditional text or choices, functions)\nis planned, but not supported jet.\n\nPlot-File Syntax\n----------------\n\nYou can add any number of scenes to a plot-file. Each new scene is preceded by\na label (e.g. ``[scene_name]``) followed by a description text. The first\nscene does not need to have a label. It is labeled 'start' automatically.\n\n::\n\n  You open the door and see nothing but black darkness.\n  You have a strange feeling about this.\n\n  [room] You are dead now. No one will ever know why.\n\n  [exit] You got out alive, lucky one.\n\nScenes alone don't make a good story. You need a way to proceed from scene to\nscene, best by giving the player a choice. This is why labels are so\nimportant. You can link to them::\n\n  You open the door and see nothing but black darkness.\n  You have a strange feeling about this.\n  \u003croom\u003e Close your eyes and enter the room.\n  \u003ctorch\u003e Light a torch.\n  \n  [room] You are dead now. No one will ever know why.\n  \n  [torch] In the flickering light of the torch you can see that the room has\n  no floor, but a deep pit with spears in it. Thank god you didn't step\n  inside.\n  \u003cexit\u003e Go home.\n  \n  [exit] You got out alive, lucky one.\n\n\nNow the player has a choice. As soon as he reaches a scene that has no further\nchoices, the game ends.\n\nWriting deeply nested plots and especially conversations can get confusing\nquickly. There is an alternative syntax which allows you to define the\ntarget-scene of a choice in-place. You just have to begin the link with '?'\ninstead of a link-target and add the target scene indented with space\ncharacters. You don't have to assign a label to the nested scene, but you can,\nif you want to jump to it from another scene, too. Here is an example::\n\n  You open the door and see nothing but black darkness.\n  You have a strange feeling about this.\n  \n  ? Close your eyes and enter the room.\n    You are dead now. No one will ever know why.\n  \n  ? Light a torch.\n    In the flickering light of the torch you can see that the room has\n    no floor, but a deep pit with spears in it. Thank god you didn't step\n    inside.\n  \n    ? Adventures are dangerous? I don't want to do this anymore.\n      [end] This was a small dungon and a borng adventure.\n  \n    ? Search for another door.\n      There is one, hidden behind a book shelve.\n  \n      \u003cdungeon\u003e Step inside cautiously.\n  \n      ? Go away.\n        \u003cend\u003e\n  \n  \u003cend\u003e Be a coward and go home.\n  \n  [dungen] The adventure begins...\n\nAs you can see, in-place choices can be nested and mixed with normal links.\nThe blank lines are optional.\n\nThis syntax is quite intuitive. Just make sure you get the indention right.\nThe last ``\u003cend\u003e`` link for example should match the indention of the scene it\nbelongs to. If a nested block gets to big to fit your screen, consider\noutsourcing parts of it into separate root-level scenes.\n\nLets now have a look at the \"Go away\" choice in the last example. It is\nfollowed by an in-place scene with no description text and only a single link.\nIt makes no sense to present an empty scene to the player, so it is stepped\nover by the game engine. The \"Go away\" choice jumps right to the 'end' scene,\njust like an ``\u003cend\u003e`` link would do. The following two examples are\nequivalent (to the player)::\n\n  Are you male or female?\n  ? I was male last time I checked.\n    \u003cmale\u003e\n\n  ? Female, thats for sure.\n    \u003cfemale\u003e\n\n::\n\n  Are you male or female?\n  \u003cmale\u003e I was male last time I checked.\n  \u003cfemale\u003e Female, thats for sure.\n\nUsage\n-----\n\nThe library is in a very early state. You can parse a plot-file into a\nscene-graph and play the game in the command line with the following syntax::\n\n  from choice import parse, play\n  with open('./test.plot') as fp:\n      source = fp.read()\n      game = parse(source)\n      play(game)\n\nAlternatively you can just run ``choice.py`` with the plot-file as first command-line argument.\n\n  $ python choice.py ./test.plot\n\nLicence (MIT)\n-------------\n\n  Copyright (c) 2010, Marcel Hellkamp.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy\n  of this software and associated documentation files (the \"Software\"), to\n  deal in the Software without restriction, including without limitation the\n  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n  sell copies of the Software, and to permit persons to whom the Software is\n  furnished to do so, subject to the following conditions:\n\n  The above copyright notice and this permission notice shall be included in\n  all copies or substantial portions of the Software.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n  IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefnull%2Fchoice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefnull%2Fchoice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefnull%2Fchoice/lists"}