Open World ~ Single Room Generation Module Design - uchicago-cs/chiventure GitHub Wiki

sample_generation

Team RPG-openworld

This document serves to lay out all dependencies for our sample_generation module, which will pull from a hard-coded room module and implement autogeneration in order to add a single room to a game; this will happen whenever a room is entered.

Dependencies

Here we lay out level-dependencies at the module level. Higher level modules depend on the modules below them in the following design plan, with direct dependencies between modules that are one level away from each other.

                            sample_generation.h
                sample_rooms.h                   autogeneration.h
                sample_items.h         load_room.h load_item.h game.h room.h item.h
              game_state_common.h

Remark: In the above, autogeneration.h module may simply be merged into sample_generation.h if the room/path addition logic is simple enough. autogeneration.h module does not yet exist. sample_rooms.h and sample_items.h both have modified structs from game-state/room.h and game-state/item.h, respectively, so we'll want to merge these changes into the game-state modules if we feel they are worth keeping after testing; if not, we can just refactor our sample_generation code to fit the existing structs unchanged. We're thinking of incorporating path support, either in sample_rooms.h, making a separate sample_paths.h module, or pulling from the existing game-state/path.h module (this will require updating the existing room.h and item.h modules).

Later: sample_rooms.h and sample_items.h with room.h and item.h. Finally, we may consider adding NPC support for testing purposes, either in sample_items.h or with a separate modules to test single-room autogeneration with NPC support.

Find them here:

Functions we may use to implement autogeneration of single-room

(and what dependencies they are from)

  • enter_new_room
    • In sample_generation.h. Given two rooms, determine if they are different (maybe using hashes) and return a boolean indicating this.
  • path_new
    • From room.h. Allocates space on the heap for a new path pointer. Returns this pointer.
  • add_room_to_game
    • From game.h. Adds a room to a given game struct pointer.
  • add_path_to_room
    • From room.h. Adds path to a given room struct pointer.
  • room_generate
    • In sample_generation.h. Generates and adds a room to an existing game if a new room is entered. Takes care of connecting paths to the new room as well. Calls enter_new_room, add_room_to_game, path_new, and add_path_to_room.

We also may implement an autogen_algorithm function (in sample_generation.h or autogeneration.h) that actually uses an algorithm to autogenerate a random room given a few specifications (we can eventually use this in room_generate). However, this is not the priority for now.

Pseudo-code for possible single-room autogeneration implementation:

  Given two games, gameOld and gameNew (compares two game states).
  Does gameNew have a different current room from gameOld?
  If no, 
      return 1 (UNSUCCESSFUL).
  If yes, get a new room (**autogenerate**).
      Add this new room to gameNew.
      Allocate space on the heap and create a new path.
      Use this new path to connect the current room in gameNew with the new room that was added.
      return 0 (SUCCESS).

Finally, we want to develop concrete tests for these modules before we attempt a pull request.