9 static int main_child( tree_t * restrict ptree );
12 #if defined(CSASHOGI) || defined(USI)
13 main( int argc, char *argv[] )
19 tree_t * restrict ptree;
22 Out("feature done=0\n");
25 ptree = tlp_atree_work;
30 #if defined(CSASHOGI) && defined(_WIN32)
31 if ( argc != 2 || strcmp( argv[1], "csa_shogi" ) )
34 "The executable image is not intended\x0d"
35 "as an independent program file.\x0d"
36 "Execute CSA.EXE instead.",
37 str_myname, MB_OK | MB_ICONINFORMATION );
43 if ( argc == 2 && ! strcmp( argv[1], "usi" ) ) { usi_mode = usi_on; }
44 else { usi_mode = usi_off; }
47 if ( ini( ptree ) < 0 )
49 out_error( "%s", str_error );
55 iret = main_child( ptree );
58 out_error( "%s", str_error );
62 else if ( iret == -2 )
64 out_warning( "%s", str_error );
68 else if ( iret == -3 ) { break; }
71 if ( fin() < 0 ) { out_error( "%s", str_error ); }
78 main_child( tree_t * restrict ptree )
84 iret = ponder( ptree );
85 if ( iret < 0 ) { return iret; }
86 else if ( game_status & flag_quit ) { return -3; }
88 /* move prediction succeeded, pondering finished,
89 and computer made a move. */
90 else if ( iret == 2 ) { return 1; }
92 /* move prediction failed, pondering aborted,
93 and we have opponent's move in input buffer. */
94 else if ( ponder_move == MOVE_PONDER_FAILED )
98 /* pondering is interrupted or ended.
99 do nothing until we get next input line. */
106 iret = next_cmdline( 1 );
107 if ( iret < 0 ) { return iret; }
108 else if ( game_status & flag_quit ) { return -3; }
111 iret = procedure( ptree );
112 if ( iret < 0 ) { return iret; }
113 else if ( game_status & flag_quit ) { return -3; }