ProceduralGraph::ProceduralGraph(int minChild, int maxChild, int nodeCount) : Graph() { this->minChild=minChild; this->maxChild=maxChild; this->nodeCount=nodeCount; parseGraph(); fromTo(); }
bool crossesEastBorder(const vpImage<int> &I, bool checked[8], const vpImagePoint &point) { vpDirection direction; if ( !fromTo(point, vpImagePoint(point.get_i(), point.get_j() + 1), direction) ) { return false; } bool b = checked[(int) direction.m_direction]; if (point.get_i() < 0 || point.get_j() < 0) { return false; } unsigned int i = (unsigned int) point.get_i(); unsigned int j = (unsigned int) point.get_j(); return I[i][j] != 0 && ( (unsigned int) point.get_j() == I.getWidth()-1 || b); }
// insert proper tests here int main (int argc, const char * argv[]) { int start,end; printf("input start and end\n"); scanf("%d %d",&start,&end); link list = fromTo (start, end); printList (list); printf("The sum is %d.\n",sumListItems(list)); dlink doublelist = doublify(list); printDList(doublelist); freeList(list); freeDList(doublelist); return 0; }
void followBorder(vpImage<int> &I, const vpImagePoint &ij, vpImagePoint &i2j2, vp::vpContour *border, const int nbd) { vpDirection dir; if (!fromTo(ij, i2j2, dir)) { throw vpException(vpException::fatalError, "ij == i2j2"); } vpDirection trace = dir.clockwise(); vpImagePoint i1j1(-1, -1); //Find i1j1 (3.1) while (trace.m_direction != dir.m_direction) { vpImagePoint activePixel = trace.active(I, ij); if (activePixel.get_i() >= 0 && activePixel.get_j() >= 0) { i1j1 = activePixel; break; } trace = trace.clockwise(); } if (i1j1.get_i() < 0 || i1j1.get_j() < 0) { //(3.1) ; single pixel contour return; } i2j2 = i1j1; vpImagePoint i3j3 = ij; //(3.2) bool checked[8] = { false, false, false, false, false, false, false, false }; while (true) { if (!fromTo(i3j3, i2j2, dir)) { throw vpException(vpException::fatalError, "i3j3 == i2j2"); } trace = dir.counterClockwise(); vpImagePoint i4j4(-1, -1); //Reset checked for (int cpt = 0; cpt < 8; cpt++) { checked[cpt] = false; } while (true) { i4j4 = trace.active(I, i3j3); //(3.3) if (i4j4.get_i() >= 0 && i4j4.get_j() >= 0) { break; } checked[(int) trace.m_direction] = true; trace = trace.counterClockwise(); } addContourPoint(I, border, i3j3, checked, nbd); if (i4j4 == ij && i3j3 == i1j1) { //(3.5) break; } //(3.5) i2j2 = i3j3; i3j3 = i4j4; } }
int main(){ int player1Seed=3,player2Seed=3,machineSeed=3; int who_begins,c; int play,player2;//lebels for goto statements int i,previous; int vlue_frm_function; int choice_of_player; int select; int depart,destination; srand(time(NULL)); printf("\t\tSMARTSOFT FROM SMARTLAB\n"); printf("do you want to play with a player or with the machine\n"); printf("enter 1 to play with another player or 2 to play with the machine\n"); scanf("%d",&choice_of_player); for(i=0;i<9;i++) board[i]=' '; switch(choice_of_player){ case 1: while(board[i]=' '){ if (player==1){ display_board(); checkForWin(); player1: if (player1Seed!=0){ printf("player X it's is your turn\n"); printf("Make your box selection\n"); scanf("%d",&select); vlue_frm_function=selection(select,player);\ if (vlue_frm_function==false) goto player1; // display_board(); player1Seed--; } else { printf("player X it's is your turn\n"); printf("from___ to __ seperated by space\n"); scanf("%d%d",&depart,&destination); vlue_frm_function=fromTo(depart,destination,player); if (vlue_frm_function==false) goto player1; //display_board(); } display_board(); player=2; } // else if(selection(select,player)==1) // player=2; else if (player=2){ display_board(); checkForWin(); player2: if (player2Seed!=0){ printf("player t it's your turn\n"); printf("make your box selection\n"); scanf("%d",&select); vlue_frm_function= selection(select,player); if (vlue_frm_function==false) goto player2; player2Seed--; } else{ printf("player t it's your turn\n"); printf("from___To___seperated by spaces\n"); scanf("%d%d",&depart,&destination); vlue_frm_function=fromTo(depart,destination,player); if(vlue_frm_function==false) goto player2; } display_board(); player=1; // } } } break; case 2: who_begins=rand()%2; if(who_begins==1) goto play; while(board[i]=' '){ display_board(); checkForWin(); previous: printf("player X it's your turn\n"); printf("make your box selection\n"); scanf("%d",&select); vlue_frm_function= selection(select,player); if (vlue_frm_function==false) goto previous; player1Seed--; display_board(); play: player='m'; //the machines turn to play the game machine_play(); machineSeed--; display_board(); checkForWin(); player=1; } break; } supportsite(); return 0; }