Choice of code design

Discussion in 'Game Development (Technical)' started by lordmetroid, Aug 25, 2007.

  1. cliffski

    Moderator Original Member

    Joined:
    Jul 27, 2004
    Messages:
    3,897
    Likes Received:
    0
    you people doing shooters and match 3 games may be saying this. but my vastly scaled up neural network behind Democracy 2 needs every clock cycle it can get to keep the games turns as short as I can.
    I have very little worries about rendering speeds, and lots of worry about processing speeds, because my game is totally different to the types being discussed. Nobody should generalize about we should all code unless you have read everyone elses design doc. an RTS needs a different coding approach to an FPS in all sorts of ways.
     
  2. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    I would. Most compilers suck. ASM coders always have a job because the CPUs come out too fast. By the time the compiler writers start to put any effort into intelligently optimizing for a given CPU, the market has moved on to the next CPU that's completely different.
     
  3. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    That slow? Dang, that's pathetic. Oh well, I don't like Microsoft anyways so it'll be awhile before I bother with the 360. Unless someone happens to pay me to bother.

    Something like this, for me, isn't a big deal. But if my optimization, more efficient code, whatever you want to call it, costs me 1 hour or more of thinking time, then that's time I'm wasting unless I know it's needed. That's the harm of worrying about optimization and efficiency. You can spend hours thinking about things that aren't contributing value, or only marginal value, to your project goals.

    I use tons of extra keystrokes for unoptimized butt-coding. It's not how many keystrokes, it's how fast I can chuck 'em out without thinking.
     
  4. voxel

    voxel New Member

    Joined:
    Oct 29, 2006
    Messages:
    176
    Likes Received:
    0
    5 million polys at 30fps = 150 million polys a second... using 32-bit indices(who uses raw triangles - that's just bad design) and tri-strips/tri-lists you get a max of 4 bytes per triangle = 600 million bytes a second.

    Of course, real world says you have textures and need to upload the vertex list and have dynamic vertex buffers for particles and one offs...
     
    #104 voxel, Aug 31, 2007
    Last edited: Aug 31, 2007
  5. voxel

    voxel New Member

    Joined:
    Oct 29, 2006
    Messages:
    176
    Likes Received:
    0
    I'm against ::draw() in any object even if it inherits from Mesh::Draw()

    Car.draw()
    Sky.draw()
    Person.draw()
    HUD.draw()

    The performance argument against it is strong, but the design argument is even stronger:

    Rendersystem.insert(car);
    Rendersystem.insert(sky);
    Rendersystem.insert(person);
    Rendersystem.insert(HUD_element);
    Rendersystem.renderNextFrame();

    The rendersystem is the one who understands all about rendering - ordering, transparency, effects, etc.. It centralizes all algorithms and also keeps coupling between classes simpler:

    Car require inheriting from Mesh which brings in all DirectX and OpenGL functionality. Blech.

    Instead, Car just contain data and logic - no platform/rendering dependent junk... no COM nor some random include files required by Mesh/DirectX drawing...

    On a related note, would you do this?

    Car.sendNetworkPackets()
    Sky.sendNetworkPackets()
    Person.sendNetworkPackets()
    HUD.sendNetworkPackets()
     
  6. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    I think he said it best himself tbh with
    :)

    The platform I work on doesn't even have an external bus to worry about (in the usual sense) and the internal one is a mile wide.
     
  7. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    :) LMAO, this struck me as really funny. I think we can agree that even this lot would never write that :)
     
  8. voxel

    voxel New Member

    Joined:
    Oct 29, 2006
    Messages:
    176
    Likes Received:
    0
    I wish.

    The situation is getting WORSE with VLIW and vector-friendly (i.e SSE) CPUs that can do 2/4/8/16 instructions in parallel.

    Exactly. But sadly, understanding the underlying architecture (modern CPU) and designing data structures has become non-trivial for modern CPUs.

    i.e an array of vectors (x,y,z) is can be FAR less efficient (i.e the difference between your game running at 15fps vs. 60fps) than an array of x, array of y, and array of z.

    Remember PC programming != Console programming. PC programmers don't give two sh*ts about memory fragmentation or vectorizing their code... and console programmers don't give two sh*ts about driver or platform incompatibilities or error checking for that matter. Don't have a joystick? You can't play!
     
  9. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    Or you could be me and have the worst of both worlds :(

    I guess this comes mostly down to my own prejudices. Nobody said games programming is easy and I just expect people to learn their trade whatever it may be. I wouldn't hire a plumber who could only tighten washers, even if I only needed a washer tightening.

    Personally I'd hate to be limited to punting out 2D puzzle games because that's all I could achieve, but it seems this kind of thinking is quite common around here. Note that I see the difference between that and *deciding* to punt out a 2D puzzle game before I get flamed to death again.)
     
  10. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
    Sigh! Still missing the message: I'll spell it out. He might as well have said he was pushing 5 million quirkafleegs for all the use that the statement made.

    Cas :)
     
  11. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    I dunno what the hell a quirkafleeg is, but I reckon your next shooter game should have lots of them. :)
     
  12. jessechounard

    Original Member

    Joined:
    Apr 4, 2006
    Messages:
    70
    Likes Received:
    0
    No joke. Forget Treasure Tomb. Get to work on Quirkafleeg! :)
     
  13. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
  14. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    Who says your Mesh class exposes anything about OpenGL or DirectX?

    This is why I don't like OO design or OO programmers. It's always forcing people to make these irrelevant decisions about what belongs where, due to the inadequacy of inheritance hierarchies to express relationships.
     
  15. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
    Sounds more like the inadequacy of the analyst in understanding the problem to me :mad: I wish people wouldn't bash tools they didn't understand.

    (Tip: another pattern to the rescue, called the Visitor Pattern)

    Cas :)
     
  16. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    Call it an inadequacy of C++ if you like. But there are plenty of situations where you have to decide whether to shove something in hierarchy A or hierarchy B for no particularly good reason. If you have to write a bunch of code to pave over all of that, you're proving that C++ style inheritance is a waste of time.
     
  17. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
    The more you come to understand OOP, the less these situations occur until they just don't happen any more. It's a tool and you must understand how to use it correctly or you can bash your fingers.

    Cas :)
     
  18. bvanevery

    bvanevery New Member

    Joined:
    Jun 25, 2007
    Messages:
    369
    Likes Received:
    0
    More like, you gravitate towards domains where you don't have the problem as often, and accept the boilerplate that you typically use to solve them when they do come up. I've done C++ for 14 years and there's no magic that makes the "I don't really want a hierarchy to own this" problem go away.
     
  19. HairyTroll

    Original Member

    Joined:
    Jul 29, 2004
    Messages:
    582
    Likes Received:
    0
    If you insist ;)

    Multimethods do not have this disadvantage.
     
  20. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    This is getting a little annoying now. Saying use patterns and that something is this pattern or that pattern is saying EXACTLY the same as me, just with a slightly better/narrower definition. Write efficient code first time round.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer