Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 May 2007
Offline Last Active Yesterday, 08:09 AM

#5082554 Why XML is all the rage now?

Posted by achild on 02 August 2013 - 01:22 PM

YAML is taking off? I have yet to see anything use it. JSON though, yes, it seems that lately everybody and their dogs are using JSON now. Probably because we're in full HTML5 mode, and JSON data is valid javascript, so using it is a non-brainer as you don't even need a parser (I wonder if anybody understands the implications of loading data as code though).


Personally, I prefer INI files anyway (well, INI-like at least). Yeah, call me old-fashioned, but they're a lot easier to deal with. XML is good when you need tree-style nesting, but most of the time you don't, really (and even then, those using XML more often than not abuse it resulting in ridiculously complex formats for no real reason).


Added systems for localization AND fairly comprehensive theming in a single night for our next release... using ini files. Still need a good sit-down or two to link remaining text, gui elements, etc to these systems, but the functionality itself is complete and works great.


Honestly I've been paranoid that the design choice was naive or missing something critical because it was so darn simple and ini files are all but unheard of these days - but it works like a charm! Not to mention it takes like 30 lines of code to have a cross platform ini parser.


I can definitely see the need to support human readable hierarchies in some cases, but it seems to happen way too often when it is unneeded.


I hold the firm belief that given time, the open-source world will achieve its ultimate goal of reducing every piece of software in the world down to operations on a key/value store (see the rise of plist, JSON, Lua, and NoSQL).


Then we can resurrect the INI file, and be done with it.



#5071874 Cleaning and 'improving' your code (const)

Posted by achild on 21 June 2013 - 02:11 PM

It needs to be in the implementation too.


May I give a small piece of advice, based on 15+ years writing code? What you're doing, making things const correct, some will argue it is a waste and even const itself is bad, others will argue it is good and makes it safer. That is a matter of opinion, both sides having reasonable arguments, but if you feel it makes it better and safer for the way you program, then hey it's probably a good idea.


However, this can easily become a thing where you start renaming all your variables/functions/macros/etc EVERYWHERE to conform to some standard way of naming things.


At first, this seems good, so things are consistent, and also once you have decided to do so it is easy to get OCD and require it everywhere. However, the problem is that if this happens to you, down the road, you will inevitably change, again, how you feel things should be named, for clarity. Then what, redo all your source code again? But now there are 100s of files instead of 10s. And so on.


One of the best things I learned on this topic was to simply work on the file that needs worked on, and keep it consistent with how it already is. If a file uses a naming convention where all variables are camelCase, stay with it so the file is consistent. If another file uses CamelCase, because you changed your mind one day on what looks better, use it... on that file, but not on the first one. Otherwise you will drive yourself crazy as your style and preferences change. Consistency doesn't have to be project wide when it comes to arbitrary choices like this (I'm not really talking about safety or smart design here, just style preferences), in fact it will be impossible once you start introducing third party libraries with their own styles. But, it should be consistent within a same source file. Now you won't go crazy.


I realize that is not what you are addressing here... but from experience I can say how easy it is to become that, so you might as well get the advice now.


[edit] That is what I am talking about, what is mentioned in the next post. Naming conventions are a good example. Keep it consistent within a file. And yes, if you prefer warts on your names, probably rAge for a reference versus pAge for a pointer, or you know, whatever you like.

#5012907 2D Image error correction algorithm(solved)

Posted by achild on 20 December 2012 - 02:14 PM

Connected Component Labelling is what you want. It is often the basis for many kinds of image analysis. In your case each pixel will be labelled, and you can just measure the area as you label it. For instance, you may keep a vector or map with each label as the index, and increment the area count as you go. Or maybe you could just detect it after the fact - whatever is easiest for you since performance isn't super-critical.

At work we use a super optimized blob detection algorithm. I'm working on something on my own time that, when importing textures, automatically detects where the various textures are on a single image. It uses a customizable flood fill algorithm. The wikipedia article on connected component labelling also has Union-find in it's see-also section, as alvaro mentioned.

