public frmMain() { InitializeComponent(); LogWatcher.Logger log_watcher_logger = new LogWatcher.Logger(); log_watcher_logger.RegisterInfoCallback( (string msg) => AddLog(msg)); log_watcher = new LogWatcher.LogWatcher(log_watcher_logger); log_watcher.BlockStart += Log_reader_ActionStart; log_watcher.CreateGameEvent += Log_reader_CreateGameEvent; log_watcher.EndTurnEvent += Log_reader_EndTurnEvent; log_watcher.game_state_changed += (Game game_state) => { Board.Game board = new Board.Game(); bool parse_success = board.Parse(game_state); if (parse_success == false) { txtGameEntity.Text = "Failed to parse game state to board."; return; } if (last_board != null && last_board.Equals(board)) { return; } last_board = board; this.UpdateBoard(game_state, board); var game_stage = GameStageHelper.GetGameStage(game_state); txtGameEntity.Text = "Stage: " + game_stage.ToString() + Environment.NewLine; ai_engine_.AbortRunner(); if (game_stage == GameStage.STAGE_PLAYER_CHOICE) { ai_engine_.UpdateBoard(board); if (game_state.GetCurrentPlayerEntityId() == game_state.PlayerEntityId) { int seconds = Convert.ToInt32(Math.Round(nudSeconds.Value, 0)); int threads = Convert.ToInt32(Math.Round(nudThreads.Value, 0)); ai_engine_.Run(seconds, threads); } } }; ai_logger_ = new AI.AILogger(ref txtAIEngine); ai_engine_ = new AI.AIEngine(ai_logger_); ai_engine_.output_message_cb += (System.String msg) => { ai_logger_.Info("[Engine] " + msg); }; }
public int Initialize(int root_sample_count) { if (engine_.Initialize(root_sample_count) != 0) { return(-1); } initialized_ = true; logger_.Info("Engine is now initialized."); return(0); }