コード例 #1
0
//Constructor from automa
UnstableMultiMonoid::UnstableMultiMonoid(const MultiCounterAut & automata) : UnstableMonoid(automata.NbStates)
{
	initial_states.clear();
	final_states.clear();

	VectorInt::SetSize(automata.NbStates);
	MultiCounterMatrix::set_counter_number(automata.NbCounters);
	
	for (unsigned char letter = 0; letter < automata.NbLetters; letter++)
	{
		ExplicitMatrix mat(automata.NbStates);
		mat.coefficients = automata.trans.at(letter);
		addLetter(letter, mat);
	}

	for (int i = 0; i < automata.NbStates; i++)
		if (automata.initialstate[i])
			initial_states.push_back(i);

	for (int i = 0; i < automata.NbStates; i++)
		if (automata.finalstate[i])
			final_states.push_back(i);

	state_names.resize(automata.NbStates);
	for (int i = 0; i < automata.NbStates; i++)
		state_names[i] = state_index_to_tuple(i, automata.NbStates);

}
コード例 #2
0
const Matrix * UnstableMultiMonoid::ExtendedExpression2Matrix(const ExtendedExpression * expr,const MultiCounterAut & automata)
{
	const LetterExpr * lexpr = isLetterExpr(expr);
	const ConcatExpr * cexpr = isConcatExpr(expr);
	const SharpedExpr * sexpr = isSharpedExpr(expr);

	if(isLetterExpr(expr)){
		ExplicitMatrix mat(automata.NbStates);
		mat.coefficients = automata.trans.at(lexpr->letter);
		return addLetter(lexpr->letter, mat);
	}
	else
	{
		if(isConcatExpr(expr))
		{
			const Matrix * mat = ExtendedExpression2Matrix(cexpr->sons[0], automata);
			for (uint i = 1; i < cexpr->sonsNb; i++) mat = mat->prod(ExtendedExpression2Matrix(cexpr->sons[i], automata));
			return mat;
		}
		else
		{
			const Matrix * mat = ExtendedExpression2Matrix(sexpr->son, automata);
			return mat->stab();
		}
	}
}
コード例 #3
0
ファイル: Algorythm.cpp プロジェクト: 4Enjoy/Letters-2048
void Algorythm::createTable(bool tutorial_table)
{
    //TODO: fix this
    if(!tutorial_table)
    {
        for(unsigned int i=0;i<2; ++i)
        {
            addLetter();
        //addLetter();
        }
    }
    else
    {
        _cells.setLetter(0,1,GameInfo::getInstance()->getLetter('B'));
        _cells.setLetter(1,1,GameInfo::getInstance()->getLetter('A'));
        _cells.setLetter(2,1,GameInfo::getInstance()->getLetter('A'));
    }

    _drawer->setTabelCells(_cells);

    logTable();

    //set table in signal
    emit signalTableChanged(_cells);
}
コード例 #4
0
ファイル: SymbolDialog.cpp プロジェクト: DanNixon/mantid
void SymbolDialog::addCurrentChar() {
  for (int i = 1; i < numButtons; i++) {
    QPushButton *btn = (QPushButton *)buttons->button(i);
    if (btn && btn->hasFocus())
      emit addLetter(btn->text());
  }
}
コード例 #5
0
    HuffmanNode(std::string l) {
        timestamp = 0;
        left = right = NULL;

        for(int i = 0; i < l.length(); i++) {
            addLetter(l[i], -1);
        }
    }
