Jump to content
  • Advertisement

Matt-D

Member
  • Content Count

    200
  • Joined

  • Last visited

Community Reputation

1574 Excellent

About Matt-D

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. Matt-D

    The One: A Singleton Discussion

    See also "Implementing a Thread-safe Singleton with C++11" (the comments are worth reading, too): http://www.nuonsoft.com/blog/2012/10/21/implementing-a-thread-safe-singleton-with-c11/   Obligatory: http://jalf.dk/blog/2010/03/singletons-solving-problems-you-didnt-know-you-never-had-since-1995/ ;>
  2. Matt-D

    Multithreading

    One note regarding display and non-CPU computation (e.g., graphics accelerators) -- while Amiga is historically important, it was by no means the starting point: http://www.techspot.com/article/650-history-of-the-gpu/
  3. Other than my comments for Part 1, here's one more fix -- make sure your constructors use "initialization lists" instead of "assignment", here's why: http://www.parashift.com/c++-faq/init-lists.html   Regarding (pseudo-)random number generation -- there's an easier (and cleaner) way now (also with better performance and higher quality), see: http://isocpp.org/blog/2013/03/n3551-random-number-generation [PDF] http://isocpp.org/files/papers/n3551.pdf In particular, take a look at the following examples: roll_a_fair_die, roll_2_fair_dice, roll_fair_dice, roll_n_sided_die, pick_a_number (for int and double, easy to adapt for different types).  
  4. Matt-D

    Let's Make: BattleGame! [Part 1 - Classes]

    It's a good thing you're not doing "using namespace std" anymore :-)   I think you should add header <string> however, since you're using std::string later on. // One advice: depends on what you do with it, you may want to consider not taking std::string argument by value, but by const-reference, this way you might avoid unnecessary copies: http://stackoverflow.com/questions/10789740/passing-stdstring-by-value-or-reference // Although for some cases std::swap can save the day when you pass-by-value: http://stackoverflow.com/questions/589076/when-is-it-not-a-good-idea-to-pass-by-reference   Also, I'd suggest getting rid of the ints and use size_t instead (remember to include the appropriate header) for all the variables that count, measure the size of something, etc.: http://en.cppreference.com/w/cpp/types/size_t http://stackoverflow.com/questions/994288/size-t-vs-int-in-c-and-or-c // otherwise, you're suggesting that ammo, maxAmmo, potions, maxPotions should be able to be negative, which obscures the intent (they're sizes/counters, and so should be non-negative) and thus decreases code readability   It's especially important to do it *now*, at the very beginning, to instill good practices from the start (next to "using namespace std", abusing/overusing ints for everything is one of the most common mistakes I've seen beginners make; perhaps it's so prevalent because it's used for "int main", but outside of that there's very rarely a justified reason to use int).
  5.   Joel F,   I'm wondering, how does it fare in comparison with the C++ vector class library by Agner Fog (both w.r.t. features and performance): http://www.agner.org/optimize/#vectorclass [PDF] http://www.agner.org/optimize/vectorclass.pdf     // EDIT: AllEightUp -- same question :-)   Best Once again, I had never looked at that implementation but from a personal point of view, I don't like that version very much.  It uses SIMD conventions and as such is not a near drop in replacement for a normal C++ version.  It also doesn't seem to expose the underlying SIMD abstraction as a utility usable in other areas.  I also didn't see the ability to use different targets in the same compilation, i.e. target SSE3 for the main executable yet in the same solution/project/whatever build a SSE3-AVX supporting shared library.  I'm not proud of using macro's but in this case it makes all sorts of sense to do so.   Speed wise, any other will likely be faster right now.  I spent time on clarity and versatility and did not optimize things in any real detail.  One of the reasons for the git repository though is that I'm very open to others jumping in and helping out.   (NOTE: I just briefly looked at it, I could have missed things.  I'll look in more detail later.)       Joel F,   I'm wondering, how does it fare in comparison with the C++ vector class library by Agner Fog (both w.r.t. features and performance): http://www.agner.org/optimize/#vectorclass [PDF] http://www.agner.org/optimize/vectorclass.pdf     // EDIT: AllEightUp -- same question :-)   Best Once again, I had never looked at that implementation but from a personal point of view, I don't like that version very much.  It uses SIMD conventions and as such is not a near drop in replacement for a normal C++ version.  It also doesn't seem to expose the underlying SIMD abstraction as a utility usable in other areas.  I also didn't see the ability to use different targets in the same compilation, i.e. target SSE3 for the main executable yet in the same solution/project/whatever build a SSE3-AVX supporting shared library.  I'm not proud of using macro's but in this case it makes all sorts of sense to do so.   Speed wise, any other will likely be faster right now.  I spent time on clarity and versatility and did not optimize things in any real detail.  One of the reasons for the git repository though is that I'm very open to others jumping in and helping out.   (NOTE: I just briefly looked at it, I could have missed things.  I'll look in more detail later.)   OK, I'm just going to take the parenthetical note as a partial answer for now and wait for a more detailed one later :-)   I think it's worth looking at, you may find it actually fits your needs. For instance, dispatching (multiple targets) is definitely supported, see the "Instruction sets and CPU dispatching" section:   • can build code for different instruction sets from the same source code • CPU dispatching to utilize higher instruction sets when available • uses metaprogramming (including preprocessing directives and templates) to find the best implementation for the selected instruction set and parameter values of a given operator or function   // BTW, I'm not sure what you mean specifically when you mention "exposing the underlying SIMD abstraction" (functions and SIMD data structures are very much available).
  6.   Joel F,   I'm wondering, how does it fare in comparison with the C++ vector class library by Agner Fog (both w.r.t. features and performance): http://www.agner.org/optimize/#vectorclass [PDF] http://www.agner.org/optimize/vectorclass.pdf     // EDIT: AllEightUp -- same question :-)   Best
  7. Coroutines are indeed pretty cool (my experience w/ them comes from Lua)! Regarding C++, I've come across this some time ago, perhaps you'll find it of use: [url="http://www.crystalclearsoftware.com/soc/coroutine/"]http://www.crystalcl.../soc/coroutine/[/url]
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!