result_t* play(uint8_t board_size, neuralnet_t* black, neuralnet_t* white, uint8_t komi, FILE* record) { board_t* board = board_create(board_size); bool game_over = false; int8_t passed = 0; result_t* final = result_init(black, white); //Game loop while(game_over == false) { move_t* move = genmove(board, final); //No move left if(move->x == -1) { game_over = true; break; } //Pass else if(move->x >= board_size) { board_pass(board); ++passed; if(passed > 1) { game_over = true; break; } } //Placement else { write_move(record, board->turn, (uint8_t)move->x, (uint8_t)move->y); board_place(board, (uint8_t)move->x, (uint8_t)move->y); passed = 0; } } //Scoring int score_val = board_score(board); final->score_black = score_val;
int main() { takeInputs(); FILE *f = fopen("Ids.txt","w"); printf("I am the AIRPORT PROCESS. PID: %d ; Parent ID : %d\n",getpid(),getppid()); boardPid = fork(); if(boardPid == 0) { board_pass(user); exit(4); } waloPid = fork(); if(waloPid == 0) { wait_lounge(user); exit(4); } secPid = fork(); if(secPid == 0) { security(user); exit(3); } immPid = fork(); if(immPid == 0) { immigration(user); exit(2); } bagPid = fork(); if(bagPid == 0) { baggage(user); exit(1); } fprintf(f,"%d ",bagPid); fprintf(f,"%d ",immPid); fprintf(f,"%d ",secPid); fprintf(f,"%d ",waloPid); fprintf(f,"%d ",boardPid); fclose(f); //Main function block int y,i,j; for(y=0;y<allowed;y++) { printf("\nMain User number : %d => \n",y); sleep(1); kill(bagPid,SIGCONT); waitpid(bagPid,&status,WUNTRACED); kill(immPid,SIGCONT); } kill(getpid(),SIGSTOP); int wait_count; f = fopen("./board_pass/wait_count.txt","r"); fscanf(f,"%d",&wait_count); fclose(f); printf("\nAIRPORT SPEAKING ==> Total number of passengers arrived at airport : %d\n",allowed); printf("\nAIRPORT SPEAKING ==> Total number of passengers boarded : %d\n",allowed-wait_count); printf("\nAIRPORT SPEAKING ==> Flight number %d ready for departure with %d passengers\n",getpid(),allowed-wait_count); while(wait(NULL)!= -1); return 0; }