5 #if defined(USI) || defined(MNJ_LAN) || defined(XBOARD)
6 static int is_move_ignore( unsigned int move );
10 make_root_move_list( tree_t * restrict ptree )
12 unsigned int * restrict pmove;
13 int asort[ MAX_LEGAL_MOVES ];
15 int i, j, k, h, value, num_root_move, iret, value_pre_pv;
18 pmove = ptree->move_last[0];
19 ptree->move_last[1] = GenCaptures( root_turn, pmove );
20 ptree->move_last[1] = GenNoCaptures( root_turn, ptree->move_last[1] );
21 ptree->move_last[1] = GenDrop( root_turn, ptree->move_last[1] );
22 num_root_move = (int)( ptree->move_last[1] - pmove );
24 value_pre_pv = INT_MIN;
26 for ( i = 0; i < num_root_move; i++ )
31 MakeMove( root_turn, move, 1 );
32 if ( ! InCheck( root_turn )
33 #if defined(USI) || defined(MNJ_LAN) || defined(XBOARD)
34 && ! is_move_ignore( move )
39 if ( InCheck(Flip(root_turn)) )
42 = (unsigned char)( ptree->nsuc_check[0] + 1U );
43 if ( ptree->nsuc_check[2] >= 2 * 2 )
45 iret = detect_repetition( ptree, 2, Flip(root_turn), 2 );
49 if ( iret == perpetual_check ) { value = INT_MIN; }
51 ptree->current_move[1] = move;
52 value = -search_quies( ptree, -score_bound, score_bound,
53 Flip(root_turn), 2, 1 );
55 if ( value > value_best ) { value_best = value; }
56 if ( I2IsPromote(move) ) { value++; }
57 if ( move == ptree->pv[0].a[1] )
64 UnMakeMove( root_turn, move, 1 );
69 for ( k = SHELL_H_LEN - 1; k >= 0; k-- )
72 for ( i = num_root_move-h-1; i >= 0; i-- )
76 for ( j = i+h; j < num_root_move && asort[j] > value; j += h )
78 asort[j-h] = asort[j];
79 pmove[j-h] = pmove[j];
86 /* discard all of moves cause mate or perpetual check */
87 if ( asort[0] >= -score_max_eval )
89 for ( ; num_root_move; num_root_move-- )
91 if ( asort[num_root_move-1] >= -score_max_eval ) { break; }
95 /* discard perpetual checks */
96 else for ( ; num_root_move; num_root_move-- )
98 if ( asort[num_root_move-1] != INT_MIN ) { break; }
101 for ( i = 0; i < num_root_move; i++ )
103 root_move_list[i].move = pmove[i];
104 root_move_list[i].nodes = 0;
105 root_move_list[i].status = 0;
106 #if defined(DFPN_CLIENT)
107 root_move_list[i].dfpn_cresult = dfpn_client_na;
110 if ( value_pre_pv != INT_MIN ) { asort[0] = value_pre_pv; }
111 root_nmove = num_root_move;
113 if ( num_root_move > 1 && ! ( game_status & flag_puzzling ) )
115 int id_easy_move = 0;
117 if ( asort[0] > asort[1] + ( MT_CAP_DRAGON * 3 ) / 8 )
120 easy_min = - ( MT_CAP_DRAGON * 4 ) / 16;
121 easy_max = ( MT_CAP_DRAGON * 32 ) / 16;
122 easy_abs = ( MT_CAP_DRAGON * 19 ) / 16;
124 else if ( asort[0] > asort[1] + ( MT_CAP_DRAGON * 2 ) / 8 )
127 easy_min = - ( MT_CAP_DRAGON * 3 ) / 16;
128 easy_max = ( MT_CAP_DRAGON * 6 ) / 16;
129 easy_abs = ( MT_CAP_DRAGON * 9 ) / 16;
131 else if ( asort[0] > asort[1] + MT_CAP_DRAGON / 8
132 && asort[0] > - MT_CAP_DRAGON / 8
133 && I2From(pmove[0]) < nsquare )
136 easy_min = - ( MT_CAP_DRAGON * 2 ) / 16;
137 easy_max = ( MT_CAP_DRAGON * 4 ) / 16;
138 easy_abs = ( MT_CAP_DRAGON * 6 ) / 16;
143 Out( "\n the root move %s looks easy (type %d).\n",
144 str_CSA_move(pmove[0]), id_easy_move );
145 Out( " evasion:%d, capture:%d, promotion:%d, drop:%d, "
147 ptree->nsuc_check[1] ? 1 : 0,
148 UToCap(pmove[0]) ? 1 : 0,
149 I2IsPromote(pmove[0]) ? 1 : 0,
150 I2From(pmove[0]) >= nsquare ? 1 : 0,
151 asort[0], asort[1] );
152 easy_value = asort[0];
160 #if defined(USI) || defined(MNJ_LAN) || defined(XBOARD)
162 is_move_ignore( unsigned int move )
166 for ( i = 0; moves_ignore[i] != MOVE_NA; i += 1 )
168 if ( move == moves_ignore[i] ) { return 1; }