OpenCores
URL https://opencores.org/ocsvn/connect-6/connect-6/trunk

Subversion Repositories connect-6

[/] [connect-6/] [trunk/] [BUILD_SCC/] [synth_src/] [search.cpp] - Diff between revs 11 and 12

Show entire file | Details | Blame | View Log

Rev 11 Rev 12
Line 30... Line 30...
/* Depth is in _moves_ */
/* Depth is in _moves_ */
{
{
        int i, j;
        int i, j;
 
 
        /* Halt and depth abort */
        /* Halt and depth abort */
        if (ai_stop || depth < 1)
        if (ai_stop || depth < 1){
 
                printf("dpeth %d %d\n",depth,moves->utility);
                return moves->utility;
                return moves->utility;
 
        }
        /* Alpha-beta sanity check */
        /* Alpha-beta sanity check */
        if (alpha >= beta) {
        if (alpha >= beta) {
                //g_warning("DFS alpha-beta failed sanity check");
                //g_warning("DFS alpha-beta failed sanity check");
                        //printf("DFS alpha-beta failed sanity check\n");
                        //printf("DFS alpha-beta failed sanity check\n");
                return moves->utility;
                return moves->utility;
        }
        }
 
 
        /* Search only the top moves beyond the minimum */
        /* Search only the top moves beyond the minimum */
        //aimoves_sort(moves);
        //aimoves_sort(moves);
        if (moves->len > player->branch) {
        if (moves->len > player->branch) {
                for (i = player->branch; i < moves->len; i++)
        //        for (i = player->branch; i < moves->len; i++)
                        if (moves->data[i].weight != moves->data[0].weight)
        //                if (moves->data[i].weight != moves->data[0].weight)
                                break;
        //                        break;
                moves->len = i;
        //        moves->len = i;
 
        moves->len=player->branch;
        }
        }
 
 
        /* No moves left -- its a draw */
        /* No moves left -- its a draw */
        if (moves->len < 1)
        if (moves->len < 1)
                return AIW_DRAW;
                return AIW_DRAW;
Line 104... Line 106...
                        //if (!func) {
                        //if (!func) {
                        //        g_warning("DFS player has no AI function");
                        //        g_warning("DFS player has no AI function");
                        //        return moves->utility;
                        //        return moves->utility;
                        //}
                        //}
                        //moves_next = func(b_next);
                        //moves_next = func(b_next);
        printf("depth %d branch %d player %d moves_left %d alpha %d MOVE %d %d \n",depth,i,b_next.turn,b_next.moves_left,alpha,aim->y+1,aim->x+1);
        //printf("depth %d branch %d player %d moves_left %d alpha %d MOVE %d %d \n",depth,i,b_next.turn,b_next.moves_left,alpha,aim->y+1,aim->x+1);
                        ai_threats(&b_next,&moves_next,index);
                        ai_threats(&b_next,&moves_next,index);
 
 
                        aim->weight = df_search(&b_next, &moves_next, index,player,
                        aim->weight = df_search(&b_next, &moves_next, index,player,
                                                depth - 1, next_ci, searched,
                                                depth - 1, next_ci, searched,
                                                next_alpha, next_beta);
                                                next_alpha, next_beta);
Line 147... Line 149...
 
 
int  search(const Board *b, AIMove *move, Player *player)
int  search(const Board *b, AIMove *move, Player *player)
{
{
        AIMoves moves;
        AIMoves moves;
        Board copy;
        Board copy;
 
        #pragma internal_blockram copy
        unsigned int index[361]={0};
        unsigned int index[361]={0};
        //AIFunc move_func = ai(player->ai)->func;
        //AIFunc move_func = ai(player->ai)->func;
 
 
        /* Player is not configured to search */
        /* Player is not configured to search */
        //if (player->search == SEARCH_NONE)
        //if (player->search == SEARCH_NONE)
Line 205... Line 208...
        ai_threats(&copy,&moves,&index[0]);
        ai_threats(&copy,&moves,&index[0]);
 
 
        //if (player->search == SEARCH_DFS) {
        //if (player->search == SEARCH_DFS) {
                df_search(&copy, &moves, &index[0],player, player->depth, 0,
                df_search(&copy, &moves, &index[0],player, player->depth, 0,
                          PIECE_SEARCHED, AIW_LOSE, AIW_WIN);
                          PIECE_SEARCHED, AIW_LOSE, AIW_WIN);
 
        printf("%d %d \n",moves.data[0].weight,moves.data[1].weight);
        int ret_val;
        int ret_val;
        ret_val=aimoves_choose(&moves, move,&index[0]);
        ret_val=aimoves_choose(&moves, move,&index[0]);
        if (!ret_val)
        if (!ret_val)
                return 0;
                return 0;
        else return 1;
        else return 1;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.