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 ptree = tlp_atree_work;
27 #if defined(CSASHOGI) && defined(_WIN32)
28 if ( argc != 2 || strcmp( argv[1], "csa_shogi" ) )
31 "The executable image is not intended\x0d"
32 "as an independent program file.\x0d"
33 "Execute CSA.EXE instead.",
34 str_myname, MB_OK | MB_ICONINFORMATION );
40 if ( argc == 2 && ! strcmp( argv[1], "usi" ) ) { usi_mode = usi_on; }
41 else { usi_mode = usi_off; }
44 if ( ini( ptree ) < 0 )
46 out_error( "%s", str_error );
52 iret = main_child( ptree );
55 out_error( "%s", str_error );
59 else if ( iret == -2 )
61 out_warning( "%s", str_error );
65 else if ( iret == -3 ) { break; }
68 if ( fin() < 0 ) { out_error( "%s", str_error ); }
75 main_child( tree_t * restrict ptree )
81 iret = ponder( ptree );
82 if ( iret < 0 ) { return iret; }
83 else if ( game_status & flag_quit ) { return -3; }
85 /* move prediction succeeded, pondering finished,
86 and computer made a move. */
87 else if ( iret == 2 ) { return 1; }
89 /* move prediction failed, pondering aborted,
90 and we have opponent's move in input buffer. */
91 else if ( ponder_move == MOVE_PONDER_FAILED )
95 /* pondering is interrupted or ended.
96 do nothing until we get next input line. */
103 iret = next_cmdline( 1 );
104 if ( iret < 0 ) { return iret; }
105 else if ( game_status & flag_quit ) { return -3; }
108 iret = procedure( ptree );
109 if ( iret < 0 ) { return iret; }
110 else if ( game_status & flag_quit ) { return -3; }