Struct usiagent::selfmatch::SelfMatchEngine  [−][src]
pub struct SelfMatchEngine<E> where
    E: PlayerError,  {
    pub system_event_queue: Arc<Mutex<SystemEventQueue>>,
    // some fields omitted
}Expand description
自己対局エンジン
Fields
system_event_queue: Arc<Mutex<SystemEventQueue>>システムイベントキュー
Implementations
SelfMatchEngineの生成
pub fn start_default<T, S, P, I, F, RH, EH>(
    &mut self, 
    on_init_event_dispatcher: I, 
    flip_players: F, 
    initial_position_creator: Option<Box<dyn FnMut() -> String + Send + 'static>>, 
    kifu_writer: Option<Box<dyn FnMut(&String, &Vec<Move>) -> Result<(), KifuWriteError> + Send + 'static>>, 
    input_handler: RH, 
    player1: T, 
    player2: T, 
    player1_options: Vec<(String, SysEventOption)>, 
    player2_options: Vec<(String, SysEventOption)>, 
    info_sender: S, 
    pinfo_sender: P, 
    game_time_limit: UsiGoTimeLimit, 
    uptime: Option<Duration>, 
    number_of_games: Option<u32>, 
    on_error: EH
) -> Result<SelfMatchResult, SelfMatchRunningError<E>> where
    T: USIPlayer<E> + Debug + Send + 'static,
    F: FnMut() -> bool + Send + 'static,
    RH: FnMut(String) -> Result<bool, SelfMatchRunningError<E>> + Send + 'static,
    I: FnMut(&mut SelfMatchEventDispatcher<'_, E, FileLogger>),
    S: InfoSender,
    P: PeriodicallyInfo + Clone + Send + 'static,
    Arc<Mutex<FileLogger>>: Send + 'static,
    EH: FnMut(Option<Arc<Mutex<OnErrorHandler<FileLogger>>>>, &SelfMatchRunningError<E>), 
pub fn start_default<T, S, P, I, F, RH, EH>(
    &mut self, 
    on_init_event_dispatcher: I, 
    flip_players: F, 
    initial_position_creator: Option<Box<dyn FnMut() -> String + Send + 'static>>, 
    kifu_writer: Option<Box<dyn FnMut(&String, &Vec<Move>) -> Result<(), KifuWriteError> + Send + 'static>>, 
    input_handler: RH, 
    player1: T, 
    player2: T, 
    player1_options: Vec<(String, SysEventOption)>, 
    player2_options: Vec<(String, SysEventOption)>, 
    info_sender: S, 
    pinfo_sender: P, 
    game_time_limit: UsiGoTimeLimit, 
    uptime: Option<Duration>, 
    number_of_games: Option<u32>, 
    on_error: EH
) -> Result<SelfMatchResult, SelfMatchRunningError<E>> where
    T: USIPlayer<E> + Debug + Send + 'static,
    F: FnMut() -> bool + Send + 'static,
    RH: FnMut(String) -> Result<bool, SelfMatchRunningError<E>> + Send + 'static,
    I: FnMut(&mut SelfMatchEventDispatcher<'_, E, FileLogger>),
    S: InfoSender,
    P: PeriodicallyInfo + Clone + Send + 'static,
    Arc<Mutex<FileLogger>>: Send + 'static,
    EH: FnMut(Option<Arc<Mutex<OnErrorHandler<FileLogger>>>>, &SelfMatchRunningError<E>), 
デフォルト設定で開始(ログファイルのパスlogs/log.txt,ログをファイルに記録)
Arguments
on_init_event_dispatcher- 自己対局時に通知されるSelfMatchEventのイベントディスパッチャーを初期化flip_players- 対局時の初期局面時のplayer1とplayer2の手番の割り当てを逆にする。(通常はplayer1が先手)initial_position_creator- 対局毎の初期局面を生成して返す関数kifu_writer- 対局終了時に棋譜を書き込むためのコールバック関数input_handler- 標準入力から読みこんだ行が渡されるコールバック関数。システムイベントの発行などに使う(’quit’で終了など)player1- USIPlayerを実装したプレイヤーオブジェクトplayer2- USIPlayerを実装したプレイヤーオブジェクトplayer1_options- player1に渡されるオプションplayer2_options- player2に渡されるオプションinfo_sender- infoコマンドを送信するための機能を持つオブジェクトpinfo_sender- あらかじめスケジュールされた一定の間隔でinfoコマンドを送信するための機能を持つオブジェクトgame_time_limit- 対局毎の制限時間uptime- 自己対局機能全体の実行時間制限。この時間に達すると自己対局は終了する(現在の対局だけではない)number_of_games- 自己対局機能で行われる対局の回数。この回数を終えると自己対局は終了するon_error- エラー発生時に呼ばれるコールバック関数。エラーオブジェクトへの参照とロガーが渡される。
pub fn start_with_log_path<T, S, P, I, F, RH, EH>(
    &mut self, 
    path: String, 
    on_init_event_dispatcher: I, 
    flip_players: F, 
    initial_position_creator: Option<Box<dyn FnMut() -> String + Send + 'static>>, 
    kifu_writer: Option<Box<dyn FnMut(&String, &Vec<Move>) -> Result<(), KifuWriteError> + Send + 'static>>, 
    input_handler: RH, 
    player1: T, 
    player2: T, 
    player1_options: Vec<(String, SysEventOption)>, 
    player2_options: Vec<(String, SysEventOption)>, 
    info_sender: S, 
    pinfo_sender: P, 
    game_time_limit: UsiGoTimeLimit, 
    uptime: Option<Duration>, 
    number_of_games: Option<u32>, 
    on_error: EH
) -> Result<SelfMatchResult, SelfMatchRunningError<E>> where
    T: USIPlayer<E> + Debug + Send + 'static,
    F: FnMut() -> bool + Send + 'static,
    RH: FnMut(String) -> Result<bool, SelfMatchRunningError<E>> + Send + 'static,
    I: FnMut(&mut SelfMatchEventDispatcher<'_, E, FileLogger>),
    S: InfoSender,
    P: PeriodicallyInfo + Clone + Send + 'static,
    Arc<Mutex<FileLogger>>: Send + 'static,
    EH: FnMut(Option<Arc<Mutex<OnErrorHandler<FileLogger>>>>, &SelfMatchRunningError<E>), 
pub fn start_with_log_path<T, S, P, I, F, RH, EH>(
    &mut self, 
    path: String, 
    on_init_event_dispatcher: I, 
    flip_players: F, 
    initial_position_creator: Option<Box<dyn FnMut() -> String + Send + 'static>>, 
    kifu_writer: Option<Box<dyn FnMut(&String, &Vec<Move>) -> Result<(), KifuWriteError> + Send + 'static>>, 
    input_handler: RH, 
    player1: T, 
    player2: T, 
    player1_options: Vec<(String, SysEventOption)>, 
    player2_options: Vec<(String, SysEventOption)>, 
    info_sender: S, 
    pinfo_sender: P, 
    game_time_limit: UsiGoTimeLimit, 
    uptime: Option<Duration>, 
    number_of_games: Option<u32>, 
    on_error: EH
) -> Result<SelfMatchResult, SelfMatchRunningError<E>> where
    T: USIPlayer<E> + Debug + Send + 'static,
    F: FnMut() -> bool + Send + 'static,
    RH: FnMut(String) -> Result<bool, SelfMatchRunningError<E>> + Send + 'static,
    I: FnMut(&mut SelfMatchEventDispatcher<'_, E, FileLogger>),
    S: InfoSender,
    P: PeriodicallyInfo + Clone + Send + 'static,
    Arc<Mutex<FileLogger>>: Send + 'static,
    EH: FnMut(Option<Arc<Mutex<OnErrorHandler<FileLogger>>>>, &SelfMatchRunningError<E>), 
ログファイルのパスを指定して開始
Arguments
path- ログファイルのパスon_init_event_dispatcher- 自己対局時に通知されるSelfMatchEventのイベントディスパッチャーを初期化flip_players- 対局時の初期局面時のplayer1とplayer2の手番の割り当てを逆にする。(通常はplayer1が先手)initial_position_creator- 対局毎の初期局面を生成して返す関数kifu_writer- 対局終了時に棋譜を書き込むためのコールバック関数input_handler- 標準入力から読みこんだ行が渡されるコールバック関数。システムイベントの発行などに使う(’quit’で終了など)player1- USIPlayerを実装したプレイヤーオブジェクトplayer2- USIPlayerを実装したプレイヤーオブジェクトplayer1_options- player1に渡されるオプションplayer2_options- player2に渡されるオプションinfo_sender- infoコマンドを送信するための機能を持つオブジェクトpinfo_sender- あらかじめスケジュールされた一定の間隔でinfoコマンドを送信するための機能を持つオブジェクトgame_time_limit- 対局毎の制限時間uptime- 自己対局機能全体の実行時間制限。この時間に達すると自己対局は終了する(現在の対局だけではない)number_of_games- 自己対局機能で行われる対局の回数。この回数を終えると自己対局は終了するon_error- エラー発生時に呼ばれるコールバック関数。エラーオブジェクトへの参照とロガーが渡される。
pub fn start<T, S, P, I, F, R, RH, L, EH>(
    &mut self, 
    on_init_event_dispatcher: I, 
    flip_players: F, 
    initial_position_creator: Option<Box<dyn FnMut() -> String + Send + 'static>>, 
    kifu_writer: Option<Box<dyn FnMut(&String, &Vec<Move>) -> Result<(), KifuWriteError> + Send + 'static>>, 
    input_reader: R, 
    input_handler: RH, 
    player1: T, 
    player2: T, 
    player1_options: Vec<(String, SysEventOption)>, 
    player2_options: Vec<(String, SysEventOption)>, 
    info_sender: S, 
    pinfo_sender: P, 
    game_time_limit: UsiGoTimeLimit, 
    uptime: Option<Duration>, 
    number_of_games: Option<u32>, 
    logger: L, 
    on_error: EH
) -> Result<SelfMatchResult, SelfMatchRunningError<E>> where
    T: USIPlayer<E> + Debug + Send + 'static,
    F: FnMut() -> bool + Send + 'static,
    R: USIInputReader + Send + 'static,
    RH: FnMut(String) -> Result<bool, SelfMatchRunningError<E>> + Send + 'static,
    I: FnMut(&mut SelfMatchEventDispatcher<'_, E, L>),
    S: InfoSender,
    P: PeriodicallyInfo + Clone + Send + 'static,
    L: Logger + Debug + Send + 'static,
    Arc<Mutex<L>>: Send + 'static,
    EH: FnMut(Option<Arc<Mutex<OnErrorHandler<L>>>>, &SelfMatchRunningError<E>), 
pub fn start<T, S, P, I, F, R, RH, L, EH>(
    &mut self, 
    on_init_event_dispatcher: I, 
    flip_players: F, 
    initial_position_creator: Option<Box<dyn FnMut() -> String + Send + 'static>>, 
    kifu_writer: Option<Box<dyn FnMut(&String, &Vec<Move>) -> Result<(), KifuWriteError> + Send + 'static>>, 
    input_reader: R, 
    input_handler: RH, 
    player1: T, 
    player2: T, 
    player1_options: Vec<(String, SysEventOption)>, 
    player2_options: Vec<(String, SysEventOption)>, 
    info_sender: S, 
    pinfo_sender: P, 
    game_time_limit: UsiGoTimeLimit, 
    uptime: Option<Duration>, 
    number_of_games: Option<u32>, 
    logger: L, 
    on_error: EH
) -> Result<SelfMatchResult, SelfMatchRunningError<E>> where
    T: USIPlayer<E> + Debug + Send + 'static,
    F: FnMut() -> bool + Send + 'static,
    R: USIInputReader + Send + 'static,
    RH: FnMut(String) -> Result<bool, SelfMatchRunningError<E>> + Send + 'static,
    I: FnMut(&mut SelfMatchEventDispatcher<'_, E, L>),
    S: InfoSender,
    P: PeriodicallyInfo + Clone + Send + 'static,
    L: Logger + Debug + Send + 'static,
    Arc<Mutex<L>>: Send + 'static,
    EH: FnMut(Option<Arc<Mutex<OnErrorHandler<L>>>>, &SelfMatchRunningError<E>), 
Logger,USIInputReaderを指定して開始
Arguments
on_init_event_dispatcher- 自己対局時に通知されるSelfMatchEventのイベントディスパッチャーを初期化flip_players- 対局時の初期局面時のplayer1とplayer2の手番の割り当てを逆にする。(通常はplayer1が先手)initial_position_creator- 対局毎の初期局面を生成して返す関数kifu_writer- 対局終了時に棋譜を書き込むためのコールバック関数input_reader- 入力を読み取るためのオブジェクト。実装によって標準入力以外から読み取るものを指定することも可能。input_handler- 標準入力から読みこんだ行が渡されるコールバック関数。システムイベントの発行などに使う(’quit’で終了など)player1- USIPlayerを実装したプレイヤーオブジェクトplayer2- USIPlayerを実装したプレイヤーオブジェクトplayer1_options- player1に渡されるオプションplayer2_options- player2に渡されるオプションinfo_sender- infoコマンドを送信するための機能を持つオブジェクトpinfo_sender- あらかじめスケジュールされた一定の間隔でinfoコマンドを送信するための機能を持つオブジェクトgame_time_limit- 対局毎の制限時間uptime- 自己対局機能全体の実行時間制限。この時間に達すると自己対局は終了する(現在の対局だけではない)number_of_games- 自己対局機能で行われる対局の回数。この回数を終えると自己対局は終了するlogger- ログを書き込むためのオブジェクト。実装によってファイル以外に書き込むものを指定することも可能。on_error- エラー発生時に呼ばれるコールバック関数。エラーオブジェクトへの参照とロガーが渡される。