{ "info": { "author": "Stephan Houben", "author_email": "stephanh42@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Build Tools" ], "description": "hexutil\n=======\n\nClasses and functions to deal with hexagonal grids.\n\n[Screenshot of example.py]\n\nIntroduction\n------------\n\nThis module provides the following functionality.\n\n1. Manipulation of grid coordinates in a hexagonal grid.\n2. Converting between hexagonal grid coordinates and screen\n coordinates.\n3. Field-of-view calculation on a hexagonal grid.\n4. A* path-finding on a hexagonal grid.\n\nAll this is provided by the module hexutil. The file example.py contains\nexample coding using this functionality. The above image is a screenshot\nfrom this example.\n\nManipulation of grid coordinates in a hexagonal grid.\n-----------------------------------------------------\n\nThe class hexagon.Hex represents a particular hexagon in a grid. Class\nHex takes two integer arguments, x and y. These need to satisfy the\nproperty that their sum is even.\n\nThe following (x,y) coordinate system is used to address hexagons in the\ngrid.\n\n[Hexgrid coordinate system]\n\nAt first, it may seem weird that this coordinate system leaves \"holes\"\nin the representation, i.e. there is no hexagon corresponding to, say,\n(0, 1). However, that turns out to be not a real problem in practise.\nThe advantage is that relationship to the actual center points of the\nhexagons becomes very simple, namely, just multiply y with \u221a3. This also\nsimplifies screen coordinate calculations.\n\nThe only time the \"holes\" are an issue is if you want to pack grid data\ndensely into a 2D (numpy) array or a list-of-lists. In that case, just\nuse ar[hexagon.x//2][hexagon.y] to index into array ar.\n\nThe constructor of Hex checks the \"x+y is even\" property. If it is not\nsatisfied, an InvalidHex exception is thrown.\n\nNote that Hex is a namedtuple. That means that it can be used wherever a\n2-tuple (x, y) is required. It also means that is is immutable.\n\nImportant functionality on instances of Hex. * The hex.x and hex.y\nfields for accessing the x- and y-coordinate, respectively. * Arithmetic\noperations hex1 + hex2, hex1 - hex2 and - hex are supported. * The\nmethod hex.neighbours() returns the 6 direct neighbours of a hex. * The\nmethod hex1.distance(hex2) returns the distance in terms of steps on the\nhexagon grid between hex1 and hex2.\n\nConverting between hexagonal grid coordinates and screen coordinates.\n---------------------------------------------------------------------\n\nThe mapping of a hexagon to screen (pixel) coordinates can be described\nby two parameters width and height. The following image shows how these\nrelate to the hexagon size.\n\n[Hexgrid width and height]\n\nFor a perfectly regular hexagon, the relationship height = \u2153\u221a3 width\nshould hold. In practice, we typically want integral pixel coordinates.\n\nThe class HexGrid captures such a pair of width and height values. It\ncan be initialized as HexGrid(width, height) or HexGrid(width). In the\nlatter case, height is automatically computed as round(\u2153\u221a3 * width).\n\nImportant functionality on instances of Hex. * The hexgrid.width and\nhexgrid.height fields for accessing the width and height, respectively.\n* Method hexgrid.center(hex) returns a pair (x, y) of screen coordinates\nof the center of hex. * Method hexgrid.corners(hex) returns a sequence\nof 6 pairs (x, y) of screen coordinates of the 6 corners of hex. *\nMethod hexgrid.bounding_box(hex) returns a hexutil.Rectangle object\ndescribing the bounding box of hex. * Method\nhexgrid.hex_at_coordinate(x, y) returns the Hex at screen coordinate\n(x,y). * Method hexgrid.hexes_in_rectangle(rect) returns a sequence of\nall Hex-es which overlap with Rectangle rect.\n\nField-of-view calculation on a hexagonal grid.\n----------------------------------------------\n\nField-of-view calculation is done by the following method on Hex\ninstances.\n\nhex.field_of_view(self, transparent, max_distance, visible=None)\n\n- transparent -- from a Hex to a boolean, indicating of the Hex is\n transparent\n- max_distance -- maximum distance you can view\n- visible -- if provided, should be a dict which will be filled and\n returned\n\nReturns a dict which has as its keys the hexagons which are visible. The\nvalue is a bitmask which indicates which sides of the hexagon are\nvisible. The bitmask is useful if you want to use this function also to\ncompute light sources.\n\n view_set = player_pos.field_of_view(...)\n light_set = light_source.field_of_view(...)\n\n # Is pos visible?\n if view_set.get(pos, 0) & light_set.get(pos, 0):\n # yes it is\n\nA* path-finding on a hexagonal grid.\n------------------------------------\n\nPath-finding (using the A* algorithm) is done by the following method on\nHex instances.\n\nhex.find_path(self, destination, passable, cost=lambda pos: 1)\n\n- hex -- Starting position (Hex object) for path finding.\n- destination -- Destination position for path finding.\n- passable -- Function of one position, returning True if we can move\n through this hex.\n- cost -- cost function for moving through a hex. Should return a\n value \u2265 1. By default all costs are 1.\n\nThis returns the path (as a sequence of Hex-es, including start point\nand destination), or None if no path could be found.\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/stephanh42/hexutil", "keywords": "math game development", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "hexutil", "package_url": "https://pypi.org/project/hexutil/", "platform": "", "project_url": "https://pypi.org/project/hexutil/", "project_urls": { "Homepage": "https://github.com/stephanh42/hexutil" }, "release_url": "https://pypi.org/project/hexutil/0.2.2/", "requires_dist": null, "requires_python": "~=3.3", "summary": "Classes and functions to deal with hexagonal grids", "version": "0.2.2" }, "last_serial": 3075047, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e4c310c58657b1a17b0963be7cb302b3", "sha256": "83d931989d47b46aba804beec23d22ac0460f28a9615e1f9a8d383355beeba14" }, "downloads": -1, "filename": "hexutil-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e4c310c58657b1a17b0963be7cb302b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.3", "size": 3486, "upload_time": "2017-07-28T11:32:11", "url": "https://files.pythonhosted.org/packages/9c/b3/e84e144dbfb631eaeabc352aa97e1d74b00e6a6a207edf9a8598b9624e71/hexutil-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1586287954977db161406219c01ae40c", "sha256": "d0a09993421e03ae0484fb393e9f5ed05b5b864a995acef45052c7ae4973a3cf" }, "downloads": -1, "filename": "hexutil-0.1.0.tar.gz", "has_sig": false, "md5_digest": "1586287954977db161406219c01ae40c", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.3", "size": 4209, "upload_time": "2017-07-28T11:32:13", "url": "https://files.pythonhosted.org/packages/c6/8e/9e09c420b915380d4fdc073da9639588356057f06d59ef224985175fc10d/hexutil-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "604a7fb80b06f513f2bd48dc55601614", "sha256": "c251830481b4bcd0f713bc1bf740ee336a525756dc2d6d3181d4a2010f795a94" }, "downloads": -1, "filename": "hexutil-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "604a7fb80b06f513f2bd48dc55601614", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.3", "size": 3673, "upload_time": "2017-07-28T15:34:09", "url": "https://files.pythonhosted.org/packages/ff/19/2167ca1394ebd06ef2fd6762d1738b5dca37a04f4ba050dee33b5cc501b9/hexutil-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ed4514124341045dd07a3995dd41bd43", "sha256": "4569087c9dec44fc3b9ef333098d0b545afd8d62345a6e0fde15d2abbf873fe4" }, "downloads": -1, "filename": "hexutil-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ed4514124341045dd07a3995dd41bd43", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.3", "size": 4398, "upload_time": "2017-07-28T15:34:12", "url": "https://files.pythonhosted.org/packages/2f/01/f658e006e7374fa9f8f11bf8fc00f8b75f4bdb3c531dcd10ae1a9f50517b/hexutil-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "68682ce28f1eb4740210ad2267d26ee7", "sha256": "935dfebf4014ece41ad0f13a2e38eac225d53f732914dd78d1fa27b59acef63f" }, "downloads": -1, "filename": "hexutil-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "68682ce28f1eb4740210ad2267d26ee7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.3", "size": 7645, "upload_time": "2017-08-04T14:49:17", "url": "https://files.pythonhosted.org/packages/1f/32/19a12782cf9e31bc52e7487aee37896c341db3c0e2b27552d3b9cfcc4574/hexutil-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f3999d2d64f9d398c955e02502a2eb55", "sha256": "a84284a202066337e83422a8111aecef6e00153461835100abe650003bf0673b" }, "downloads": -1, "filename": "hexutil-0.2.0.tar.gz", "has_sig": false, "md5_digest": "f3999d2d64f9d398c955e02502a2eb55", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.3", "size": 7623, "upload_time": "2017-08-04T14:49:19", "url": "https://files.pythonhosted.org/packages/91/9e/df6e1b15bcc627ecc10e70a2f620d1515f0bb24f8c2a07b9692019e5b16d/hexutil-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "2f7f294312590af7142daaa57d111b21", "sha256": "779c1c48dd1d0dc9e762008e693a3bc6751779d5cfdc7976ec674f54775cde6d" }, "downloads": -1, "filename": "hexutil-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "2f7f294312590af7142daaa57d111b21", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.3", "size": 7752, "upload_time": "2017-08-05T07:17:32", "url": "https://files.pythonhosted.org/packages/17/5c/82f8d2299207cee3ec015fe62127a28a70ba1bb29810b49a2d9c688e5716/hexutil-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "30a6bf68388db9d6e544fb471f943958", "sha256": "ed2d1cc8c669a68032a68611e89d3265d702c4852f8e48d151725aeed5e763a7" }, "downloads": -1, "filename": "hexutil-0.2.1.tar.gz", "has_sig": false, "md5_digest": "30a6bf68388db9d6e544fb471f943958", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.3", "size": 7985, "upload_time": "2017-08-05T07:17:34", "url": "https://files.pythonhosted.org/packages/58/2a/a51a66f848e787d1a9d506e6639af1ad245654128d9106df4be75c902355/hexutil-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "4c34b6ce4c888318fe6c6b5260b765eb", "sha256": "21e34a329b6ae4abaa9eed356a7c4279ef7b7c6a0870bb77f8c7014805a8c5d4" }, "downloads": -1, "filename": "hexutil-0.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "4c34b6ce4c888318fe6c6b5260b765eb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.3", "size": 10044, "upload_time": "2017-08-05T15:16:19", "url": "https://files.pythonhosted.org/packages/4e/f9/24cd47b7cb81a30c433850740e87a0e9a817b4342ca97dcaf2f9bff87ecc/hexutil-0.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9b58ebf9cef5c37fa3a870d246897bcc", "sha256": "64e0de4d0ed52f75ada204b6878a837d095521c0086410f9dbcfe30c640cba6f" }, "downloads": -1, "filename": "hexutil-0.2.2.tar.gz", "has_sig": false, "md5_digest": "9b58ebf9cef5c37fa3a870d246897bcc", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.3", "size": 9410, "upload_time": "2017-08-05T15:16:20", "url": "https://files.pythonhosted.org/packages/47/2e/7ecab7ecf2c9c97b0307086426aaf6213fb577b515f6dd3177add520d73c/hexutil-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4c34b6ce4c888318fe6c6b5260b765eb", "sha256": "21e34a329b6ae4abaa9eed356a7c4279ef7b7c6a0870bb77f8c7014805a8c5d4" }, "downloads": -1, "filename": "hexutil-0.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "4c34b6ce4c888318fe6c6b5260b765eb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.3", "size": 10044, "upload_time": "2017-08-05T15:16:19", "url": "https://files.pythonhosted.org/packages/4e/f9/24cd47b7cb81a30c433850740e87a0e9a817b4342ca97dcaf2f9bff87ecc/hexutil-0.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9b58ebf9cef5c37fa3a870d246897bcc", "sha256": "64e0de4d0ed52f75ada204b6878a837d095521c0086410f9dbcfe30c640cba6f" }, "downloads": -1, "filename": "hexutil-0.2.2.tar.gz", "has_sig": false, "md5_digest": "9b58ebf9cef5c37fa3a870d246897bcc", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.3", "size": 9410, "upload_time": "2017-08-05T15:16:20", "url": "https://files.pythonhosted.org/packages/47/2e/7ecab7ecf2c9c97b0307086426aaf6213fb577b515f6dd3177add520d73c/hexutil-0.2.2.tar.gz" } ] }