Project Summary

Space Sim is a space-themed, AI bot-driven, procedurally generated, dynamic game economy simulation developed with the Unity Game Engine.

Project Purpose

The purpose of this solo project has been to get some hands-on experience with solving the challenges involved with creating a virtual world. In this context, a virtual world is a game world that grows and evolves with or without player input and persists regardless of player presence. While my initial work on this project was for a course at my university, my fascination with the topic has since brought me back to continue exploring the idea.

Economy Description

As the economy comes into play in many of the descriptions on this page, it'll help to have a little context for how it works.

The economy consists of raw resources, in the form of gases and minerals gathered from gas clouds and asteroids respectively, and products manufactured at factories contained within space stations. Said products then become the resources for more advanced factories whose products also become the resources for other factories and so on. The scope of this simulation includes four tiers of manufacturing, starting with the processing of raw resources and ending in the production of new ships at a shipyard.

Key Components

This is a complex project consisting of many parts and systems, but following is a high-level list of the main building blocks.

  • A hierarchy of goods ranging from basic minerals and gases, collected in space, to high-tech goods produced at the end of a series of processing space stations.
  • A grid system to simplify the game world object placement and ensure solid performance by facilitating efficient data structures and search algorithms.
  • A procedurally generated resource placement system to distribute gas clouds and mineral rich asteroids automatically in a way that looks organic and can be adjusted to produce interesting game play scenarios.
  • A production facility placement algorithm that can analyze the existing resources and production facilities and determine the best placement of new facilities to maximize the resource utilization across industries.
  • A Stock and Worker Management system that monitors factory stock levels, places orders for stock as needed, and tasks workers with fulfilling those orders.
  • Intuitive factory and worker in-game UI that provides all the info required to monitor the economy simulation as it plays out.

Highlights

Resource Generation System

A key decision I needed to make going into this project was how to handle the placement of the asteroids and gas clouds. As they represented both the most prominent visual feature of the game and the foundation of the game's simulated economy, I needed a placement system that could provide flexibility in both categories.

To solve this problem, I decided to build a tool that utilized procedural generation to populate the game world dynamically. More specifically, a tool that uses a noise map and a suite of settings to determine resource placement algorithmically.

See the videos below for a demonstration of how this tool works.

Stock Management System

To automate the game's economy, I developed an AI system that monitors stock levels in each space station and manages the workforce to ensure shortages are dealt with. When a resource is needed, an order is placed. The system then periodically scans for other space stations that produce the needed resources, spacing out the scans to avoid impacting the game's performance.

Once a space station that has the desired resource in stock is found, an idle worker is assigned to perform the collection. When the worker returns and deposits the resources, the order is marked as complete, and the process begins again. All of this activity is displayed in an in-game UI so that the player can see how stock is being managed. Additionally, I developed a code-based animation system for the docking arms which, together with animated landing lights and in-world UI, clearly communicate how a station's local traffic is being handled.

Results

The culmination of the systems I've developed result in a virtual economy that develops over time without player input or intervention. Starting with production facilities in place and AI ships ready to work, the world immediately comes to life with mining ships gathering resources.

Before long, basic production facilities are in full production and cargo ships start distributing their products - bringing more advanced industries online. Eventually, high-end products are being manufactured and the game world buzzes with activity as dozens of ships busy themselves keeping their respective industries fed.

This process culminates with a shipyard receiving all the high-end products required to manufacture new ships.

Lessons Learned

When concluding work on a project, I often find myself thinking about what I would do differently, given the chance to start over with what I'd just learned. One of my favorite things about this project was how it gave me a chance to explore that idea in practice; to see just how much I could improve on my previous work.

Taking Responsibility for Previous Code

Though I always strive to write code in a way that is self-documenting and easily understood, I don't often get the chance to really put that work to the test. When revisiting this project, I had to work with code that I'd written over a year earlier, so I often needed to rebuild my understanding of exactly what the code was doing. Though I found some of my previous efforts helpful, I also found some lacking, which prompted me to develop several improvements in code organization and documentation moving forward.

Final Thoughts

This project has been, and continues to be, a fantastic source of learning for me. This includes working in Unity, both in-editor development and writing custom editor code, and developing game functionality through custom scripts in C#. There have been so many challenges both big and small and each has been its own little adventure with struggles, epiphanies, and triumphs.

Between my love for the topics covered here (game dev, programming, space simulations, procedural generation, AI, etc. ) and the sense of accomplishment and growth I've felt throughout development, I would gladly dedicate more time to this project.

Experience Gained ++

Here's a brief overview of the many game development aspects that I got hands-on experience with in this project.

  • UI development, including animations, interactive elements, and UI attached to moving objects within the game world.
  • Building chained animations with DoTween to enhance game feel.
  • Prototyping with ProBuilder and assigning materials and colors at runtime.
  • Using Particle Systems to create mining effects, with collection handled by pulling particles to a collider with a force field and counting impacts.
  • Navigation using Unity's NavMesh system, baked at runtime after procedurally generated resources are instantiated to incorporate their static positions without the performance hit of NavMesh Obstacles.
  • Camera layering to create the illusion of a background of nebulae and planets.
  • Built-in Renderer Post Processing.
  • Addressing performance issues with Unity's Profiler both in-editor and in-game.
  • Developing specialized logging tools to streamline debugging with toggleable, class-specific and color coded console output.
  • Developing procedural generation algorithms that must perform quickly while minimizing performance impact to show results in real-time.
  • Developing in-game searching algorithms for locating resources without impacting performance.

Contact

Have questions about my projects or work experience?
Think I'd be a great match for your team?
Feel free to reach out!

ian.ritter.cs@gmail.com