• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# How Many Lines of Code in a Commercial Game?

## Recommended Posts

Spindle    122
The subject pretty much says it. How many lines of code, average in a commercail game?

##### Share on other sites
IgniteSoft    122
on average I would say 500,000+

Ignite Software Ltd.

##### Share on other sites
gph-gw    122
Black and White had 2,000,000+ lines, most of it AI.

zbarrier1    122
Black & White did take approx. 2 million lines of code. To give you a little taste of what all went into the project, Lionhead Studios had 25 full-time developers, 3 contractors, a budget of approx. $5.7 million, it took 3 years, 1 month, and 10 days to complete. This is more than the average game today, but expect it to be the standard a in a few years. #### Share this post ##### Link to post ##### Share on other sites 2 000 000 lines! That''s pretty big Anonymous Programmer #### Share this post ##### Link to post ##### Share on other sites bullet182 122 Wow, that''s absolutely amazing... Hehe, in the old IBM prog days, those developers would be rich, would have got paid by the K loc ;] ^_^DATO #### Share this post ##### Link to post ##### Share on other sites I wouldn''t say 500,000 is average; that''s probably a bit on the high side. From my experience 150,000 to 200,000 is a bit closer to normal. Some projects breach the 300,000 barrier, but 500,000 is a rare case AFAIK. It''s true that the games are getting more complicated so the LOC count will continue to go up over time, but by the same token the programmers are (hopefully) learning more so they can gradually figure out how to do more with less code. The two don''t necessarily cancel each other out entirely, but it does slow down the rate of LOC count increase. I suspect 2,000,000 LOC will be way above the norm for quite some time. #### Share this post ##### Link to post ##### Share on other sites gph-gw 122 quote: Original post by bullet182 Wow, that''s absolutely amazing... Hehe, in the old IBM prog days, those developers would be rich, would have got paid by the K loc ;] ^_^DATO You couldn''t make a game run fast on an old IBM pc if it was 500,000 lines, much less 2,000,000. If you could then you''d be a billionaire. Black and White was really ahead of it''s time, IMO it would be even more fun on really fast computers of the future(3.0Ghz+) because then the ai could really take off. B&W''s ai is the taste of what''s coming. If you read Game Developer Magazine''s "Game AI: State of the Industry" articles you''ll see that as processor time is freed due to things like HW T&L, good hardware sound/MIDI/DLS, and amazing processor speed increases, more time is given to AI. I would amagine that one day almost all of the processor is going to be physics and AI - all of the graphics and sound is offloaded onto hardware. Maybe one of the next big things is hardware physics - can you imagine what kind of games we''ll have then? #### Share this post ##### Link to post ##### Share on other sites Neophyte 595 Here are the stats I''ve managed to dredge up on a couple newish games:   Star Trek: Voyager - Elite Force 1.000.000 lines of code 4.000 filesUnreal Tournament: 350.000 lines of codeAsheron''s Call: 2.000.000 lines of codeFallout Tactics: 300.000 lines of code 1500 filesVampire : The Masquerade - Redemption 350.000 lines of code  (Numbers taken from the developers themselves) -Neophyte - Death awaits you all with nasty, big, pointy teeth. - #### Share this post ##### Link to post ##### Share on other sites brettporter 122 but how many are blank? I bet they use next line { indentation and lots of commenting compared to the others. The old Sierra hint books used to say how many lines of code there were, and I think they had >1M but they also had about 70% blank (that would''ve included the engine and the script though) ~~~ Cheers! Brett Porter PortaLib3D : A portable 3D game/demo libary for OpenGL #### Share this post ##### Link to post ##### Share on other sites I can guarantee you that the projects with numbers in the millions of LOC are adding in not just normal engine/gamelogic code, but also specific game scripts. Yes I know some people will argue "but it''s still code!", but I still have a problem with it. People can take code-driven or data-driven approaches to all sorts of different problems. Plenty of specific scripted situations can be done both in code-driven form (via a simple scripting language), or in a data-driven form (some kind of dialog-box-based thing that indicates the actions that occur at certain times in a tabular manner). I reminded myself of this recently when doing some skeletal animation work. Adding in script code that handles common/essential game logic (like damage or weapon control or primitive AI or whatever) is fine, and that should certainly count in terms of LOC. But scripts for things like "on level 3 I want this guy to play this sound and then run to this point over here" should certainly *not* count, because in theory the same thing could be done in a data-driven manner, and you wouldn''t add data into an LOC count. I''m pretty certain if you took out all the LOC for these kinds of scripts, the LOC count would drop back out of the stratosphere into something more in line with the rest of the projects. #### Share this post ##### Link to post ##### Share on other sites LordElectro 122 Am I the only one that doesn''t see "2 million lines" worth of AI in Black and White? Honestly, the AI didnt impress me at all. It may have been using all sorts of mathematical mumbo jumbo, but in the finished product, you get a creature that can learn to poop on villages. The whole environment of black and white isn''t very versatile at all, and there isn''t all that much possibilities for the creature to do stuff. I really think the AI code was an ego trip, they could have accomplished much of the same with far less code and a simpler approach. Isn''t that what game programming is anyway? Taking shortcuts that allows us to do stuff that traditionally requires far more complex methods? This is kind of off topic, I know but I really think Black and White wound up wasting a huge amount of development resources for what it accomplished. #### Share this post ##### Link to post ##### Share on other sites gph-gw 122 quote: Original post by LordElectro Am I the only one that doesn't see "2 million lines" worth of AI in Black and White? Honestly, the AI didnt impress me at all. It may have been using all sorts of mathematical mumbo jumbo, but in the finished product, you get a creature that can learn to poop on villages. The whole environment of black and white isn't very versatile at all, and there isn't all that much possibilities for the creature to do stuff. I really think the AI code was an ego trip, they could have accomplished much of the same with far less code and a simpler approach. Isn't that what game programming is anyway? Taking shortcuts that allows us to do stuff that traditionally requires far more complex methods? This is kind of off topic, I know but I really think Black and White wound up wasting a huge amount of development resources for what it accomplished. Not all of it was AI, there was scripting, sound, graphics, and that sophisticated "gesture" system also. Compared to the billions of "instructions" our brain processes per second I'd reckon that they did an okay job. The ai is better later in the game, too. At the beginning all you have is one dumb creature. Oh, and you can bet that it's not 2,000,000 lines of C code. No doubt they added quite a bit of assembly as well. Edited by - gph-gw on August 2, 2001 9:31:51 PM #### Share this post ##### Link to post ##### Share on other sites Guest Anonymous Poster quote: Oh, and you can bet that it''s not 2,000,000 lines of C code. No doubt they added quite a bit of assembly as well. What makes you certain they added quite a bit of assembly? You know, compilers are pretty darn good these days, and processor pipeline issues are getting more and more complicated to where a person has a hard time knowing all the rules all the time. Where do you think any significant amount of assembly was used? I mean, I used to love working in assembly, but the reality is there simply isn''t enough of a need for it anymore except in the most extreme inner loop cases (and those inner loops are inherently small in size and thus don''t require "quite a bit" of assembly). Not only that, but projects these days are so expensive to develop that the extra time (and resulting cost) to put a large chunk of code into assembly, and maintain it thereafter (maintaining being the difficult part) generally overrides any possible speed gain you might hope to achieve. A few small inner loops? Okay. Large chunks? Heck no. #### Share this post ##### Link to post ##### Share on other sites gph-gw 122 Well, with a game with a budget like Black and White it would make sense to use some assembly, like you said. But have you ever actually carefully examined output from VC++? It''s not the same quality thet you could get with fine, hand tuned asm. Certainly, since the source is closed, we aren''t going to know until they decide to release it, if they ever release it. It also uses MMX and possibly SSE or 3DNOW, right? So unless they used the intel c/c++ compiler they''ve used asm. And it''s best if the code is uniform, right? So therefore it makes sense if they use a good amount of assembly. You''re right in that most of the code is not asm because if not then it would be a$20 million and take 5 years.

