bool HandleCoincidence(SkTArray<SkOpContour*, true>* contourList, int total) {
#if DEBUG_SHOW_WINDING
    SkOpContour::debugShowWindingValues(contourList);
#endif
    CoincidenceCheck(contourList, total);
#if DEBUG_SHOW_WINDING
    SkOpContour::debugShowWindingValues(contourList);
#endif
    fixOtherTIndex(contourList);
    checkEnds(contourList);  // check if connecting curve intersected at the same end
    bool hasM = checkMultiples(contourList);  // check if intersections agree on t and point values
    SkTDArray<SkOpSegment::AlignedSpan> aligned;
    if (hasM) {
        alignMultiples(contourList, &aligned);  // align pairs of identical points
        alignCoincidence(contourList, aligned);
    }
    checkDuplicates(contourList);  // check if spans have the same number on the other end
    checkTiny(contourList);  // if pair have the same end points, mark them as parallel
    checkSmall(contourList);  // a pair of curves with a small span may turn into coincident lines
    joinCoincidence(contourList);  // join curves that connect to a coincident pair
    sortSegments(contourList);
    if (!calcAngles(contourList)) {
        return false;
    }
    sortAngles(contourList);
#if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY
    DebugShowActiveSpans(*contourList);
#endif
    return true;
}
void strangeSplices(struct txGraph *graph, struct dnaSeq *chrom, FILE *f)
/* Write out introns with non-cannonical ends. */
{
    struct txEdge *edge;
    for (edge = graph->edgeList; edge != NULL; edge = edge->next)
    {
        if (edge->type == ggIntron)
        {
            int start = graph->vertices[edge->startIx].position;
            int end = graph->vertices[edge->endIx].position;
            if (checkEnds(chrom, start, end, "atac", graph->strand))
            {
                fprintf(f, "%s\t%d\t%d\t%s\t0\t%s\n", graph->tName,
                        start, end, "atacIntron", graph->strand);
            }
            else if (!checkEnds(chrom, start, end, "gtag", graph->strand) &&
                     !checkEnds(chrom, start, end, "gcag", graph->strand) )
            {
                fprintf(f, "%s\t%d\t%d\t%s\t0\t%s\n", graph->tName,
                        start, end, "strangeSplice", graph->strand);
            }
        }
    }
}
Beispiel #3
0
bool Player1::isSolved(char &whoWon) // 5 in a row?
{
	int l, m, line, row;	bool victory = false;
	int lineVal;			// how much a run / line is worth
	int helpfull;			// for diagonal board evaluation
	char coloR = 'X';	// alternate between 'P' and 'T'
	char direction = '@';	// dir of run / line of 2, 3, 4 ...

	two = three = four = 0;	// heur vars
	two_P_BB = two_P_BO = twp_P_OO = 0;		// color 'P'
	two_T_BB = two_T_BO = twp_T_OO = 0;		// color 'T'
	three_P_BB = three_P_BO = three_P_OO = 0;	// Blocked Blocked
	three_T_BB = three_T_BO = three_T_OO = 0;	// Blocked Open
	four_P_BB = four_P_BO = four_P_OO = 0;	// Open Open
	four_T_BB = four_T_BO = four_T_OO = 0;

// HORIZONTAL check for ROWS for win ---------------------
	
	direction = 'H';

	for (l = 0; l < 19; l++)
	{
		line = 0;	// reset every new row

		for (m = 0; m < 19; m++)
		{
			if (pOneBoard[l][m] == 'E') 
				line = 0; // holes reset line

			if (pOneBoard[l][m] == 'P')
			{
				if (coloR == 'P') 
					line++;	// line already started
				else				
				{
					coloR = 'P';	 // start new line
					line = 1;		
				}
			}
			else if (pOneBoard[l][m] == 'T')
			{
				if (coloR == 'T') 
					line++; // line already started
				else				{
					coloR = 'T';	 // start new line
					line = 1;		}
			}
//--------- TALLY heuristic variables --------------------

			if (2 <= line && line <= 4)
			{
				// check ends : OPPO or OPPT or TPPO or TPPT
				//checkEnds(direction, line, row, col);
				lineVal = checkEnds(direction, coloR, line, l, m);
				TALLY_heur_vars(line, lineVal, coloR);
				//				3	   
			}
			else if (line == 5)			
			{
				victory = true;	
				whoWon = coloR;
				return victory;		
			}

//--------- END TALLY -------------------------------------

		}
	}

// VERTICAL check for COLUMNS for wins -----------------------

	direction = 'V';
	
	for (l = 0; l < 19; l++)
	{
		line = 0;	// reset every new column

		for (m = 0; m < 19; m++)
		{
			if (pOneBoard[m][l] == 'E')	 line = 0; // holes reset line

			if (pOneBoard[m][l] == 'P')
			{
				if (coloR == 'P') // line already started
					line++;
				else				{
					coloR = 'P';	 // start new line
					line = 1;		}	
			}
			else if (pOneBoard[m][l] == 'T')
			{
				if (coloR == 'T') // line already started
					line++;
				else				{
					coloR = 'T';	 // start new line
					line = 1;		}
			}

//--------- TALLY heuristic variables --------------------

			if (2 <= line && line <= 4)
			{
				//checkEnds(direction, line, row, col);
				lineVal = checkEnds(direction, coloR, line, m, l);
				TALLY_heur_vars(line, lineVal, coloR);
			}
			else if (line == 5)			
			{
				victory = true;	line = 0;	
				whoWon = coloR;
				return victory;		
			}

//--------- END TALLY -------------------------------------
		}
	}

// 1 DIAGONAL BL, board cut into 2 triangles w/ 45 angle at BL

	direction = '1';

	for (l = 14; l >= 0; l--) // diminishing rows
	{
		line = 0;	row = l;

		for (m = 0; m < 19 - l; m++) // 5 diagonals at row 14
		{
			if (pOneBoard[row][m] == 'E')	 // holes reset line
				line = 0;
			else if (pOneBoard[row][m] == 'P')
			{
				if (coloR == 'P') // line already started
					line++;
				else 
				{
					coloR = 'P';	 // start new line
					line = 1;
				}
			}
			else if (pOneBoard[row][m] == 'T')
			{
				if (coloR == 'T') // line already started
					line++;
				else {
					coloR = 'T';	 // start new line
					line = 1;}
			}

//--------- TALLY heuristic variables --------------------
			
			if (2 <= line && line <= 4)
			{
				//checkEnds(direction, line, row, col);
				lineVal = checkEnds(direction, coloR, line, row, m);
				TALLY_heur_vars(line, lineVal, coloR);
			}
			if (line == 5)
			{
				victory = true;
				whoWon = coloR;
				return victory;
			}

//--------- END TALLY -------------------------------------

			row++; // ***************************
		}
	}

// 2 DIAGONAL TR, board cut into 2 triangles w/ 45 angle at TR

	direction = '2';	helpfull = 14;
	
	for (l = 4; l < 18; l++) // not l > 19 - fixed overlap w/ BL
	{
		line = 0;	helpfull--;	row = l;

		for (m = 18; m > helpfull; m--) // 5 diagonals at row 14
		{
			if (pOneBoard[row][m] == 'E')	 // holes reset line
				line = 0;

			if (pOneBoard[row][m] == 'P')
			{
				if (coloR == 'P') // line already started
					line++;
				else {
					coloR = 'P';	 // start new line
					line = 1;}
			}
			else if (pOneBoard[row][m] == 'T')
			{
				if (coloR == 'T') // line already started
					line++;
				else {
					coloR = 'T';	 // start new line
					line = 1;}
			}

//--------- TALLY heuristic variables --------------------
			
			if (2 <= line && line <= 4)
			{
				//checkEnds(direction, line, row, col);
				lineVal = checkEnds(direction, coloR, line, row, m);
				TALLY_heur_vars(line, lineVal, coloR);
			}
			if (line == 5)
			{
				victory = true;
				whoWon = coloR;
				return victory;
			}

//--------- END TALLY -------------------------------------

			row--; // ***************************
		}
	}

// 3 DIAGONAL BR, board cut into 2 triangles where 45 angle is at BR
	
	direction = '3';	helpfull = 14;
	
	for (l = 14; l > 0; l--) // not l >= 0 - fixed overlap w/ TL
	{
		line = 0;	helpfull--;	row = l;

		for (m = 18; m > helpfull; m--) // 5 diagonals at row 14
		{
			if (pOneBoard[row][m] == 'E')	 // holes reset line
				line = 0;

			if (pOneBoard[row][m] == 'P')
			{
				if (coloR == 'P') // line already started
					line++;
				else {
					coloR = 'P';	 // start new line
					line = 1;}
			}
			else if (pOneBoard[row][m] == 'T')
			{
				if (coloR == 'T') // line already started
					line++;
				else {
					coloR = 'T';	 // start new line
					line = 1;}
			}

//--------- TALLY heuristic variables --------------------
			
			if (2 <= line && line <= 4)
			{
				//checkEnds(direction, line, row, col);
				lineVal = checkEnds(direction, coloR, line, row, m);
				TALLY_heur_vars(line, lineVal, coloR);
			}
			if (line == 5)
			{
				victory = true;
				whoWon = coloR;
				return victory;
			}

//--------- END TALLY -------------------------------------

			row++;	// diagonal goes down and to the left
		}}

// 4 DIAGONAL TL, board cut into 2 triangles w/ 45 angle at TL
	
	direction = '4';	helpfull = 4;
	
	for (l = 4; l < 19; l++)
	{
		line = 0;	helpfull++;		row = l;

		for (m = 0; m < helpfull; m++) // 5 diagonals at row 14
		{
			if (pOneBoard[row][m] == 'E')	 // holes reset line
				line = 0;

			if (pOneBoard[row][m] == 'P')
			{
				if (coloR == 'P') // line already started
					line++;
				else {
					coloR = 'P';	 // start new line
					line = 1;}
			}
			else if (pOneBoard[row][m] == 'T')
			{
				if (coloR == 'T') // line already started
					line++;
				else {
					coloR = 'T';	 // start new line
					line = 1;}
			}

//--------- TALLY heuristic variables --------------------
			
			if (2 <= line && line <= 4)
			{
				//checkEnds(direction, line, row, col);
				lineVal = checkEnds(direction, coloR, line, row, m);
				TALLY_heur_vars(line, lineVal, coloR);
			}
			if (line == 5)
			{
				victory = true;
				whoWon = coloR;
				return victory;
			}

//--------- END TALLY -------------------------------------

			row--;	// ***************************
		}
	}

	return victory; // false, but heur vals come back
}