You can simply determine the area as you label, whichever method you choose, and if it is too small, I dunno, refill that area with the data from one of the other perlin noise layers bordering it? Not sure how you are getting the image exactly but you'll know the area you need to "fix".

#5012467 Once you go OO, you never go back?

Posted by achild on 19 December 2012 - 09:31 AM

As was mentioned - remember it's one of many tools, and tools, while they can be typically used for just about anything, are usually specialized for certain things. (I could go cut a board in half with a screwdriver, given enough time, but better to use the saw for that and use the screwdriver for what it's meant for.)

OOP tends to be a good fit for self-contained black-boxes that don't (usually) know about the inner workings of each other. This allows them to be highly reusable for many situations. A fantastic example is a GUI system.

Procedural programming tends to shine when it comes to algorithms and complicated ... procedures. Take code for reading/writing JPEGs for instance. I've seen this done with minor use of OOP (by Intel, in fact) and it was very awkward. I've also seen it done fully procedurally, and it is just easier to follow.

Data Oriented Design is another way of thinking that is getting a lot more attention lately (it is nothing new though). This has more to do with layout and memory structure being the first thing on your mind, and so can then be wrapped up in whatever little package you want, whether it is using OOP idiom, PP idiom, or something else.
(Note that just because you use SoA does not mean it isn't wrapped up in a nice neat little object)

There's also functional programming, stack based programming, event based programming, etc... but most of all you will find what works best and what doesn't - and more importantly why, as you get more experience. So even if you just keep doing what you're doing, and pure OOP comes back and bites you hard, it's good - that's how you must usually learn!

#5012083 C++ Engine Layout

Posted by achild on 18 December 2012 - 09:29 AM

Maybe it's time for some experiments, I'll try to break the dependencies to a bare minimum as suggested by L. Spiro.

This is the most important part. Now that you have a few different advices from people, there is really no way for you to know which is the best advice until you try them. As you pick one and implement it, you will inevitably encounter issues and see problems with your solution. At this point you may realize how to tweak it, in some cases, or you may realize that a totally different solution was much better. More importantly, you will better understand why some things are bad and why some things are good. A few years later, that understanding may change too Posted Image

Have fun man! Posted Image

#5009548 Go language use in performance-critical code

Posted by achild on 11 December 2012 - 03:38 PM

There is also this page I found but I don't really know whats GOing on here: http://golang.org/test/bench/shootout/

har har

#4999352 Convicted Felon as a game programmer

Posted by achild on 09 November 2012 - 11:15 AM

Just wanted to say, as a fellow convicted felon, that if you are good (as in you excel in some area in software development) and the manager wants you, you will likely get the job. The only thing that can stop that is if there is some company policy they absolutely can not exercise any power over, for instance. Or if their manager hates you - even then the manager that likes you may very well convince them to "give you a chance".

Just because you did some stuff does not mean your life is over. Not at all. Just stay out of trouble now! And if something doesn't work out because of your past, then be glad because it will still guide you to something else that will.

It is nice to see your determination. I am proof you will be okay Posted Image

#4998210 Time to write rendering engine from scratch

Posted by achild on 06 November 2012 - 03:51 PM

Whoa whoa whoa

If you are generally unsure of yourself (and it sounds as though you are), I would say you should give yourself no less than a month, maybe up to 2.

Because of the wide range of skills and experiences, I am not sure how helpful any of our answers would be.

1) I don't believe LS was tearing you down or diminishing your character. And I'm pretty sure the way you reacted to LS and similar answers set this thread downhill. Clarification on your part probably would have went a long way.
2) Plenty of people here don't like goto (unless absolutely positively necessary, which it usually isn't).
3) I don't believe you can get a negative rating - perhaps I am wrong about that one though.

Please try to reconsider your perspective on all this - it's not what you think it is.

#4996307 MSVC 2010 vs MSVC 2012 - Performance question.

