{ "info": { "author": "Lucas Bourneuf", "author_email": "lucas.bourneuf@laposte.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Other Audience", "Programming Language :: ASP", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5" ], "description": "# Space Engine modding language abstraction\nUsing python, define complete systems in SpaceEngine.\n\nFor motivations, see [my blog entry about this repository](lucas.bourneuf.net/blog/se-lang.html).\n\n\n## Short example\nLet's say you want to reproduce a simple solar system with a sun, an earth and a moon.\nYou can write in `mysimplesystem.lp` the following lines:\n\n```asp\nroot(sun,\"MySimpleSystem\").\norbit(sun,orbit(earth,moon,\"0.005\"),1).\n```\n\nYou now run selang on it:\n\n python -m selang mysimplesystem.lp -o ~/path/to/SpaceEngine/install/dir\n\nYou can now run SpaceEngine and press F3 to search and go to `MySimpleSystem`.\n\n\n## Install\n\n pip install selang\n\nOn random error, add `no-cache-dir`.\nTo get the ASP part working, install [clingo 5](https://github.com/potassco/clingo/releases) in you $PATH.\n\n\n\n## CLI Example\nFirst, lookup some example of input data in [data/](data/), for instance the reproduction in JSON\nof [the full 4 Kalgash systems](data/kalgash.json) from [planetplanet.net]().\n\nNow, run the command:\n\n python -m selang data/kalgash.json\n\n8 files will be created : two for each of the four Kalgash systems defined in `data/kalgash.json`.\nThe two files correspond to the SpaceEngine modding interface, that needs a star record (which should be named system record) and a planet record (which should be named object record).\nNote that the star record, ending in `.star.sc`, is quite trivial.\n\nAlso, if you have the path to your SpaceEngine installation directory, for instance `~/games/SpaceEngine/`:\n\n python -m selang data/kalgash.json -o ~/games/SpaceEngine\n\nThis way, selang will directly put the generated files into the expected directories, i.e. `/addons/catalogs/{star,planet}/`.\n\nThere is some help about this CLI if you need it:\n\n python -m selang --help\n\n\n\n## API Example\nLet's say you want to reproduce a simple solar system with a sun, an earth and a moon.\n\nUsing python and se-lang, you would write:\n\n```python\nfrom selang import ref, orbit, Model, model_to_se\n\nmodel = Model(\n 'My little system',\n { # structure of the system\n 'sun': (1, orbit(1, eccentricity=0.04)),\n 1: ('moon', orbit(0.05)),\n },\n { # non explicit objects\n 1: ref('earth', earth_mass=1.2), # super earth\n }\n)\n\nmodel_to_se(model, '~/games/space_engine/SpaceEngine/')\n```\n\n### Alternative typing\nThe internal model used by se-lang is quite simple, and therefore may be used directly:\n\n```python\nfrom selang import ref, orbit, Model, model_to_se\n\nmodel = Model(\n 'My little system',\n (\n ('sun', 1, orbit(1, eccentricity=0.04)),\n (1, 'moon', orbit(0.05))\n ),\n {\n 1: ref('earth', earth_mass=1.2), # super earth\n }\n)\n\nmodel_to_se(model, '~/games/space_engine/SpaceEngine/')\n```\n\n\n## Interest of se-lang over the modding language\nThe modding language of SpaceEngine is very well documented and powerful. However, beyond the simple cases described in the doc,\nyou end up writing python scripts [to automatize some standard things, like rings](lucas.bourneuf.net/blog/uess.html).\n\nInstead of rewriting new python scripts each time, here it is: an internal model to rule them all. An internal model to be created by any format.\nAn internal model to use for any case.\n\n\n## Input formats\nThe internal model can be directly built by client code.\nHowever, to simplify the input, further work will focus on building the internal model using\nother languages.\n\n### ASP\nASP is (logical) programming language, like prolog.\nIt allows the high-level expression of logical relations, which is quite interesting for DSLs.\n\nIt leads to very short programs, as show the following reproduction of all 4 Kalgash systems:\n\n```asp\n% Common to all\nroot(black_hole,\"Kalgash\").\n\n\n% Kalgash 2 system\norbit(black_hole,ring(sun,8),20).\norbit(black_hole,orbit(red_dwarf,earth,\"0.2\"),10).\n\n\n% Kalgash 3 system\norbit(black_hole,ring(sun,12,orbit(1,earth,1)),20).\n\n\n% Kalgash 4 system\norbit(black_hole,ring(sun,8),1,retrograde).\norbit(black_hole,earth,\"2.5\").\norbit(black_hole,ring(sun,8),\"4\").\n\n\n% Kalgash 5 system\norbit(black_hole,ring(sun,8),1,retrograde).\norbit(black_hole,earth,\"2.5\").\norbit(black_hole,ring(blue_giant,8),20).\n```\nSee other examples in [data/](data/).\n\n\n### JSON\nJSON is really close to Python basic types, and as such enables\na quasi-obvious mapping to the python API.\n\nAs for ASP, previous implementation handled JSON-based input. It was verbose, but simple:\n```json\n{\n \"name\": \"Kalgash 3\",\n \"UID\": \"Kalgash\",\n \"type\": \"black hole\",\n \"childs\": {\n \"type\": [\"ring\", 12, \"sun\"],\n \"distance\": 20,\n \"childof\": {\n \"1\": {\n \"type\": \"earth\",\n \"distance\": 1\n }\n }\n }\n}\n```\n\nSee other examples in [data/](data/).\n\n\n#### ASP vs JSON\nASP is (logical) programming language, JSON is a text format, so they differ in so many ways,\nyou can assume they are different things.\n\nThe ideal language to abstract modding of SpaceEngine is probably not one of these two,\nbut i had fun making the corresponding interpreters, and using them for some [use cases](lucas.bourneuf.net/blog/se-lang.html).\n\n\n\n## dev\n- [x] ASP input: short and simple.\n- [x] JSON input: not programmable, but useful for simple work.\n- [x] Python input: good enough\n- [ ] lisp input.\n- [x] read input from file\n- [x] reproduce Kalgash systems from [planetplanet.net](https://planetplanet.net/2018/03/21/asimov-kalgash-take2/): [see blog entry](https://lucas.bourneuf.net/blog/se-lang.html)\n- [x] reproduce [UESS](https://lucas.bourneuf.net/blog/uess.html)\n- [x] find a way to simplify UESS encoding: python do the job.\n- [x] user-made spacing for rings\n- [x] specific treatment for elements of rings\n- [x] allow use of standard name for objects: `sun`, `earth`,\u2026\n- [x] allow use of non-standard name for objects: `planet` and `star` functions.\n- [ ] injection of arbitrary SpaceEngine script code.\n- [x] full orbit definition\n- [ ] testing suite\n- [ ] handle star barycenter as object (bottom line: necessary to handle binary objects)\n\n\n\n## FAQ\n\n### Dinopython support ?\nNo.\n\n### Contributions ?\nYes.\n\n### Other things i did for SpaceEngine ?\n[se-pioneer](https://github.com/Aluriak/se-pioneers), for asynchonous multiplayer.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/aluriak/se-lang", "keywords": "SpaceEngine,DSL,Answer Set Programming", "license": "GPL", "maintainer": "", "maintainer_email": "", "name": "selang", "package_url": "https://pypi.org/project/selang/", "platform": "", "project_url": "https://pypi.org/project/selang/", "project_urls": { "Homepage": "https://github.com/aluriak/se-lang" }, "release_url": "https://pypi.org/project/selang/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Python, ASP and JSON abstractions of the SpaceEngine modding language", "version": "0.1.1" }, "last_serial": 3781359, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "ad05954492c0b5a3b3242e58e2efd856", "sha256": "55378f68dc914afd9b2cc89a7b2abad83afd674d0cfd79024f97ef74c780e637" }, "downloads": -1, "filename": "selang-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ad05954492c0b5a3b3242e58e2efd856", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12881, "upload_time": "2018-04-19T16:40:23", "url": "https://files.pythonhosted.org/packages/45/4b/47b733599f768b76a2ebe64526ad830b3ffbfbacf94919874695094c38ae/selang-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "7bcd70335984c6083715ed04b023d387", "sha256": "81cd91de80e714ab86f31e71ad0aa068ce49783c60e8d4507d126bd3419f8f22" }, "downloads": -1, "filename": "selang-0.1.1.tar.gz", "has_sig": false, "md5_digest": "7bcd70335984c6083715ed04b023d387", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12873, "upload_time": "2018-04-19T16:42:12", "url": "https://files.pythonhosted.org/packages/0e/49/2000094f333eb77ccf0c85a1cf64e9f28427f68e6b8960a58e52c4e4dbfc/selang-0.1.1.tar.gz" } ], "0.1.1.dev0": [ { "comment_text": "", "digests": { "md5": "edb3daee94dc595193f809da56043ca0", "sha256": "86d13d0dbd58db3514c2f298d25336edd386039426b416f0f02fa1e18e2ac836" }, "downloads": -1, "filename": "selang-0.1.1.dev0.tar.gz", "has_sig": false, "md5_digest": "edb3daee94dc595193f809da56043ca0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13075, "upload_time": "2018-04-19T16:41:20", "url": "https://files.pythonhosted.org/packages/6d/93/e514fb338f4181a2aebad307af35edbeab191d8bb5fb279119abf4ba4a1f/selang-0.1.1.dev0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7bcd70335984c6083715ed04b023d387", "sha256": "81cd91de80e714ab86f31e71ad0aa068ce49783c60e8d4507d126bd3419f8f22" }, "downloads": -1, "filename": "selang-0.1.1.tar.gz", "has_sig": false, "md5_digest": "7bcd70335984c6083715ed04b023d387", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12873, "upload_time": "2018-04-19T16:42:12", "url": "https://files.pythonhosted.org/packages/0e/49/2000094f333eb77ccf0c85a1cf64e9f28427f68e6b8960a58e52c4e4dbfc/selang-0.1.1.tar.gz" } ] }