There''s no evidence either way, so we could post about it until our ears bleed without getting anywhere.

And you could argue that a few small inner loops could constitute "quite a bit of asm".

##### Share on other sites
Beer Hunter    712
quote:
and that sophisticated "gesture" system also

Someone posted a gesture recognition program somewhere around here a couple of months ago. The recognition core fit in a single page of code. So unless Lionhead did something massively different, that''s not really contributing to the 2 million lines of code

##### Share on other sites
Kylotan    9860
quote:
Original post by gph-gw
And it''s best if the code is uniform, right? So therefore it makes sense if they use a good amount of assembly.

That''s a very bizarre argument. They''re not going to have coded a lot of it in assembly just because it would make the code uniform. They''re going to want as much of the code as high-level as possible, because it is easier to understand and debug, with any assembly used only in the very tight loops. Remember the Pareto Principle in this context: 80% of the execution time is spent in only 20% of the code. The Lionhead guys are smart, realise this, and wouldn''t waste time on using assembly where a high level language would do. A lot of games released these days don''t even have a single line of assembly. So it makes sense to assume there was no or little assembly unless there''s evidence to the contrary.

##### Share on other sites
gph-gw    122
What I meant by uniform code is that it''s clean, not sloppy, and that everybodys code works together very well. I didn''t mean they coded everything in assembly just because a bit of it was.

I would believe that in a 2,000,000 line game there would be a larger number of tight code spots than in a 500,000 line game. So they would optimize those sections of code further. Especially since they spent so much time on it, perfecting it. I''m able to run it at semi-high quality and I don''t have a super fast computer. That suggests there''s some kind of optimization.

##### Share on other sites
LordElectro    122
quote:
Original post by gph-gw
Not all of it was AI, there was scripting, sound, graphics, and that sophisticated "gesture" system also. Compared to the billions of "instructions" our brain processes per second I''d reckon that they did an okay job. The ai is better later in the game, too. At the beginning all you have is one dumb creature.

Oh, and you can bet that it''s not 2,000,000 lines of C code. No doubt they added quite a bit of assembly as well.

Edited by - gph-gw on August 2, 2001 9:31:51 PM

The two million was in quotes for a reason

The point is that the AI of BW has become such a big deal and supposedly took huge amounts of time. However the end result is a creature that no matter how much you train it, wont really be all that exciting and neat. Okay, so it will poop on the villagers. Yea, you can make some complex AI mumbo jumbo, or you could just write a few simple lines of code so that sometimes the creature will decide it''s a good idea to poop on the villagers and eventually be trained out of it using a system similiar to that of the Windows/Office menus where only the stuff you use often is shown. All you need is some counters and bit of randomness. I''m sure that scientifically speaking, the AI in BW is amazing, but it''s a huge waste because the game world it was placed in is extremely limited. It has some trees, some rocks, some villagers, some wood, and that''s about it. And those things can be used in very limited ways. So what you wind up with is a lot of code that has gone to waste, while critical aspects of the game were made oversimplistic (likely because they wound up with no time to make them better) and very limited gameplay.

Lionhead fell into the trap of using all this advanced stuff, and wound up with a huge game significantly less fun than PacMan. That should tell you something about where gaming is going :/