Posted by achild on 01 November 2012 - 02:57 PM

I like VS2012 express for C++. Seems to be a bit quicker on my system than 2010. I haven't tried the new auto-vectorization but I've heard good things about it. [...]

If you haven't done anything, it is already auto-vectorizing stuff. I have not done any artificial tests - only checked the log on my actual code - and it tries to auto-vectorize a LOT of things for me at least.

#4985747 How many third party libraries do most games use?

Posted by achild on 01 October 2012 - 07:40 AM

As a side note, if you're still looking for some well known examples, both Source and Unreal Dev Kit use or can use a ton of 3rd party libs.
- http://www.unrealeng...om/en/partners/
- Can't find a link for Source Engine but if you have an installed game from Valve there are a lot of 3rd party dlls in there source engine folder.

#4981244 File I/O streaming performance.

Posted by achild on 18 September 2012 - 07:40 AM

It's ... bad mojo ... to even mention compression. And the word "lossless" is like a lie. Seriously. It's very strange and counterproductive from my perspective.

Posted Image I'm not sure why you think that. There surely exists compression schemes such that the decompressed image is completely faithful to the original one.

Heh... I was referring to where I work. In a lot of areas in the microbiological field, there is this stigma against any compression. I'm guessing someone with a lot of clout saw that jpeg compression distorted their data, and said "compression is bad" and now we're stuck here, unfortunately.

#4980924 File I/O streaming performance.

Posted by achild on 17 September 2012 - 10:11 AM

Use mem mapping. Make sure to use FILE_FLAG_SEQUENTIAL_SCAN. Experiment with FILE_FLAG_NO_BUFFERING. Depending on how windows caches your data, it may keep loading your 5gb file as you read it into virtual memory, only to eventually have to flush and stall your system for a very long time. Using no buffering may seem slower overall, but it avoids this very bad annoying thing.

Make sure all your alignment stuff is good. In my experience sequential access has been many times faster than random access. Can't imagine why it would be otherwise anyway, though that obviously doesn't mean there aren't cases where it happens.

(Of course if you can slip an ssd drive into this person's computer things will be much faster.)

[edit] Oh yeah... you might (or might not) get better performance by always reading a buffer ahead - it won't do most of the time consuming (hard drive access) stuff until you read from memory-mapped memory anyway, but at least windows gets a chance to know what's coming.

#4920136 Old school racing (TopGear, Lotus) game track algorithm

Posted by achild on 07 March 2012 - 12:05 PM

Say you want to simulate turning 90 degrees in one direction. All you would do is use a sine wave of the appropriate length, from, say, 0 radians to pi/2 or even pi/4 for your horizontal offsets. While driving, the sine wave should gradually go from having no amplitude to much amplitude to go into the curve. Hold it at that amplitude for however long the turn is, and finally gradually interpolate back down to no amplitude to get out of the curve.

#4920130 Old school racing (TopGear, Lotus) game track algorithm

Posted by achild on 07 March 2012 - 11:48 AM

Actually that's pretty good, and all that was really done back in the day was handle the interrupt that would occur at the beginning of each scanline and scroll it by a given amount - very similar to what you're doing.

Realize that
a) It will never feel completely right done this way
b) There are times when you want to just have it go right or left for a while to give a sense that the track is going in a complete circle. Right now it just feels like it is an inifinitely (generally) straight track.

It feels really nice, and looks awesome, but you almost need to overdo a turn here or there so that the track feels like it is connected in a loop - unless of course the track isn't connected in a loop.

You may experiment with shifting the scene up or down a bit too... perhaps it would feel better if it wasn't so exactly behind the player.

All in all it feels good... I think you are closer than you realize. Just needs some minor tweaking!

#4919496 c++ 0x threading problem

Posted by achild on 05 March 2012 - 10:57 AM

Also, though it's not super useful to you just yet, VS2011 looks like it will have the majority of the new standard threading libraries.