Playing Einstein

Do you see anything wrong with the code below? I have a serious question. If the random number generator returns negative numbers or if rand() is greater than (RAND_MAX + 1), doesn't that mean the OS is totally F4D? This comes from the source code for "einstein" and it works mostly as I would have guessed internally, however, I have my reservations about C++ name overloading and how understandable the code is for a mere mortal. On another note, I don't think that checking your own pulse is a good way to see if you are dead.

static void shuffle(short arr[PUZZLE_SIZE])
{
    int a, b, c;
    
    for (int i = 0; i < 30; i++) {
        a = (int)(((double)PUZZLE_SIZE)*rand()/(RAND_MAX+1.0));
        if ((a < 0) || (a >= PUZZLE_SIZE)) {
            std::cerr << "Index error" << std::endl;
            exit(1);
        }
        b = (int)(((double)PUZZLE_SIZE)*rand()/(RAND_MAX+1.0));        
        if ((b < 0) || (b >= PUZZLE_SIZE)) {
            std::cerr << "Index error" << std::endl;
            exit(1);
        }
        c = arr[a];
        arr[a] = arr[b];
        arr[b] = c;
    }
}

I took the program apart and cheated it once or twice to see how long it takes and I can't move the mouse around the little squares faster than 3 minutes or so for all 36 elements to select them for the answer. The internals use a three dimensional matrix representation of the puzzle and I learned some interesting things about C++, SDL, and logic itself. I have this link to explain RAND_MAX if you are interested. I modified the title screen and fixed some things inside the code. Something odd is the fact that the debian source will not compile when I do:

apt-get source einstein
cd to it
make
It complains about TTFs

So I got the fonts from the "flowix games spot" and it compiled. The way in which the game is implemented is much as I would assume from playing it a few times. It generates rules to solve at random and so if you want to anthropomorphize the interaction with the game, you would be kidding yourself. I noticed that the game itself was not reworked at debian, because somebody said that the code was not well documented and was inscrutable. I actually imagined the methods in my head as I first played the game and the code is exactly as I would expect. I think it is messy to use a static screen size, but it is only a game. I learned some interesting things about i18n and how to use the unicode in a sensible and indirect way for multi-language support and this made the entire adventure worthwhile. BTW , I used some work I did with Inkscape, Blender, and Gimp to use as the title page for my version and if anybody is interested in getting the new source, just leave a comment here. If I get real energetic and make a rotating three D of the matrix, I will certainly put the code up and leave a link. It could happen.

Other than this , I am studying the genotype to phenotype structure of the human neural array and it does have some fascinating aspects.

0 comments:

Contributors

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen