Giter Site home page Giter Site logo

scholliyt / mgaia-minecraft Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 153.09 MB

Procedural content generation in Minecraft using the wave function collapse algorithm.

License: MIT License

Python 100.00%
python wfc gdcm minecraft pcg wavefunctioncollapse procedural-generation

mgaia-minecraft's Introduction

MGAIA-Minecraft

wakatime

This project was realized for the first assignment of the course Modern Game AI Algorithms at Leiden University on procedural content generation in Minecraft.

This project uses the wave function collapse algorithm to generate randomized realistic buildings in Minecraft.

GIF of a large building generation process

Full Videos: generate building in flat world, generate building in real world

Close up of some building structures Large city of buildings Medium-sized building in real world

Getting Started

Installation

The project uses Python Poetry (version 1.3.2) to manage dependencies. However, installing the dependencies from pyproject.toml manually using pip should also work. Additionally, using Forge the GDMC HTTP interface mod (v1.0.0) needs to be installed in Minecraft (1.19.2).

Running

The whole end to end script e2e_brickhouse.py contains building placement, building generation and interior decoration. Below are short descriptions on how to use the most important scripts that e2e_brickhouse.py is composed of.

End 2 End (start here)

See e2e_brickhouse.py

  1. Set the build area in Minecraft using /setbuildarea ~ ~ ~ ~99 ~ ~99 (or similar)
  2. Run e2e_brickhouse.py
  3. Wait for the process to finish which may take a few minutes

Building Placement

See buildregion_finder.py

  1. Set the build area in Minecraft using /setbuildarea ~ ~ ~ ~99 ~ ~99 (or similar)
  2. Run buildregion_finder.py
  3. The selected buildregion will be marked with white and red wool blocks.

Structure Scanning and Building

  1. Set the build area in Minecraft using /setbuildarea ~1 ~ ~ ~11 ~6 ~10 (or similar)
  2. Update the name for the structure in structure_scanner.py
  3. Run structure_scanner.py

The structures are saved in ./structures. There are some premade ones in this repository.

You can now replicate a single structure using structure_builder.py or go to the next steps.

Showcase generation

Building structure showcase The structure_showcase.py builds a showcase of all available building structures. This is very useful to define the rules in the rule set because you get a visual representation of the structure's rotations. Before running, you should verify that the build location in the script is okay for you.

Building Generation

The main building generation happens in brickhouse.py. You can also run this file directly to generate a building (a brickhouse in this case).

  1. Update the coordinates where to place the house in brickhouse.py
  2. Update the maximum size of the house including air padding in brickhouse.py
    • random_building(size=(7,2,7)) for a house of 5x2x5 structure building blocks because of
      "structure" air padding around it
  3. Optionally, specify some fixed structures in reinit() that guide the algorithm
    • For example wfc.collapse_cell_to_state([8,0,8], StructureRotation(brickhouse_courtyard, 0)) will ensure that a courtyard is placed at position (8,0,8) with rotation 0
    • The algorithm will use this information and build a house around it
    • This is very useful as the algorithm tends to not use certain cool structures ☚ī¸
  4. Run brickhouse.py. This might take a while. You can see the progress in the terminal.

You can also try to generate on a larger area like ``WaveFunctionCollapse((17,2,17), ...)` which will likely generate multiple unconnected houses (which still follows the rules!). Way larger areas unfortunately don't work because of recursion depth limitations.

mgaia-minecraft's People

Contributors

scholliyt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.