コード例 #6
0
//--------------------------------------------------------------------------------
void PMRendererTypography::keyPressed(ofKeyEventArgs &eventArgs)
{
    if (state == RENDERERSTATE_ON) {
        if (eventArgs.key == 'q')
            addLetter();
    }

}
コード例 #7
0
ファイル: CapturedString.cpp プロジェクト: jbmorse/Dragonfly
int CapturedString::eventHandler(Event *p_e) {

	if(p_e->getType() == CAPTURED_LETTER_EVENT) {
		EventCapturedLetter *ecl = (EventCapturedLetter *) p_e;
		addLetter(ecl->getCapturedLetter());
		return 1;
	}

	return 0;
}
コード例 #8
0
    /*
    @desc Complex constructor takes 2 nodes and makes them the children of this
    newly contructed node. By definition, the parent must have the data from the
    children, so their members are each copied into the new node as well
    @param a The first node, should be the lesser of the 2
    @param b The second node, should be the greater of the 2
    @return void
     */
    HuffmanNode(HuffmanNode* a, HuffmanNode* b, int t) {
        //timestamp (psuedotime) from the tree
        timestamp = t;

        //initialize left and right to null
        left = right = NULL;

        //for each member of the vector in a, append one in the new HuffmanNode
        for (int i = 0; i < a->letters.size(); ++i)
            addLetter(a->letters[i].letter, a->letters[i].frequency);

        //for each member of the vector in b, append one in the new HuffmanNode
        for (int i = 0; i < b->letters.size(); ++i)
            addLetter(b->letters[i].letter, b->letters[i].frequency);

        //make the parameter nodes children of the new one
        left = a;
        right = b;

    }
コード例 #9
0
void symbolDialog::addCurrentChar()
{
for (int i=0; i<GroupBox1->count(); i++)
	{
	QPushButton *btn = (QPushButton *) GroupBox1->find (i);
	if (btn && btn->hasFocus())
		{
		emit addLetter(btn->text());
		return;
		}
	}
}
コード例 #10
0
ファイル: Quiz.cpp プロジェクト: tngoc/Wheel-Of-Fortune
void Quiz::arrangeLetter() {
	std::list<Button*>::iterator iter;
	letters.clear();
	int strlen = answer.length();
	if (strlen <= 0 ) return;
	for(int i = 0;i<strlen;i++) {
		addLetter(i);
	}
	number_of_words++; //do mặc định khởi tạo là 0 nên phải +1
	count_words.push_back(strlen); //lưu ký tự kết thúc
	iter = letters.begin();
}
コード例 #11
0
table* loadTable(table *alphabet, char c, float freq, int flag) {
	table *curr = alphabet;
	table *prev = NULL;
	if (alphabet == NULL){ 
		alphabet = addLetter(c, freq);
	}
	else if ((c < alphabet->c && flag) || (freq > alphabet->frequency && !flag)) {
		alphabet = addLetter(c, freq);
		alphabet->next = curr;
	}
	else {
        prev = alphabet;
		curr = curr->next;
		while (curr != NULL && ((c > curr->c && flag) || (freq < curr->frequency && !flag))) {
			prev = curr;
			curr = curr->next;
		}
		prev->next = addLetter(c, freq);
		prev = prev->next;
		prev->next = curr;
	}

	return alphabet;
}
コード例 #12
0
void SymbolDialog::getChar(int btnIndex)
{
	QPushButton * btn = (QPushButton *)buttons->button( btnIndex );
	if(btn)
		emit addLetter(btn->text());
}
コード例 #13
0
void symbolDialog::getChar(int btnIndex)
{
QPushButton *btn = (QPushButton *) GroupBox1->find ( btnIndex );
emit addLetter(btn->text());
}
コード例 #14
0
 //constructor for a node with a letter + frequency pair
 HuffmanNode(char letter, int freq) {
     timestamp = 0;
     addLetter(letter, freq);
     left = right = NULL;
 }
