Beispiel #1
0
void Solver :: execute () {
    std::list <Operation *> :: iterator it;
    std::stringstream debug_steps;
    bool change = true;
    
    while (change) {
        change = false;
        for (it  = this->operations.begin();
             it != this->operations.end();
             it++) {
            if ((*it)->execute()) {
                debug_steps << "[*] " << (*it)->g_name() << "\n";
                if (validate() == false) {
                    std::cout << debug_steps.str();
                    output_state();
                    throw -1;
                }
                change = true;
            }
            else {
                debug_steps << "[ ] " << (*it)->g_name() << "\n";
                if (validate() == false) {
                    std::cout << debug_steps.str();
                    output_state();
                    throw -1;
                }
            }
        }
    }
    std::cout << debug_steps.str();
}
Beispiel #2
0
void Solver :: solve () {
    int highest_bit_count = 0;
    int bc;
    int i;
    for (i = 0; i < 1; i++) {
        initialize_values();
        find_best_Ms();
        execute();
        bc = 0;
        /*
        for (j = 0; j < 16; j++) {
            bc += M[j]->mask_count();
        }
        if (bc > 32 * 12) {
            output_state();
            std::cout << "FOUND M\n";
        }
        */
        if (bit_count() > highest_bit_count) {
            highest_bit_count = bit_count();
            output_state();
        }
        std::cout.flush();
    }
}
Beispiel #3
0
void recombine_level (int l)
{
    int i, j, count, done;
    /* sweep right */
    count= 0;
    done = 0;
    for (i=N-1; i>0; i--) /* search for first relevant point */
    {
        if (sd[i+1] == l/2 && sd[i] == l)
        {
            /* Look for points to the right that need recombination */
            count = 0;
            while (sd[i-count]==l && fabs(dx*dx*d2dx2(Tm,i-count)/(sd[i-count]*sd[i-count]))<1e-6)
                count++;
            i -= count;
            if (count>10) {
                done = 1;
                printf("count = %d, %d, %d\n", count, i, l);
            }
        }
    }
    if (done && 0)
    {
        output_state("state", 0);
        exit(0);
    }
}
Beispiel #4
0
void GOTO(int new_state)
{
    state_timeout = (trans[new_state].timeout)
                    ? *trans[new_state].timeout : -1;
    if (debug&DEBUG_STATE_CONTROL)
        syslog(LOG_DEBUG,"new state %s action %d timeout %d",
               trans[new_state].name,(int)trans[new_state].action,state_timeout);
    state = new_state;
    output_state();
    (*trans[new_state].action)();
}