/** @brief 다음 돌은 인공지능이 알아서 놓는다. 기본적으로 white 로 한다. 흰색돌이 이기면 0 흑돌이 이기면 1을 리턴한다. 종료상태가 아니라면 -1을 리턴한다. @date 2014-03-16 */ int CTable::NextAIStep(const PIECE pieceType) //pieceType=WHITE { if (ai::IsGameComplete(m_table, OppositePiece(pieceType))) { m_state = (pieceType==WHITE)? WIN_BLACK : WIN_WHITE; return -1; } bool err; CHECK_TIME_START; { Pos pos; m_state = ai::SearchBestLocation(m_table, pieceType, pos); if (GAME == m_state) SetPiece(pos, pieceType); } CHECK_TIME_END(m_procTime, err); if (ai::IsGameComplete(m_table, pieceType)) { m_state = (pieceType==WHITE)? WIN_WHITE : WIN_BLACK; } return -1; }
void quick() { extern int *input; int *copy_input[LOOP_COUNT]; int i, j; // Time check variable double time; BOOL err; for (i = 0; i < LOOP_COUNT; i++){ copy_input[i] = (int *) malloc(sizeof(int) * DATA_SIZE); for (j = 0; j < DATA_SIZE; j++) { // copy data copy_input[i][j] = input[j]; } } CHECK_TIME_START; for (i = 0; i < LOOP_COUNT; i++) { Quick_Sort(copy_input[i], DATA_SIZE); // if(x%(LOOP_COUNT/10) == 0) printf("*"); // printf("Selecting Result --> input[%d] : %d\n", result, input[result]); } CHECK_TIME_END(time, err); // // data output check // for (i = 0; i < DATA_SIZE; i++) { // if(i%(DATA_SIZE/10) == 0) printf("%d : %d, ", i, copy_input[i]); // } // printf(" Calc Time = %.0fus\n", time/LOOP_COUNT); printf("%.0f\n", time / LOOP_COUNT); }
void merge() { extern int *input; int *copy_input[LOOP_COUNT]; int i, j; // Time check variable double time; BOOL err; for (i = 0; i < LOOP_COUNT; i++) { copy_input[i] = (int *) malloc(sizeof(int) * DATA_SIZE); for (j = 0; j < DATA_SIZE; j++) { // copy data copy_input[i][j] = input[j]; } } CHECK_TIME_START; for (i = 0; i < LOOP_COUNT; i++) { Merge_Sort(copy_input[i], DATA_SIZE); } CHECK_TIME_END(time, err); // // data output check // for (i = 0; i < DATA_SIZE; i++) { // if (i % (DATA_SIZE / 10) == 0) // printf("%d : %d, ", i, copy_input[0][i]); // } // printf(" Calc Time = %.0fus\n", time/LOOP_COUNT); printf("%.0f\n", time / LOOP_COUNT); }