gridengine-framework


Namegridengine-framework JSON
Version 0.8.5 PyPI version JSON
download
home_pagehttps://github.com/primal-coder/grid-engine
SummaryA framework for generating and manipulating grid-based game worlds
upload_time2024-05-01 07:44:25
maintainerNone
docs_urlNone
authorJames Evans
requires_pythonNone
licenseNone
keywords game development 2d grid world generation procedural generation cell numpy pillow pyglet pymunk cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # grid-engine

## Description

**gridengine** is a framework for generating and manipulating grids. It provides a number of classes and functions for generating and manipulating grids. Each grid is composed of [Cell](#Cell) objects and is defined by a [Blueprint](#Blueprint). A grid can be generated from a blueprint, loaded from a file, or created manually. It can also be pickled for later use. It can be rendered as a 2D image, an animated GIF or an ASCII string. Grids provide a number of relevant methods for pathfinding, cell manipulation, and more.

## Installation

To install **gridengine**, run the following command:

    ```bash
    pip install grid_engine
    ```

## Usage

To use **gridengine** you can import any number of the submodules and utilize its respective features or you can import the main module.

    ```python
    import grid_engine as ge
    
    # Create a grid
    grid = ge.grid.Grid(cell_size=10, grid_dimensions=(1000, 1000))
    
    # Save a grid
    ge.grid.save_grid(grid)
    
    # Load a grid
    loaded_grid = ge.grid.Grid.load_grid(1)
    ```

grid-engine also provides a command line interface. To use it, run the following command:

    ```bash
    python -m grid_engine --help

    # Output:
    # usage: gridengine [-h] [-i] [-b BLUEPRINT] [--ascii] [-l LOAD] [-t] [-ns NOISE_SCALE] [-no NOISE_OCTAVES] [-nr NOISE_ROUGHNESS] [-r ROWS] [-c COLUMNS] [-s SIZE] [-S] [-T TYPE] [-v]

    # Generate a visualized grid from a blueprint. For producing a blueprint, see the blueprint module.

    # options:
    #   -h, --help            show this help message and exit
    #   -i, --interactive     Run an interactive session
    #   -b BLUEPRINT, --blueprint BLUEPRINT
    #                         Load a blueprint from a file
    #   --ascii               Print the grid as ascii
    #   -l LOAD, --load LOAD  Load a grid from a file
    #   -t, --terrain         Whether to generate terrain with the grid.
    #   -ns NOISE_SCALE, --noise-scale NOISE_SCALE
    #                         Noise scale
    #   -no NOISE_OCTAVES, --noise-octaves NOISE_OCTAVES
    #                         Noise octaves
    #   -nr NOISE_ROUGHNESS, --noise-roughness NOISE_ROUGHNESS
    #                         Noise roughness
    #   -r ROWS, --rows ROWS  Number of rows in the grid
    #   -c COLUMNS, --columns COLUMNS
    #                         Number of columns in the grid
    #   -s SIZE, --size SIZE  Size of each cell in the grid
    #   -S, --save            Save the grid object to a file
    #   -T TYPE, --type TYPE  Type of file to save the grid as
    #   -v, --verbose         Verbose output
    ```

# Examples

The following examples demonstrate the use of the grid-engine package.

### CLI

The following command:

    ```bash
    python -m grid_engine -v -S -t -ns 400 -no 75 -nr 0.55 -r 450 -c 800 -s 2
    ```

Will produce the following output:

    ```bash
    Generating blueprint with cell size 2, 450 rows and 800 columns. Total_cells: 360000 ...
    Success! Blueprint generated. Dimensions: (1600, 900)
    Building grid from blueprint ...
    Finding landmasses ...
    Separating islands from landmasses ...
    done
    Finding start to river ...
    Found largest landmass: 0 with 302951 cells
    Finding lake coastal cells ...
    Found 1094 cells.
    Validating start/end of river ...
    Start cell: pd00229(445, 228), End cell: dq00087(146, 86))
    Building river ...
    Getting river cells by walk ...
    Generating river with end designated ...
    Cells in river: 300 | Current cell: kb00082 | Next cell: kc00082
    River steps: 300
    Found largest landmass: 0 with 302951 cells
    Finding lake coastal cells ...
    Found 1094 cells.
    Validating start/end of river ...
    Start cell: ip00499(275, 498), End cell: dv00087(151, 86)
    Building river ...
    Getting river cells by walk ...
    Generating river with end designated ...
    Cells in river: 757 | Current cell: dz00082 | Next cell: ea000814
    River steps: 757
    done
    Success! Grid generated.
    Pickling grid ...
    Success!
    Pickling blueprint ...
    Success!
    Generating grid image ...
    Importing pillow ...
    Preparing raw image ...
    Counting cells ...
    Total cells: 360000
    Shuffling cells ...
    Cells drawn. 100%
    Saving grid image ...
    Grid ID: 8d564
    ```

The following image is the result of the above command:

![grid](grid_engine/_saves/8d564/grid.png)
*The river generation algorithm is not perfect. I am currently working on improving it.*

The above command will also produce the following files(Not included in the repository... That is, generate your own!):

* `grid.8d564.pickle`: A pickled Grid object.
* `blueprint.8d564.pickle`: A pickled TerrainGridBlueprint object.

    ```python
    import grid_engine
    from grid_engine import Grid

    # Load the 8d564 grid(assuming you've not generated any other grids)
    _8d564 = Grid.load_grid('8d564')

    print(_8d564.grid_id)
    # output: 'fb16965aa77f44138dd6149b823ee9e4'

    # Get a random cell
    cellA = _8d564.random_cell(attr=('passable', True))

    # Get another
    cellB = _8d564.random_cell(attr=('passable', True))

    # Get a path from cellA to cellB
    path, cost = _8d564.get_path(cellA, cellB)
    print(path)
    ```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/primal-coder/grid-engine",
    "name": "gridengine-framework",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "game development 2d grid world generation procedural generation cell numpy pillow pyglet pymunk cli",
    "author": "James Evans",
    "author_email": "joesaysahoy@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2d/ee/3a616259401ed62935d0a61ac2e35ccdaab0aa37d65f24998f3d3d99bbf0/gridengine_framework-0.8.5.tar.gz",
    "platform": null,
    "description": "# grid-engine\n\n## Description\n\n**gridengine** is a framework for generating and manipulating grids. It provides a number of classes and functions for generating and manipulating grids. Each grid is composed of [Cell](#Cell) objects and is defined by a [Blueprint](#Blueprint). A grid can be generated from a blueprint, loaded from a file, or created manually. It can also be pickled for later use. It can be rendered as a 2D image, an animated GIF or an ASCII string. Grids provide a number of relevant methods for pathfinding, cell manipulation, and more.\n\n## Installation\n\nTo install **gridengine**, run the following command:\n\n    ```bash\n    pip install grid_engine\n    ```\n\n## Usage\n\nTo use **gridengine** you can import any number of the submodules and utilize its respective features or you can import the main module.\n\n    ```python\n    import grid_engine as ge\n    \n    # Create a grid\n    grid = ge.grid.Grid(cell_size=10, grid_dimensions=(1000, 1000))\n    \n    # Save a grid\n    ge.grid.save_grid(grid)\n    \n    # Load a grid\n    loaded_grid = ge.grid.Grid.load_grid(1)\n    ```\n\ngrid-engine also provides a command line interface. To use it, run the following command:\n\n    ```bash\n    python -m grid_engine --help\n\n    # Output:\n    # usage: gridengine [-h] [-i] [-b BLUEPRINT] [--ascii] [-l LOAD] [-t] [-ns NOISE_SCALE] [-no NOISE_OCTAVES] [-nr NOISE_ROUGHNESS] [-r ROWS] [-c COLUMNS] [-s SIZE] [-S] [-T TYPE] [-v]\n\n    # Generate a visualized grid from a blueprint. For producing a blueprint, see the blueprint module.\n\n    # options:\n    #   -h, --help            show this help message and exit\n    #   -i, --interactive     Run an interactive session\n    #   -b BLUEPRINT, --blueprint BLUEPRINT\n    #                         Load a blueprint from a file\n    #   --ascii               Print the grid as ascii\n    #   -l LOAD, --load LOAD  Load a grid from a file\n    #   -t, --terrain         Whether to generate terrain with the grid.\n    #   -ns NOISE_SCALE, --noise-scale NOISE_SCALE\n    #                         Noise scale\n    #   -no NOISE_OCTAVES, --noise-octaves NOISE_OCTAVES\n    #                         Noise octaves\n    #   -nr NOISE_ROUGHNESS, --noise-roughness NOISE_ROUGHNESS\n    #                         Noise roughness\n    #   -r ROWS, --rows ROWS  Number of rows in the grid\n    #   -c COLUMNS, --columns COLUMNS\n    #                         Number of columns in the grid\n    #   -s SIZE, --size SIZE  Size of each cell in the grid\n    #   -S, --save            Save the grid object to a file\n    #   -T TYPE, --type TYPE  Type of file to save the grid as\n    #   -v, --verbose         Verbose output\n    ```\n\n# Examples\n\nThe following examples demonstrate the use of the grid-engine package.\n\n### CLI\n\nThe following command:\n\n    ```bash\n    python -m grid_engine -v -S -t -ns 400 -no 75 -nr 0.55 -r 450 -c 800 -s 2\n    ```\n\nWill produce the following output:\n\n    ```bash\n    Generating blueprint with cell size 2, 450 rows and 800 columns. Total_cells: 360000 ...\n    Success! Blueprint generated. Dimensions: (1600, 900)\n    Building grid from blueprint ...\n    Finding landmasses ...\n    Separating islands from landmasses ...\n    done\n    Finding start to river ...\n    Found largest landmass: 0 with 302951 cells\n    Finding lake coastal cells ...\n    Found 1094 cells.\n    Validating start/end of river ...\n    Start cell: pd00229(445, 228), End cell: dq00087(146, 86))\n    Building river ...\n    Getting river cells by walk ...\n    Generating river with end designated ...\n    Cells in river: 300 | Current cell: kb00082 | Next cell: kc00082\n    River steps: 300\n    Found largest landmass: 0 with 302951 cells\n    Finding lake coastal cells ...\n    Found 1094 cells.\n    Validating start/end of river ...\n    Start cell: ip00499(275, 498), End cell: dv00087(151, 86)\n    Building river ...\n    Getting river cells by walk ...\n    Generating river with end designated ...\n    Cells in river: 757 | Current cell: dz00082 | Next cell: ea000814\n    River steps: 757\n    done\n    Success! Grid generated.\n    Pickling grid ...\n    Success!\n    Pickling blueprint ...\n    Success!\n    Generating grid image ...\n    Importing pillow ...\n    Preparing raw image ...\n    Counting cells ...\n    Total cells: 360000\n    Shuffling cells ...\n    Cells drawn. 100%\n    Saving grid image ...\n    Grid ID: 8d564\n    ```\n\nThe following image is the result of the above command:\n\n![grid](grid_engine/_saves/8d564/grid.png)\n*The river generation algorithm is not perfect. I am currently working on improving it.*\n\nThe above command will also produce the following files(Not included in the repository... That is, generate your own!):\n\n* `grid.8d564.pickle`: A pickled Grid object.\n* `blueprint.8d564.pickle`: A pickled TerrainGridBlueprint object.\n\n    ```python\n    import grid_engine\n    from grid_engine import Grid\n\n    # Load the 8d564 grid(assuming you've not generated any other grids)\n    _8d564 = Grid.load_grid('8d564')\n\n    print(_8d564.grid_id)\n    # output: 'fb16965aa77f44138dd6149b823ee9e4'\n\n    # Get a random cell\n    cellA = _8d564.random_cell(attr=('passable', True))\n\n    # Get another\n    cellB = _8d564.random_cell(attr=('passable', True))\n\n    # Get a path from cellA to cellB\n    path, cost = _8d564.get_path(cellA, cellB)\n    print(path)\n    ```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A framework for generating and manipulating grid-based game worlds",
    "version": "0.8.5",
    "project_urls": {
        "Homepage": "https://github.com/primal-coder/grid-engine"
    },
    "split_keywords": [
        "game",
        "development",
        "2d",
        "grid",
        "world",
        "generation",
        "procedural",
        "generation",
        "cell",
        "numpy",
        "pillow",
        "pyglet",
        "pymunk",
        "cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2dee3a616259401ed62935d0a61ac2e35ccdaab0aa37d65f24998f3d3d99bbf0",
                "md5": "077eafe9473939b849eff7eea9793488",
                "sha256": "58cf5cf69424e22844fb871eac2d9d01affe068e2ec81e285085bd294d1bdcdb"
            },
            "downloads": -1,
            "filename": "gridengine_framework-0.8.5.tar.gz",
            "has_sig": false,
            "md5_digest": "077eafe9473939b849eff7eea9793488",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 48067,
            "upload_time": "2024-05-01T07:44:25",
            "upload_time_iso_8601": "2024-05-01T07:44:25.886671Z",
            "url": "https://files.pythonhosted.org/packages/2d/ee/3a616259401ed62935d0a61ac2e35ccdaab0aa37d65f24998f3d3d99bbf0/gridengine_framework-0.8.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-01 07:44:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "primal-coder",
    "github_project": "grid-engine",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "gridengine-framework"
}
        
Elapsed time: 0.25555s