1 Object Systems Methods for attaching data to objects, and connecting behaviors Doug Church.

Slides:



Advertisements
Similar presentations
Chapter 25 Lists, Stacks, Queues, and Priority Queues
Advertisements

Shared-Memory Model and Threads Intel Software College Introduction to Parallel Programming – Part 2.
2006 Pearson Education, Inc. All rights reserved Object-Oriented Programming: Polymorphism.
Using Matrices in Real Life
Analysis of Computer Algorithms
Chapter 7 System Models.
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
Chapter 7 Constructors and Other Tools. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 7-2 Learning Objectives Constructors Definitions.
Copyright © 2003 Pearson Education, Inc. Slide 1.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 1 Embedded Computing.
By Rick Clements Software Testing 101 By Rick Clements
1 Hyades Command Routing Message flow and data translation.
Writing Pseudocode And Making a Flow Chart A Number Guessing Game
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 5: Repetition and Loop Statements Problem Solving & Program.
10 Copyright © 2005, Oracle. All rights reserved. Reusing Code with Inheritance and Polymorphism.
DCV: A Causality Detection Approach for Large- scale Dynamic Collaboration Environments Jiang-Ming Yang Microsoft Research Asia Ning Gu, Qi-Wei Zhang,
1 The design of presentation slides Stephen Bostock.
Mike Scott University of Texas at Austin
Photo Slideshow Instructions (delete before presenting or this page will show when slideshow loops) 1.Set PowerPoint to work in Outline. View/Normal click.
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Computer Literacy BASICS
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 10 Arrays and Tile Mapping Starting Out with Games & Graphics.
Configuration management
Databasteknik Databaser och bioinformatik Data structures and Indexing (II) Fang Wei-Kleiner.
The Racing Game of Knowledge Continue Questions – push on trees
Red Tag Date 13/12/11 5S.
Information Systems Today: Managing in the Digital World
Software testing.
Chapter 17 Linked Lists.
Singly Linked Lists What is a singly-linked list? Why linked lists?
DATA STRUCTURES AND ALGORITHMS Prepared by İnanç TAHRALI
David Luebke 1 6/7/2014 ITCS 6114 Skip Lists Hashing.
Linked Lists Chapter 4.
Chapter 24 Lists, Stacks, and Queues
11 Data Structures Foundations of Computer Science ã Cengage Learning.
Abstract Data Types and Algorithms
Campaign Overview Mailers Mailing Lists
Chapter 1 Object Oriented Programming 1. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Hash Tables.
1 Symbol Tables Chapter Sedgewick. 2 Symbol Tables Searching Searching is a fundamental element of many computational tasks looking up a name.
Semantic Analysis and Symbol Tables
© Paradigm Publishing, Inc Access 2010 Level 1 Unit 1Creating Tables and Queries Chapter 2Creating Relationships between Tables.
Microsoft Office Illustrated Fundamentals Unit K: Working with Data.
Yong Choi School of Business CSU, Bakersfield
Microsoft Access.
Vanderbilt Business Objects Users Group 1 Reporting Techniques & Formatting Beginning & Advanced.
Access Tables 1. Creating a Table Design View Define each field and its properties Data Sheet View Essentially spreadsheet Enter fields You must go to.
Memory Management.
The Modular Structure of Complex Systems Team 3 Nupur Choudhary Aparna Nanjappa Mark Zeits.
Chapter 5 Plan-Space Planning.
Chapter 10 Software Testing
Indexing.
Pasewark & Pasewark Microsoft Office XP: Introductory Course 1 INTRODUCTORY MICROSOFT WORD Lesson 8 – Increasing Efficiency Using Word.
Chapter 10: The Traditional Approach to Design
Systems Analysis and Design in a Changing World, Fifth Edition
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Intracellular Compartments and Transport
PSSA Preparation.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Chapter 11 Creating Framed Layouts Principles of Web Design, 4 th Edition.
Essential Cell Biology
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Exception Handling Outline 13.1 Introduction 13.2 Exception-Handling Overview 13.3 Other.
Modeling Main issues: What do we want to build How do we write this down.
User Defined Functions Lesson 1 CS1313 Fall User Defined Functions 1 Outline 1.User Defined Functions 1 Outline 2.Standard Library Not Enough #1.
Data Structures Using C++ 2E
Chapter 9: Using Classes and Objects. Understanding Class Concepts Types of classes – Classes that are only application programs with a Main() method.
Benchmark Series Microsoft Excel 2013 Level 2
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
IT253: Computer Organization
Methods for attaching data to objects, and connecting behaviors
Presentation transcript:

