Design of Data structures

Started by
3 comments, last by LorenzoGatti 15 years, 6 months ago
I'm trying to design my data structures. I'm using python. I'm working on a space game, Although that could change. Right now I'm concerned with economics. Specifically, i want a system with workshops(smelters, centrifuges, machine shops) that can do things to resources. Some things will be assembly line generic(liquid oxygen, microporcessors). ...but some things will be unique (Bottled Air: 77% Nitrogen, 20% Oxygen, 1% water, .4% CO2, .6% inert gas). I know how to add two bottles of air together using weighted averages to calculate the resulting composition. ...and some things are absolutely unique. Artifacts, if you will. Captain Jimmy's command pod. The Magic Interstellar Teleporter we stole. These will have thier own properties. I'd like to figure out an inventory system, but I don't know where to start. It's important to me that I be able to later add things like temperature, or shock sensitivity. Storing nitroglycerin in a workshop that gets bumped produces a bigger bump, but that's for the future. Now I just want to figure out how to build an inventory that handles uniques AND generics.
Advertisement
How are uniques handled differently than generics in your inventory?
That's what I'm trying to figure out. I'm asking for design advice. Pointers to artcles on organizing data. Helpful hints. Directions to think in.

Complete solutions(HA! not likely)
I'm not sure why there is any difference between those two (three?) types. A unique item will only appear once in your game's assets - in that case, there's no need to differentiate it, is there? You can add a boolean flag for uniques if you want, for some programmatic checks or as a hint/option for the level designers maybe?

To start with, just figure out what property types every item has in common. For instance:
name
deescription
sprite
3d model
stackable yes/no (optional)
weight
bulk
unique yes/no (optional, design choice?)

These will make up the data members of your Item class. Now add an Inventory class which is a container for Item objects (a hashmap of Item and quantity (in Python you could, I think, use a dictionary that maps the Item's GUID to the quantity), maybe, unless each Item object is instanced - you might want to think about Item instance vs Item blueprint, in cases where you want say a red bottle that is full and a red bottle that is half full, ie if you want to modify properties of individual items). Any station or agent or whoever needs an inventory should include an Inventory object. That's the gist of it, imho.
Maybe generic objects are merged with similar ones in inventories and unique objects are those that never find a similar object to form a pile, without an explicitly different treatment.
Unique objects are special in a different way: their creation mechanisms ensure uniqueness or differences.
For example every citizen has a SSN and every starship has a license plate (taken from counters), Captain Jimmy's command pod is linked to Captain Jimmy which is presumably scripted in such a way that it appears once, etc.

If you are emphasizing substances and inventories and fabrication, maybe you can also deal with containers and assemblies:

4 so and so uranium rods in rugged individual boxes + an empty reactor loading rack + half an hour of engineer work with a small crane = a lightweight but unwieldy and unprotected assembly ready for the reactor + 4 empty fuel rod boxes


Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement