示例#1
0
int main(){
	cleanA(); // Start by setting each element in A to NULL.
	int z = 0, tries=0;	
	srand(time(0)); // Resets random.
	fileOK=fopen("OK.txt", "a+");
	fileEJOK=fopen("notOK.txt", "a+");
	
	
	int numberOfEnv=5; // Number of matrices to be created
	int obstaclesPerCent = 15; // How many percent of the environment should be obstacles?
	int multiplier = 5; // Scales the environments. 5 gives 5x5, 10x10, 15x15 and so on.
	int startAtLoop = 12; // Counter to keep track of which turn in the loop it is, starts at one since 0x0-maps aren't fun.
	int stopAtLoop = 20; // Will create environments ranging in size between "multiplier*startAtLoop" and "multiplier*stopAtLoop".
	
	for(;startAtLoop<=stopAtLoop;startAtLoop++){
		height = multiplier*startAtLoop;
		width = multiplier*startAtLoop;
		obstacles=(height*width*obstaclesPerCent/100);// Set number of obstacles
		SIZE = (width*height);
		cleanA(); // Make sure A is clean from previous run.
		working = 0; // Keep track of number of working environments.
		tries = 0;
		z = 0;
		while(working<numberOfEnv){
			create(*A, obstacles);
			//tries++; // Keep track of how many attempts it took to create enough working environments.
		}
	}
	
	fclose(fileOK);
	fclose(fileEJOK);
	return EXIT_SUCCESS;
}
示例#2
0
void TakasuPoppo::cleanBlocks() {    
    
    createB = false;
    if (toDestroyArray->count() != 0) {
        
        CCObject *object;
        CCARRAY_FOREACH(toDestroyArray, object) {            
            bool hyperA = false;
            bool hyperB = false;
            TPBlockSet *blockSet = dynamic_cast<TPBlockSet*>(object);
            if (blockSet->getType() == "hyperBlockC") {
                TakasuPoppo::cleanHyperBlockC(blockSet->getEx1());
            } else {
                hintCounter = 3;
                TakasuPoppo::plusAllComboCounter();
                // update current block set
                currentBlockSet = blockSet->getBlocksArray();
                
                //===============================
                
                if(blockSet->getEx3() != NULL)
                {
                    score = score + (int)(ComboScoreRequired * increasedScore * SCORE_THREE * doubleScore);
                }
                if(blockSet->getEx4() != NULL && blockSet->getEx4()->getID() != 7)
                {
                    score = score + (int)(ComboScoreRequired * increasedScore * SCORE_FOUR * doubleScore);
                    hyperA = true;
                }
                if(blockSet->getEx5() != NULL)
                {
                    score =score + (int)(ComboScoreRequired * increasedScore * SCORE_FIVE *doubleScore);
                    hyperA = false;
                    hyperB = true;
                }
                
                if (isValidEx(blockSet->getEx1())){
                    TakasuPoppo::cleanOneBlock(blockSet->getEx1());
                    if(hyperA || hyperB)
                        generationEffect(blockSet->getEx1()->getPosition(), checkSwipe(blockSet)->getPosition());
                }
                
                if (isValidEx(blockSet->getEx2())){
                    if((!hyperA && !hyperB) || checkSwipe(blockSet)->getBlockType() >= MOVED_NORMAL_BLOCK_TYPE)
                    {
                        
                        TakasuPoppo::cleanOneBlock(blockSet->getEx2());
                        if(hyperA || hyperB)
                            generationEffect(blockSet->getEx2()->getPosition(), checkSwipe(blockSet)->getPosition());
                    }
                }
                
                if (isValidEx(blockSet->getEx3())) {
                    TakasuPoppo::cleanOneBlock(blockSet->getEx3());
                    if(hyperA || hyperB)
                        generationEffect(blockSet->getEx3()->getPosition(), checkSwipe(blockSet)->getPosition());
                }
                
                if (isValidEx(blockSet->getEx4())) {
                    TakasuPoppo::cleanOneBlock(blockSet->getEx4());
                    if(hyperA || hyperB)
                        generationEffect(blockSet->getEx4()->getPosition(), checkSwipe(blockSet)->getPosition());
                }
                if (isValidEx(blockSet->getEx5())) {
                    TakasuPoppo::cleanOneBlock(blockSet->getEx5());
                    if(hyperA || hyperB)
                        generationEffect(blockSet->getEx5()->getPosition(), checkSwipe(blockSet)->getPosition());
                }
                
                if (isValidEx(blockSet->getEx6())) {
                    TakasuPoppo::cleanOneBlock(blockSet->getEx6());
                    if(hyperA || hyperB)
                        generationEffect(blockSet->getEx6()->getPosition(), checkSwipe(blockSet)->getPosition());
                    
                }
                
                if (isValidEx(blockSet->getEx7())) {
                    TakasuPoppo::cleanOneBlock(blockSet->getEx7());
                    if(hyperA || hyperB)
                        generationEffect(blockSet->getEx7()->getPosition(), checkSwipe(blockSet)->getPosition());
                    
                }
                
                if(checkSwipe(blockSet)->getBlockType() == 13)
                {
                    createSpecialBlock(checkSwipe(blockSet), HBB_BLOCK_TYPE);
                    currentBlockSet = NULL;
                    continue;
                }
                
                if(checkSwipe(blockSet)->getBlockType() >= 20)
                {
                    if (checkSwipe(blockSet)->getBlockType() == 21) {
                        cleanA(checkSwipe(blockSet));
                    }
                    if (checkSwipe(blockSet)->getBlockType() == 22) {
                        cleanB(checkSwipe(blockSet));
                    }
                    if(checkSwipe(blockSet)->getBlockType() == 26)
                        isCleanMB1 = true;
                    if(checkSwipe(blockSet)->getBlockType() == 27)
                        isCleanMB2 = true;
                    if(checkSwipe(blockSet)->getBlockType() == 28)
                        isCleanMB3 = true;
                    checkSwipe(blockSet)->setBlockType(13);

                }
                else if (checkSwipe(blockSet)->getBlockType() >= MOVED_NORMAL_BLOCK_TYPE && hyperA)
                {
                    if(checkSwipe(blockSet)->getBlockType() == MOVED_HBA_BLOCK_TYPE)
                        cleanA(checkSwipe(blockSet));
                    if(checkSwipe(blockSet)->getBlockType() == MOVED_HBB_BLOCK_TYPE)
                        cleanB(checkSwipe(blockSet));
                    if(checkSwipe(blockSet)->getBlockType() == MB1_BLOCK_TYPE + 10)
                        isCleanMB1 = true;
                    if(checkSwipe(blockSet)->getBlockType() == MB2_BLOCK_TYPE + 10)
                        isCleanMB2 = true;
                    if(checkSwipe(blockSet)->getBlockType() == MB3_BLOCK_TYPE + 10)
                        isCleanMB3 = true;
                    createSpecialBlock(checkSwipe(blockSet), HBA_BLOCK_TYPE);
                    hyperA = false;
                    hyperB = false;
                }
                else if(hyperA)
                {
                    createSpecialBlock(blockSet->getEx2(), HBA_BLOCK_TYPE);
                    hyperA = false;
                    hyperB = false;
                }
                else if (checkSwipe(blockSet)->getBlockType() >= MOVED_NORMAL_BLOCK_TYPE && hyperB)
                {
                    if(checkSwipe(blockSet)->getBlockType() == MOVED_HBA_BLOCK_TYPE)
                        cleanA(checkSwipe(blockSet));
                    if(checkSwipe(blockSet)->getBlockType() == MOVED_HBB_BLOCK_TYPE)
                        cleanB(checkSwipe(blockSet));
                    if(checkSwipe(blockSet)->getBlockType() == MB1_BLOCK_TYPE + 10)
                        isCleanMB1 = true;
                    if(checkSwipe(blockSet)->getBlockType() == MB2_BLOCK_TYPE + 10)
                        isCleanMB2 = true;
                    if(checkSwipe(blockSet)->getBlockType() == MB3_BLOCK_TYPE + 10)
                        isCleanMB3 = true;
                    
                    createSpecialBlock(checkSwipe(blockSet), HBB_BLOCK_TYPE);
                    hyperA = false;
                    hyperB = false;
                }
                else if(hyperB)
                {
                    createSpecialBlock(blockSet->getEx2(), HBB_BLOCK_TYPE);
                    hyperB = false;
                    hyperA = false;
                }
                else {
                    cleanOneBlock(checkSwipe(blockSet));
                }
                currentBlockSet = NULL;
            }
        }