void fonction() { int c; char cc; int n; int j; j = 0; n = 0; char tab[9][18] = { {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'}, {' ',' ','#',' ',' ',' ',' ',' ',' ',' ','#',' ','#',' ',' ',' ',' ','#'}, {'#',' ','#',' ','#',' ','#',' ','#','#','#',' ','#','#','#',' ',' ',' '}, {'#',' ',' ',' ','#',' ',' ',' ','#',' ',' ','#',' ',' ',' ',' ','#',' '}, {'#','#','#',' ','#','#','#','#','#','#',' ',' ',' ','#',' ',' ','#','#'}, {'#',' ',' ',' ',' ',' ','#','#',' ',' ',' ','#',' ','#','#','#','#','#'}, {' ',' ','#','#','#',' ','#','#',' ','#','#','#',' ','#','#',' ','#',' '}, {'#','#','#',' ',' ',' ',' ',' ',' ','#','#','#',' ',' ',' ','#','#',' '}, {'#','#','#','#','#','#','#','#','#','#','#','#','#','#',' ','#','#','#'}}; affiche2d(tab); while (1) { if (j == 0) j = menu(n); char tab[7][15] = { {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}, {'8',' ',' ','0','0',' ',' ',' ',' ',' ','0','0',' ','0','0'}, {'0','0',' ','0','0',' ','0','0','0',' ','0','0',' ','0','0'}, {'0','0',' ','0','0',' ','0','0',' ',' ',' ',' ',' ','0','0'}, {'0','0',' ',' ',' ',' ','0','0','0','0','0','0',' ','0','0'}, {'0','0','0','0','0',' ',' ',' ',' ',' ','0','0',' ',' ',' '}, {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'} }; my_putstr("Rejouez oui(o)/non(n)/menu(m)\n"); cc = getchar(); while ((c = getchar()) != '\n' && c != EOF); my_putstr("\033[H\033[2J"); if (cc == 'o') { if (j == 1) play1(tab, n, 0); if (j == 2) play2(); if (j == 3) play1(tab, n, 1); if (j == 4) play1(tab, n, 2); } if (cc == 'm') j = menu(n); if (cc == 'n') return ; } }
void play1() { printf("\nPlayer 1 playing\n"); printf("\nEnter the row: "); scanf("%d",&row); row--; printf("\nEnter the column: "); scanf ("%d",&col); col--; if(row < 3 && row >= 0 && col < 3 && col >= 0 && !ch[row][col]) { ch[row][col] = 'x'; count--; player = win(); if(player == 1) { system("cls"); printf("---------------------------->Player 1 Wins!!! Congratulations!!!<-------------\n\n"); count = 0; display(); } else { system("cls"); display(); } } else { printf("Wrong input... Enter again"); play1(); } }
int main() { draw_board(); while(1) { play1(); play2(); } return 0; }
void display() { int j; int i; printf("\t\t <TIC-TAC-TOE>\n"); for(j = 0; j < 10;j++) { printf(" "); } for(j = 0;j < 3;j++) { printf(" - "); } printf("\n"); for(i = 0;i < 3;i++) { for(j = 0; j < 10;j++) { printf(" "); } for(j = 0;j < 3;j++) { printf("|%c|",ch[i][j]); } printf("\n"); for(j = 0; j < 10;j++) { printf(" "); } for(j = 0;j < 3;j++) { printf(" - "); } printf("\n"); } if(count) { if(player == 1) { play1(); } else { play2(); } } else { printf("\n----------------------------------->END OF GAME<-------------------------------\n"); again(); } }
void mainControlSM(ros::NodeHandle &n) { stream::info.open("info.txt"); //PUBLISHER FOR MOTIONCONTROL ros::Publisher robo1Com = n.advertise<robot_soccer::controldata>("robot1Com", 5); ros::Publisher robo2Com = n.advertise<robot_soccer::controldata>("robot2Com", 5); //SUBSCRIBER FROM VISION ros::Subscriber vision_subscriber = n.subscribe("vision_data", 5, visionCallback); (void*)vision_subscriber; ros::Rate loop_rate(TICKS_PER_SEC); ros::Subscriber gameCmdSub = n.subscribe("game_cmd", 5, gameCmdCallback); (void*)gameCmdSub; // Strategies strategies; // Skills skill(RobotType::ally2); // skill.aim(); // Plays play2(RobotType::ally2); // play2.playGoalie(); Plays play1(RobotType::ally1); play1.rushGoal(); while (ros::ok()) { // checkGCFlags(strategies); if (visionUpdated) { visionUpdated = false; field.updateStatus(visionStatus_msg); // strategies.tick(); play1.tick(); // play2.tick(); // skill.tick(); } if (sendCmd_Rob1) { sendCmd_Rob1 = false; checkCmd(cmdRob1); robo1Com.publish(cmdRob1); } if (sendCmd_Rob2){ sendCmd_Rob2 = false; checkCmd(cmdRob2); robo2Com.publish(cmdRob2); } ros::spinOnce(); loop_rate.sleep(); } }
int main() { time_t secs; time(&secs); srand( (unsigned int)secs); dir = rand() % 4 + 1; BITMAP *buffer, *sball, *player1,*player2; allegro_init(); install_keyboard(); set_color_depth(16); set_gfx_mode( GFX_AUTODETECT_WINDOWED, 440, 280, 0, 0); buffer = create_bitmap( 440, 280); sball=create_bitmap(50,50); player1 = create_bitmap( 10, 60); player2 = create_bitmap( 10, 60); clear_to_color( sball, makecol( 255, 0, 0 ) ); clear_to_color( player1, makecol( 0, 255, 0 ) ); clear_to_color( player2, makecol( 0, 255, 0 ) ); while( !key[KEY_ESC]) { clear_to_color( buffer, makecol( 0, 0, 255 ) ); ball(); play1(); play2(); //rest(1); blit(sball,buffer,0,0,x,y,sball->w,sball->h); blit(player1,buffer,0,0,xx,yy,player1->w,player1->h); blit(player2,buffer,0,0,xxx,yyy,player2->w,player2->h); blit(buffer,screen,0,0,0,0,440,280); std::cout<<"dir"<<dir<<std::endl; } return 0; }
void createSons() { int pid1, pid2; int player1 = 0; int player2 = 10; time_t t; pid1 = fork(); switch(pid1) { case -1: printf("No child created!\n"); exit(1); case 0: signal(SIGINT, my_handler); while(1) { pause(); srand((unsigned) time(&t)); printf("Player1 Dice!\n"); draws[0] = throwTheDice(); if(*gameStarted == 1) { play1(draws[0]); } sleep(4); kill(getppid(), SIGINT); } break; default: pid2 = fork(); switch(pid2) { case -1: printf("No child created!\n"); exit(1); case 0: signal(SIGINT, my_handler); while(1) { pause(); srand((unsigned) time(&t)); printf("Player2 Dice!\n"); draws[1] = throwTheDice(); if(*gameStarted == 1) { play2(draws[1]); } sleep(4); kill(getppid(), SIGINT); } break; default: signal(SIGINT,my_handler); printf("I'm the father!\n"); sleep(4); while(1) { kill(pid1, SIGINT); pause(); printf("Player1 dice: %d\n", draws[0]); printf("\n"); kill(pid2, SIGINT); pause(); printf("Player2 dice: %d\n", draws[1]); printf("\n"); if(draws[1] < draws[0]) { *gameStarted = 1; printf("Player1 win the dice and will start the game!\n"); printf("\n"); printArray(arr, arrSIZE); while(1) { kill(pid1, SIGINT); pause(); printf("Player1 dice: %d\n", draws[0]); isWinner(); printArray(arr, arrSIZE); kill(pid2, SIGINT); pause(); printf("Player1 dice: %d\n", draws[0]); isWinner(); printArray(arr, arrSIZE); } break; } else if(draws[1] > draws[0]) { *gameStarted = 1; printf("Player2 win the dice and will start the game!\n"); printf("\n"); printArray(arr, arrSIZE); while(1) { kill(pid2, SIGINT); pause(); printf("Player2 dice: %d\n", draws[1]); isWinner(); printArray(arr, arrSIZE); kill(pid1, SIGINT); pause(); printf("Player1 dice: %d\n", draws[0]); isWinner(); printArray(arr, arrSIZE); } break; } else printf("Dice's are equals, try again please!\n"); } } } }
int check(int ply) { int i=0; switch(ply){ case 7 : if(digits[6]==0){ digits[6]=xoro(i); gotoxy(28,9); printf("%c", xo); numb++; }else{ if(xo== 'O'){ play2();} else if(xo== 'X'){ play1(); }} break; case 4 : if(digits[3]==0){ digits[3]=xoro(i); gotoxy(28,12); printf("%c", xo); numb++; }else{ if(xo== 'O'){ play2();} else if(xo== 'X'){ play1(); }} break; case 1 : if(digits[0]==0){ digits[0]=xoro(i); gotoxy(28,15); printf("%c", xo); numb++; }else{ if(xo== 'O'){ play2();} else if(xo== 'X'){ play1(); }} break; case 2 : if(digits[1]==0){ digits[1]=xoro(i); gotoxy(36,15); printf("%c", xo); numb++; }else{ if(xo== 'O'){ play2();} else if(xo== 'X'){ play1(); }} break; case 5 : if(digits[4]==0){ digits[4]=xoro(i); gotoxy(36,12); printf("%c", xo); numb++; }else{ if(xo== 'O'){ play2();} else if(xo== 'X'){ play1(); }} break; case 8 : if(digits[7]==0){ digits[7]=xoro(i); gotoxy(36,9); printf("%c", xo); numb++; }else{ if(xo== 'O'){ play2();} else if(xo== 'X'){ play1(); }} break; case 9 : if(digits[8]==0){ digits[8]=xoro(i); gotoxy(44,9); printf("%c", xo); numb++; }else{ if(xo== 'O'){ play2();} else if(xo== 'X'){ play1(); }} break; case 6 : if(digits[5]==0){ digits[5]=xoro(i); gotoxy(44,12); printf("%c", xo); numb++; }else{ if(xo== 'O'){ play2();} else if(xo== 'X'){ play1(); }} break; case 3 : if(digits[2]==0){ digits[2]=xoro(i); gotoxy(44,15); printf("%c", xo); numb++; }else{ if(xo== 'O'){ play2();} else if(xo== 'X'){ play1(); }} break; default : play1();} gotoxy(36,18); }