Mp24: Python in gaming industry

Post on 22-Apr-2015

1,876 views 0 download

description

 

transcript

Python in the Game Industry

Jeff PreshingTechnical Architect

Ubisoft Montréal10/24/2011

Presenter
Presentation Notes
I’m Jeff Preshing Technical Architect at Ubisoft Montréal Been working in game industry total of 10 years. More than 7 here in Montreal at Ubisoft. Worked on 8 different game productions. Check LinkedIn to know more.

1. Describe (AAA) Game Production

2. Where Python fits in

3. Examples

Outline

Types of Game Development

Casual Games

Mobile Games

Flash Games

Indie Games

Social Games

AAA Games

Plus: MMORPG, etc…

Presenter
Presentation Notes
For the purposes of this talk, let’s define AAA games as one for “current gen”. Xbox 360 and PS3 consoles, and PC. “Blockbusters” Such as these. Large team, 100-200 people. Big budget. Hopefully lots of sales. This is the type of game development I’m gonna describe in this talk.

Mostly Windows Visual Studio

AAA Game Programming

Presenter
Presentation Notes
What’s it like being a programmer on a AAA game? Windows, mostly. I could probably have written “all”… Bulk of game itself is usually written in C++, though with one or more embeded scripting languages.

AAA Game Programming

Mostly Windows Visual Studio

Presenter
Presentation Notes
When you target one of the major platforms, it requires an SDK. The PS3 SDK is proprietary, under NDA. The PC SDK documentation is publicly avaialble. You really use a kit! Like embedded systems. Unlike iPhone where you have a simulator.

Structure of a Game Production

Presenter
Presentation Notes
Structure of game production. (Again, large AAA team, but much of it applies to other types.) Programmers submitting code. Content creators (artists, designers) submitting data. It’s all source material. You need (many) build steps to turn it into a game. On a large team, automated by a build farm (Indie game may not have this step.) Ultimate goal is to produce the Game itself. QC tests the game and reports issues (for progs and CC). Behind every game, there is an editor. So you’re basically developing / maintaining two products in parallel. That’s why you see two loops here. Should mention: Online back-end. Can be a production in and of itself. Especially for big online scope. I’ll let Pierre from Quazal talk about that. Leaving out … management, designers, technical services. Where can Python fit in, where does it fit in?

Structure of a Game Production

Presenter
Presentation Notes
If you look at all projects / all studios, there are people using Python in every place. Obviously, programmers use it. Not all. But it’s advantageous to know. So more and more are learning. Ubi offer Python training Content creators use it for third party tool scripting. At some studios, the editor is written in Python. The game itself? As I mentioned, embedded scripting language. Civ 4 used it. So did Eve Online. But it’s rare within AAA games.

Third-Party Tools Scripting

• Autodesk Maya(Python, MEL)

• Autodesk Softimage XSI(Python, C#, VBScript, JScript, C++)

• Autodesk MotionBuilder(Python, C++)

Presenter
Presentation Notes
Content creator is not only working with in-house editor we provide. All of these tools support Python as a scripting language.

MotionBuilder – Integrated Python Editor

Presenter
Presentation Notes
MoBu has a built-in editor. Window Python Editor, you can edit & run without leaving MoBu.

MotionBuilder – Python-based Plugin

Presenter
Presentation Notes
You can extend the UI to do anything you want. We use it to import and export the scene. Lot of data to gather from different sources (skeleton, mesh, anim). Such plugins can really assist with the workflow. Making sure everyone follows the same steps, and those steps are always correct.

Build Steps

1. Sync code (< 1 min)2. Build editor (5 – 10 mins)3. Sync data (< 1 min)4. “Cook” data (1 min – 1 hour, depends)5. Build game (5 – 15 mins)6. Deploy to kit (sometimes)

If only this was automated…

Presenter
Presentation Notes
You saw all the steps that went into building a game. All of those steps need to happen on a programmer’s PC. Several times a week, maybe even daily. But it’s time consuming.

OvernightScript.py – End of Day

Presenter
Presentation Notes
In all the recent projects I’ve worked on, I’ve had a Python script to do all that overnight.

OvernightScript.py – Next Morning

Presenter
Presentation Notes
UI may not be sexy, but it’s reliable Hit the ground running, run on console, with local changes + latest changes. A good percentage of the team is using this.

OvernightScript.py – Archived Logs

Presenter
Presentation Notes
Logs are compressed and archived. Have details about everything that happened.

Notifications

Presenter
Presentation Notes
With all the data flying around, people submitting to various repositories, there are a lot of notifications. It’s important esp. for managers to know what’s going on. Individual e-mails are spammy.

Notifications

Presenter
Presentation Notes
We have a Python script to scrape the repository and send aggregate notifications. A bit easier to follow. Also report most recent issues.

• Analyze MAP files• Custom build steps for SPU ELFs• Code sweeps

• #include < >• Upgrading middleware• Fix C++ initializer lists

• Locate debug information • Precompiled header optimization• Debugging• Log file merging

Many Other Examples…

Presenter
Presentation Notes
MAP Files : To save memory (a precious resource) SPU ELF : Patch the assembly. Team member learned Python just for this. A lot of stuff which a few people might have used Perl for, before Python came along.

Logging System

eg. For mismatched reference counts.

Presenter
Presentation Notes
There are a whole class of bugs which are best debugged via logging. Like certain Reference Count mismatches. (Many engines use reference counting for game objects.) Especially when there are too many decrements, and the target object is destroyed early. You need to pinpoint the bad inc/decrement out of hundreds. Usually, the system is fairly robust using smart pointers, but accidents still happen. (I’m interested in how people manage this problem in CPython?)�

Logging System

For each event:

• Thread ID• Timestamp• Message• Callstack

Logging System

Very big log files!

• Log file is compressed using BZ2• Parsing step handled in C• Script just sees event objects

Presenter
Presentation Notes
That’s a lot of data to log. 10 million events.

Logging System

Post-mortem log analysis via Python scripting.

Presenter
Presentation Notes
Once I’ve crashed and I see that the deleted object is at a certain address, I can whip up a script to analyze the inc/dec events (with callstacks) leading up to it. Handy when hard to reproduce. Similarly, this can be used to track down memory leaks, corruptions, fragmentation problems. We have a custom in-house tool for that, though Alex extended the tool to support Python scripting.

Thanks toAlex Camano Alonso

Dave BélangerPatrick Duquette

Nicolas FleuryRichard Malo

Pierre-Marc Simard

Questions?