コード例 #15
0
void PMRendererTypography::update()
{
    if (state != RENDERERSTATE_ON) return;

    PMBaseRenderer::update();

    int _mode = myGUI->getMode();

    if (oldMode != _mode) {
        oldMode = _mode;
        box2d.getWorld()->ClearForces();

    }

    // IF ADDALETTER IS ENABLES IN ENERGY CHANGED ...
    if (addALetter) {
        float minVelocity = 0.01;
        float maxVelocity = 1.0;
        float velocityY = ofMap(pParams.smoothedPitch, 0.0, 1.0, minVelocity, maxVelocity, true);
        setYVelocity(velocityY);
        addLetter();
        addALetter = false;
    }

    uint64_t maxAge = myGUI->getMaxAge() * uint64_t(1000);
    list<shared_ptr<PMLetterContainer>>::iterator letterIt;
    for (letterIt = activeLetters.begin(); letterIt != activeLetters.end(); ++letterIt) {
        if (((*letterIt)->getAge() >= maxAge) || ((*letterIt)->getNeedsToBeRemoved())) {
            (*letterIt).get()->destroy();
            activeLetters.erase(letterIt++);
        }
    }


    switch (_mode) {
    case 1 : {
        box2d.setGravity(myGUI->getGravityX(), myGUI->getGravityY());
        oldMode = 1;
        break;
    }
    case 2 : {
        float time = ofGetElapsedTimef();
        float gX = sin(time * myGUI->getSinusFreq()) * myGUI->getSinusAmplitude();
        float gY = cos(time * myGUI->getSinusFreq()) * myGUI->getSinusAmplitude();
        myGUI->setGravityX(gX);
        myGUI->setGravityY(gY);
        box2d.setGravity(gX, gY);
        break;
    }
    case 3 : {
        box2d.setGravity(myGUI->getGravityX(), myGUI->getGravityY());
        oldMode = 3;
        for (letterIt = activeLetters.begin(); letterIt != activeLetters.end(); ++letterIt) {
            ofVec2f mouse(ofGetMouseX(), ofGetMouseY());

            ofVec2f v = ofVec2f(ofGetMouseX() / ofGetWidth(), ofGetMouseY() / ofGetHeight());
            (*letterIt)->addAttractionPoint(mouse, myGUI->getAttractorForce());
        }

    }

    case 4 : {
        box2d.setGravity(myGUI->getGravityX(), myGUI->getGravityY());
        oldMode = 4;

    }
    default :
        break;

    }

    box2d.update();


}
コード例 #16
0
ファイル: Algorythm.cpp プロジェクト: 4Enjoy/Letters-2048
void Algorythm::makeMove(MoveDirection direction)
{
    std::vector< std::vector <CellMovementInfo > > for_drawer;
    int64_t old_score = _score;



    //move
    _direction = direction;
    for(int y=0; y<Cell::N; ++y)
    {
        int empty = 0;
        _info.clear();

        for(int x=0; x<Cell::N; ++x)
        {
            //replace coordinates in deppend  on direction
            int x_cur = x;
            int y_cur = y;

            if(direction == MoveDirection::Right || direction == MoveDirection::Up)
                x_cur = Cell::N - x - 1;

            if(direction == MoveDirection::Down || direction == MoveDirection::Up)
            {
                std::swap(x_cur, y_cur);
            }
            Cell curr_cell = _cells.getCell(x_cur,y_cur);

            if(curr_cell.isEmpty())
                ++ empty;
            else
            {
                processOneCell(x_cur, y_cur, empty);
            }
        }

        if(!_info.empty())
            for_drawer.push_back(_info);
    }

    //if there is no changes after the move do not add new letter(do not continue the algorythm)
    if(for_drawer.empty())
    {
        ADStatistics::logEvent("[Game] Move no change");
        previousActionFinished();
        return;
    }

    ADStatistics::logEvent("[Game] Move");

    //add a new letter
    Cell new_letter = addLetter();

    sendPackagetForDrawer(for_drawer, new_letter);
    //sendScores(for_drawer);

    //look - is there next move, if no - send signal to table - game end
    if(isGameEnd())
    {
        emit signalGameEnd();
    }

    //make unmerged all cells
    unMergeCells();

    //for debug
    logTable();

    //send scores
    if(old_score != _score)
    {
        emit signalScoreChanged(_score);
    }

    //send signal table is changed
    emit signalTableChanged(_cells);
}