Пример #1
0
void clean_hash()
{
	for (int i = 0; i < HASHSIZE; i++)
	{
		if (hash.data[i] != 0)
			free_move(hash.data[i]);
	}
}
Пример #2
0
Move* MaxMove (Disc board [BOARD_SIZE][BOARD_SIZE],int current_player) {
    
    Disc copy [BOARD_SIZE][BOARD_SIZE];
    int temp_score =0, alpha =-1000;
    Move* best_move =NULL;
    Move* curr_suggested_move =NULL;
    MoveList* moves_for_all_discs_this_turn = NULL, *curr =NULL;
	count =0;
    
    update_all_legal_moves_for_player(board, current_player);

    moves_for_all_discs_this_turn = collect_all_moves_for_player(board, current_player);

    if (global_max_depth == 5)
    {
        curret_max_depth = calculate_current_best_max_depth(board);
    }
    else
    {
        curret_max_depth = global_max_depth;
    }
    
    curr = moves_for_all_discs_this_turn;
    while (curr  !=NULL && curr->m !=NULL)
    {
        copy_board_from_copy(board, copy);
        curr_suggested_move = curr->m;
         
 

        make_turn_for_player(copy,curr_suggested_move,current_player);
        if (global_max_depth ==5 && count > max_board_count)
        {
            free_all_optional_moves_for_player(copy,current_player);
            free_move_list(moves_for_all_discs_this_turn);
            moves_for_all_discs_this_turn = NULL;
            printf ("%lu\n",count);
            return best_move;
        }
        count++;
         
 


        temp_score = calculate_score_for_board_alpha(copy, 0, current_player*-1, -1000, 1000);
        
        if (temp_score >= alpha)
        {
            if (best_move !=NULL)
            {
                free_move(&best_move);
                best_move = NULL;
            }
            best_move= init_move_from_int_arrs(curr_suggested_move->from, curr_suggested_move->to);
            alpha =temp_score;
        }
        curr = curr->next;
    }
    free_all_optional_moves_for_player(copy,current_player);
    free_move_list(moves_for_all_discs_this_turn);
    moves_for_all_discs_this_turn = NULL;
    curr= NULL;
    printf ("%lu\n",count);
    return best_move;
}