Move pb_probe(Pos *pos) { Move m1 = 0; if (!enabled) return m1; if (!check_do_search(pos)) return m1; if (book_depth_count >= max_book_depth) return m1; Key key = polyglot_key(pos); int n = find_first_key(key); if (n < 1) { search_counter++; if (search_counter > 4) { // Stop searching after 4 times not in the book till position changes // according to check_do_search() do_search = false; search_counter = 0; book_depth_count = 0; } return m1; } book_depth_count++; ssize_t idx1 = use_best_book_move ? index_best : index_rand; m1 = pg_move_to_sf_move(pos, from_be_u16(polyhash[idx1].move)); if (!is_draw(pos)) return m1; // 64 if (n == 1) return m1; // Special case draw position and 2 moves available if (!check_draw(pos, m1)) return m1; ssize_t idx2 = index_first; if (idx1 == idx2) idx2++; Move m2 = pg_move_to_sf_move(pos, from_be_u16(polyhash[idx2].move)); if (!check_draw(pos, m2)) return m2; return 0; }
void player_turn() { int pos; check_draw(); draw_board(); gotoxy(30, 18); printf("Your Turn :> "); scanf("%d", &pos); if (board[convert_pos_to_row(pos)][convert_pos_to_col(pos)] != EMPTY) player_turn(); move_to(pos); draw_board(); if (isWinning(player)) { gotoxy(30, 20); SetConsoleTextAttribute(h, FOREGROUND_RED); printf("Player Wins\n"); updateNumberOfWins(); SetConsoleTextAttribute(h, 7); _getch(); menu(); //exit(0); } else start_game(); }
char *get_param(int flag) { extern t_client t; char *tmp; int a; tmp = malloc(my_strlen(t.contenu_map[t.i]) * sizeof(*tmp)); if (t.contenu_map[t.i][t.j] == ' ') t.j++; for (a = 0;t.contenu_map[t.i][t.j] != ' ' && t.contenu_map[t.i][t.j] != '\0';t.j++, a++) tmp[a] = t.contenu_map[t.i][t.j]; tmp[a] = '\0'; if (flag == 1) check_draw(tmp); return (tmp); }
void start_game() { // p==1 then X p==0 then O check_draw(); move_to(getPossibleWinningPos()); draw_board(); if (isWinning(comp)) { gotoxy(30, 20); SetConsoleTextAttribute(h, FOREGROUND_BLUE); printf("Computer wins\n"); SetConsoleTextAttribute(h, 7); //7 - WHITE _getch(); menu(); } else player_turn(); }