The game einstein again

bool rulesDone = false; do { Rule *rule = genRule(puzzle); if (rule) { std::wstring s = rule->getAsText(); for (std::list<Rule*>::iterator i = rules.begin(); i != rules.end(); i++) if ((*i)->getAsText() == s) { delete rule; rule = NULL; break; } if (rule) { rules.push_back(rule); rulesDone = canSolve(puzzle, rules); } } } while (! rulesDone); }

I was looking through the code again and this is where the duplicate hints are deleted. It is a necessary function as there is no sense whatsoever to have two hints that are the same and when they are created at random, that possibility exists.

    bool rulesDone = false;
do { Rule *rule = genRule(puzzle); if (rule) { std::wstring s = rule->getAsText(); for (std::list<Rule*>::iterator i = rules.begin(); i != rules.end(); i++)

So this mainly it, other than some iteration and conversion and the fact that is used as wide characters." if ((*i)->getAsText() == s) {" would mean that a string "s" which was the new rule was found in array of rules and integers that describe the set and element of the association. I just used an iterator in an array with a "enum" to define the hint types and I find that to be more clear than text conversions to deal with the objects. It is faster to index on an integer than it is to pull up the string library resources for each element to handle. There is no clarity lost by passing the pointer to the hints, IMHO. I am trying to see how many puzzles I can solve in a second and I have gone from 4 / sec to 100 / sec and I guess that I can do 10,000 / sec when I am done. I figured out a method today that uses the 64 bit registers and would have to be coded in assembly, but I don't want to make it machine architecture dependent. It is possible to do ASM that uses add and shift to simulate multiply and divides, but that is also too specific and I wanted to at least be able to run on any Linux machine that had OpenGL. I can use the algorithms to solve some real world stuff after that. The total problem enclosure is about 100 bits so it is less complex than a 94 bit variable. An entire puzzle can be described with an array of 94 bit variables. The same is true of the hints and also the probability array is just 216 bits. This means I can describe a saved game with it's state in about 400 bits, or about 50 bytes. The variable is the number of hints and their usage state. So, to be sure it would have to be 64 bytes of data to describe each game with its states. I may do a javascript implementation that can be played on the blog. Once the logic is established. It is iffy as I am a lazy person and that seems like work, but I may be bored some night and do that, because I can.

                if ((*i)->getAsText() == s) {
                    delete rule;
                    rule = NULL;
                    break;
                }
            if (rule) {
                rules.push_back(rule);
                rulesDone = canSolve(puzzle, rules);
            }
        }
    } while (! rulesDone);
}

0 comments:

Contributors

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen