Skip to main content
GameDev.net gamedev.net
🔒 Locked

Your Game Engine!

Started by LevyDee Oct 27, 2011 at 8:31 AM 32 replies 7.8k views
Original Post
LevyDee
LevyDee
I'm just kind of curious for comparison, but I was wondering how many lines of code is your game engine(if you are working on, or have made one!)? I wrote a script to count my header and .cpp file lines, and including my server, client + the actual engine, I'm at 8300 lines of code(white space included).

What about you guys? I really have no idea what is "normal" for the size of a game engine.
jamesleighe
jamesleighe
I have no way to count but it would have to be roughly 30,000 lines so far (still allot of work to go, and not including game code).

But remember what Bill Gates said, "Judging progress on software by lines of code is like judging progress on an aircraft by weight" or some-such.
mcmuzzle
mcmuzzle
Just a suggestion if your engine is in c/c++, instead of counting line of code, count line with a ;

It's still pretty useless but it make lore sense comparing as people have different coding structure.
Radikalizm
Radikalizm

I'm just kind of curious for comparison, but I was wondering how many lines of code is your game engine(if you are working on, or have made one!)? I wrote a script to count my header and .cpp file lines, and including my server, client + the actual engine, I'm at 8300 lines of code(white space included).

What about you guys? I really have no idea what is "normal" for the size of a game engine.


I doubt there's such a thing as a 'normal size' for a game engine, and it's generally a bad idea to attach any value to the amount of code you've written instead of the quality of code

EDIT:

To contribute to this thread, mine has about 70000 lines of code right now
I gets all your texture budgets!
Dawoodoz
Dawoodoz
The number of lines in the current engine is about 60000. Reducing the number of lines using well defined functions will reduce the possible errors both by reducing the lines that can have a bug and by spending more time on each line. When I started with the engine, it was twice as big and had about 15 times as much CPU overhead by using DirectX utility instead of having everything custom made.
LevyDee
LevyDee
Interesting responses! BTW I wasn't measuring my engine by line count, I am just curious!
StephanieWhite
StephanieWhite

Interesting responses! BTW I wasn't measuring my engine by line count, I am just curious!


i dont use engines. i write all my code free and mainly only apply to global containers for data and few files. i try to do it all at one and don't like the sense of all that "engine" work.
Postie
Postie
Not sure about the lines of code, but the current project I'm working on has about 1.4 megabytes of C# source.


[size="2"]Currently working on an open world survival RPG - For info check out my Development blog:[size="2"] ByteWrangler
Tachikoma
Tachikoma
Not sure about lines of code for us either, our iOS game has 2 MB of C code. After 1 MB C stops being fun.
Storyyeller
Storyyeller
My largest game is around 25k loc, but a lot of code is related to defining level layouts and entity behaviors, so it might not be considered part of "the engine".

Of course, the separation between game and engine is subjective and often not a meaningful division. Assuming you use the design and refactor approach to "engine" development, an engine is simply behavior that is common to more than one game.
I trust exceptions about as far as I can throw them.
j-dog
j-dog
My last engine was just over 20000 lines. This is something I was initially quite proud of since it was (and still remains) the largest project I had done, but in retrospect it could and should be less. For instance, I think some parts of the engine (the "outer layers" and some structures) are designed rather elegantly and take up fewer lines. While other parts - especially my UI implementation, gets quite hairy and cumbersome. For instance, I have some functions that take in 13 parameters!! That's just awful design.

Bottom line: less is more.
DarklyDreaming
DarklyDreaming
Last count was 70K for engine + level editor + character editor (don't know the exact number, sorry) and around 20K for the game.

Not that I work that much with building things from scratch nowadays anyhow.
"I will personally burn everything I've made to the fucking ground if I think I can catch them in the flames."
~ Gabe

"I don't mean to rush you but you are keeping two civilizations waiting!"
~ Cavil, BSG.
"If it's really important to you that other people follow your True Brace Style,
solenoidz
solenoidz
Mine shows 22094.
I'm using Visual C++ 2008 and the following regular expression in "Find and replace->Find in files" dialog :
^~(:Wh@//.+)~(:Wh@\{:Wh@)~(:Wh@\}:Wh@)~(:Wh@\#).+
Servant of the Lord
Servant of the Lord
The last time I measured it, many months ago, my project was slightly over 11,000 lines of code, with 5,000 being statements (and the rest either class defines or comments or whitespace).

You can use SourceMonitor to check your own project's stats, regardless of what IDE you are using. It records alot of useful stats, and helps you keep your project in a cleaner state by showing you what parts of your code is too bloated and is in need of refactoring.
Krohm
Krohm
You can use SourceMonitor to check your own project's stats, regardless of what IDE you are using.
Thank you very much! I have been searching for this for a while! Perhaps I should have tried harder!


I got (not including gameplay)
  • 617 Files
  • 81k LOC
  • ~57k statements
  • 20% branches (uhm, didn't expect so much, is this good?)
  • 12% comments
  • 743 classes
  • 5.6 methods/class
  • 10.2 statements/method
  • Max complexity 121
  • Max depth 9+ (I guess that's really bad?)
  • AVG depth 1.81
  • AVG complexity 3.70 (is this good or bad? I'm not sure I get what the metric is supposed to mean)
  • Functions: 340
Previously "Krohm"
Servant of the Lord
Servant of the Lord

  • [color=#1C2837][size=2]Max complexity 121
  • Max depth 9+ (I guess that's really bad?)
  • AVG depth 1.81
  • AVG complexity 3.70 (is this good or bad? I'm not sure I get what the metric is supposed to mean)

Max depth and average depth has to do with how many nested statements are in a single function. Your average depth is good. On average, your functions only go 1.81 nests deep. Your max depth isn't that great, it means some functions go over 9 nests (9 pairs of brackets stacked on top of each other) deep. This means, on average your functions are very good, but there are still some functions that need to be refactored into several smaller functions to improve code readability and simplicity. I haven't used SourceMonitor for four or five months, so I don't remember to well, but I think it tells you which functions are the bad ones.


void myFunction()
{
//Depth of 0

if(x)
{
//Depth of 1
}

if(y)
{
//Depth of 1

for(...)
{
//Depth of 2

if(q)
{
//Depth of 3 //<--- Max depth for this function
}
}
}

if(z)
{
//Depth of 1
}
}



Code complexity has to do with how complex a function is.

//This function is hardly complex at all.
void myFunc()
{
if(x)
{

}
}

//This function is only slightly complex.
void myFunc()
{
if(x && y)
{
if(z)
{

}
}
}

//This function is complex.
void myComplexFunc()
{
if(x && (y || !z))
{
for(...)
{
if(a)
{

}

}
}

while(...)
{
if(!b)
{

}
else if(c == a)
{

}
else
{
if((a != q) && (q > b)
{

}
}
}
}


I don't know exactly what formula they use to measure complexity, but smaller is better. The point is still the same: to encourage you to break functions up into smaller bite-size functions, instead of monolithic ones that are harder to follow the logic of, and thus more likely to contain bugs, or harder to change, or to be more difficult to read a year from now.

So, your average complexity and depth is the more important thing; but the max complexity and depth helps you measure the worst offenders.
Postie
Postie

You can use SourceMonitor to check your own project's stats, regardless of what IDE you are using. It records alot of useful stats, and helps you keep your project in a cleaner state by showing you what parts of your code is too bloated and is in need of refactoring.

Whoa.. very cool find!

Stats from my project:

  • Files: 102
  • Lines: 33K
  • Statements: 14K
  • Comments: 5.5% <-- hmmm i should do something about this
    Not surprisingly, my A* implementation and Text layout functions are flagged as having high complexity.
[size="2"]Currently working on an open world survival RPG - For info check out my Development blog:[size="2"] ByteWrangler
Matias Goldberg
Matias Goldberg
519 text files.
498 unique files.
2810 files ignored.

http://cloc.sourceforge.net v 1.55 T=5.0 s (62.8 files/s, 13471.8 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 107 5552 8910 28917
C/C++ Header 157 3252 3264 11075
Lua 46 988 569 4557
CMake 1 31 34 125
DOS Batch 1 9 0 28
make 1 5 0 18
Bourne Shell 1 8 0 17
-------------------------------------------------------------------------------
SUM: 314 9845 12777 44737
-------------------------------------------------------------------------------


Of course I also use 3rd party libs like Havok, Ogre, Boost, Lua, Ogg, Vorbis and some other stuff. Those statistics above are from my own code written by me. Apparently Cloc doesn't count Cg shaders. Anyway it's not that much.
froop
froop
7"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.