Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 25 Jun 2013
Offline Last Active Aug 12 2015 12:23 PM

Posts I've Made

In Topic: Land/Sea ratio from a Heightmap

01 August 2015 - 07:14 AM

Thank you for your reply. While you were writing your answer, I came up with another solution involving the histogram.
I define my ranges according to the average altitude of the map and its standard deviation.
First, I compute the cumulative histogram cumHisto:
    var cumHisto = 0;

    for (var i = 0; i < World.width; i++) {
        for (var j = 0; j < World.height; j++) {
            cumHisto += World.mapData[i][j];
        } // for j
    } // for i
Then, I compute the average altitude avgHeight:
    var nbPoints = World.width * World.height;
    var avgAltitude = cumHisto / nbPoints;
I need a loop to compute the standard deviation stdevAltitude, based on the variance varAltitude:
    var varAltitude = 0;
    for (var i = 0; i < World.width; i++) {
        for (var j = 0; j < World.height; j++) {
            var diff = World.mapData[i][j] - avgAltitude;
            varAltitude += diff * diff;
        } // for j
    } // for i

    var varAltitude = varAltitude / nbPoints;
    var stdevAltitude = Math.sqrt(varAltitude);
Given the average altitude and its standard deviation, I can define four ranges which seem to give quite reliable results:
    for (var i = 0; i < World.width; i++) {
        for (var j = 0; j < World.height; j++) {
            if (World.mapData[i][j] < avgAltitude) {
                World.mapData[i][j] = Terrain.DEEP_OCEAN;
            else if (World.mapData[i][j] < avgAltitude + 0.5 * stdevAltitude) {
                World.mapData[i][j] = Terrain.COASTAL_OCEAN;
            else if (World.mapData[i][j] < avgAltitude + 2 * stdevAltitude) {
                World.mapData[i][j] = Terrain.FLAT;
            else {
                World.mapData[i][j] = Terrain.MOUNTAIN;
        } // for j
    } // for i
mini_837212Capturedcran20150801142639.pn mini_317439Capturedcran20150801142726.pn mini_441266Capturedcran20150801142737.pn mini_372853Capturedcran20150801142749.pn

In Topic: Some programmers actually hate OOP languages? WHAT?!

29 January 2015 - 10:02 AM

Just to feed this tr.. topic, I recently had to do some reverse engineering on a game's codebase in C#, strongly OO. It was a real nightmare...


However, understanding a large C (well-written) codebase, even without documentation is a piece of cake.

In Topic: Web game: flash or unity?

30 July 2013 - 10:34 AM

Which kind of game do you plan to develop ?

In Topic: Why companies still use C++ and what should I learn then

29 July 2013 - 01:00 PM

Exactly. So in ~30 years, this same C++ will then be recycled into Ubuntu MegaScript*
So as long as you write your high level code in C or C++, it will be likely that you will be able to reuse it. This is perhaps why it is so hard to convince a C++ developer to make a lateral move to another high level language.
* I just made a guess at what the successor to JavaScript was going to be called.

Future could be the one you said. Or maybe be future will be Javascript and even more than today. Who knows after all?
I'm just pointing the fact that unlike the past decades since the begining of the PC era, with Web browsers nowadays, hardware and software architectures are changing dramatically.
Consumers' habits too.
I'm not telling that C++ will disapear, I don't really care after all, and I'm not a Javascript guru too.
I wanted to say that, but I could be mistaken, that consumption of games are changing with the overall improvment of the Web (hardware networks and web browsers). Today with the increasing popularity of social and casual games, gaming is maybe not only a matter of AAA stuffs.

But I recall, I'm not a specialist, this is just a feeling.

For consoles, eg. Xbox and PS, probably, low level languages like C & C++ will still be mandatory. However, with their internal architecture getting more and more closer to a computer's one, things are evolving too. Maybe one day we will have a console especially optimized for a web browser which will replace the OS layer (this is maybe a nonsense, if so, sorry...)

In such a context of "browserization", which is completely different from superficial improvements like 8 bits->16bits->32bits and so on, Intel or Motorola chip's specifications will eventually become not so relevant.
And finally, Javascript, even if it could not be the "ultimate language" could become the new assembly language of "post Intel era" programming.

The more the industry is investing in this new "browser" paradigm, the more Javascript will become corner stone, like C and C++ were (and still are) during the "OS" paradigm.

But one day, in a future I don't know, Javascript will disapear or at least decline. But I think this will be the fact of a new paradigm, a new architecture, not because of a hype for a new "Ubuntu MegaScript". Because, past proved that despite innovations in a customer's point of view, the computing industry tends to be very conservative in their internal habits, and C and C++ languages are proofs of that.

So, does a beginner should start learning C++ because of performance and memory allocation discipline required?
10 years ago, when the "browserization" was almost inexistant and nothing really sophisticated could get out of Netscape, I could have answered yes.

But nowadays, I could not be so definitive as browsers can do almost everything, even make running a 3D MMO FPS in a close future.

The future top-ranked developpers would maybe those who masterize perfectly Javascript optimization? Since Google and major companies are investing seriously in this field, it's not impossible.

So, that's all for my thoughts about this neverending but interesting question.
And please note that my intention is not to argue against C++ supporters (C++ was my very first programming language), just to bring an "amateur" point of view.

In Topic: Why companies still use C++ and what should I learn then

29 July 2013 - 06:05 AM

And as with OSes, you need systems languages which is why tools like Emscripten (C++) and to a certain extent Microsoft's TypeScript have been created to work on large scale client-side web applications which becomes very tricky with something like Javascript.
I also find Javascript is far harder than C++ when working in large teams so I am very grateful for Emscripten ;)

You should be right. Well, I'm not a specialist. But eventually, what Emscripten or TypeScript produce is Javascript code.
And Emscripten can be seen not only for performance consideration, but also as a way to reuse C & C++ legacy codes.
A kind of usual transition period in computing industry where tons of past decades C/C++ code will be recycled into Javascript in the future.