1 Object Systems Methods for attaching data to objects, and connecting behaviors Doug Church

2 Outline of Talk Quick definitions Progression of object data complexity The problem in the abstract Current approaches to this problem Small Case Study Problems, lessons, and tradeoffs

3 Why an object system Games have more and more objects to track Compared to years ago, these objects are –more diverse (different types of data) –more dynamic (data and fields change often) –much larger –support more emergent behaviors Game object data has become a major part of our games, worth real analysis

4 A brief history of Objects The goal of this section is to make clear the complexity of objects in some modern games. We will examine a sequence of object models, from simplest up, looking at how they handle the data issues.

5 Hard-coded Constants Objects simply have type and position All behaviors are implied from this A big static array of objects No save/load or versioning ex. Space Invaders like games

6 Simple object structures ~5 custom structure types (npc, weapon) Each has a common beginning (location, id) Each has custom fields (hp, damage, speed) Often pre-sized static arrays for each type Simple save/load w/o versioning ex. basic RPG circa 1990

7 C++ hierarchy Just use C++ inheritance as is Objects are simply class objects Derived classes add new fields Binary rep not trivial to effectively version –Though C++ makes serialize functions easier This initially was just data, not code

8 Example: Space Invaders Like All objects have same data Type data used to control behavior Your Ship, Enemy Ships, Bullets, UFO Global state (remaining enemies, time) used to control enemy speed, animation –Probably position too, really Object -Type -Position

9 Example: Tempest Like More types of enemy ship, with more individualized/asynchronous behavior More data to store per object Object -Type -Position -Speed -Animation

10 Example: Old School Tile RPG Several game object types, some common data, but also type specific information Many specific objects Object -Type -Location Creature -Goal -Motion -HP -Text Treasure -Value Gear -Worn At -Damage -Value

11 Example: More complex RPG But how do I make –a spiky tree that does damage? –a sword that talks? Object -Type -Location Creature -Goal -Motion -HP -Text Treasure -Value Gear -Worn At -Damage -Value

12 Example: More dynamic RPG What if I want some objects to be able to catch on fire, be poisoned, or make a sound when hit, or… Do we just start moving all possibly necessary data up into the basic object? This may sound like a few simple things, but a modern simulation has hundreds, if not more, potential data fields to track

13 If you dont believe it can really get extremely complicated Some Example Screenshots (from the Thief Game Editor) Object Browser Specific Object Property List Property Editing on an Object

14 Object Browser

15 Specific Object

16 Property List

17 Property Editing on an Object

18 Lesson As we get more complex, simple approaches break, data becomes more sparse and pushing it up the tree is very inefficient in terms of space, and it is hard to manage the data effectively Picture trying to put all that data in the basic object… or dynamically resizing and repacking objects with inlined fields… or?

19 So what do we do about it? Various cool approaches from real software View it all as a relational data base Build in introspection like capabilities Attach code to objects for flexibility Support varieties of storage forms Inheritance and instantiation of aspects

20 What sorts of choices do we have Is the data stored with objects or properties? Major speed/space tradeoffs for retrieval How does inheritance and overriding work Where are the behaviors associated with the property? In scripts, in game code, in both? How different are abstract and concrete objects? How dynamic is the system? Can you create types at run-time? Change properties on abstracts?

21 Some approaches Particular approaches from recently shipped games

22 Halo Object-centric view Fixed size block (stored in an array) –Position, velocity, and a pointer to the variable block Variable sized block (stored in a heap) –Subsystem dependent properties (AI, physics models, effects) Class hierarchy of types Shipped with 11 leaf classes –things would have been much easier if wed specialized more Function evaluation system Jeep velocity jeep brake lights to get backup lights Plasma rifle heat value heat display meter

23 Thief Property-centric view of the world –Objects are just IDs, and can have any property –Of course, many have implicit rules of use and relationships Programmers code property behaviors –Publish property fields, value range, help message to edit tool –Flexible implementations, allowing a speed/space choice Scripting works with property system –Scripts can be attached and inherited like other properties –Script system can easily read/write property values Links between objects –Avoid out-of-date object reference bugs –Ability to attach data to connections (timeouts, etc) –Allow multiplicity… an object can care about lots of others at once abstract objects, several thousand concrete objects

24 Dungeon Siege Property-centric view Property hierarchy with single inheritance Components are compositions of properties Highly integrated with scripting language Properties can be written in C++ or script language Properties can have scripts attached Components in hierarchy Discouraged designers from dynamic component creation –I dont want our designers mixing and matching types Designers wanted lots of prefab types for authoring speed –tree_waving, tree_bushy, etc leaf classes when shipped

25 Thief Property System Implementation Details A Quick Case Study

26 Major goals Allow systems to quickly iterate over the data and objects they care about, dont force indirections Programmer chooses what cases to optimize for, but system automatically supports all cases Maximize designer flexibility and control Allow scripting, but dont depend on it A property should be implemented with as little impact on other systems as possible Most properties are sparse, so creating and adding properties must be a light weight decision

27 Coding with the system Objects are only an ID One references a property by GUID (which you can get by asking the Property Manager for a GUID for a given name) –IProperty *pProp = GetProperty(HitPoints) Given a property, ID gets the data –int hp = pProp->GetIntProperty(ID) Cannot change the data in place, need to call Set For Structures, pass reference to pointer you want

28 Property Implementation A collection of data storage models are pre-built, instantiate the template for your type –Arrays, individual hash, shared hash, bitfields Define the fields of the property by name Can deal with properties in two ways –Given an object, query about the property –Iterate over all objects with the property Which data store you use depends on your primary usage case, and how often you reference it All of this property code is very localized

29 Example: Physics Physics needs fast random data access about all physics objects while in physics loop Physics keeps a linear array of data –Array has all physics information + Object ID –Supplementary hash connects ID -> array Physics loop, therefore, just operates on its own array –No indirections or overhead, just use the array information –Can use the ObjID to get the values of any other properties Other systems which need physics data go through GetProperty, which internally calls the physics storage model, hashes the ID, and returns array data for that object

30 Sadly The object tree is big, so object based property lookups end up being relatively slow This is because many property retrievals require a traversal of the entire tree So we need to reduce the tree searches When we find a property value, cache it at the lowest abstract level of the tree Future lookups will find the cached version Note: Need careful coding to make sure that cache invalidation works right when tree changes

31 Designer Usage Programmers expose a name and valid data ranges for each field of each property Designers can place properties on (and links between) objects, and change attached data Designers create and maintain the object hierarchy, decide how to define the world Can create simple (int) properties by name

32 Specific Object (again)

33 Major Issues Object creation time too long –Have to ask each property what it wants to do –(machine gun bullets in Combat Flight Sim) Programmer Complexity… to meaningfully use the system, steep learning curve Tools were not robust until the middle of the development –So we missed chances to do things right earlier –Lots of code from earlier unfinished period shipped Property systems underlie the game, so changes to them impact large sections of the code –The system allows easy change to property code –But changes to the system itself are not so easy

34 Problem Example #1 Hierarchy, inherited value, local override –What happens when global value changed –Several subtle issues, for instance: If a local property has same value as global, do you save it out, or do you auto-delete it as it is redundant Of course, if you remove it, and the global changes, then you lose the original set value Probably want the local to remain itself even when shadowed by the same global setting

35 Problem Example #2 Failed queries can take a lot of time –Determining a property is missing requires a full search up the tree –Successful lookups are stored in cache –To deal with failure problem, they must be too This fixes the speed problem –But requires extra cache space and complexity

36 Typical Object System Design Frustrations Object creation time can get very large Need tools which show why a given property value is on a given object –Esp. when debugging the system itself Your designers will use the system… be prepared for very creative usage Educating the team is vital! Designers and programmers both must get it