public bool TryMakeAIMove(out Move move) { move = _jd.MakeBestMove(_game); if (null == move) { return(false); } else { return(true); } }
static void Main(string[] args) { do { IHiveAI AI = new JohnnyDeep(BoardAnalysisWeights.winningWeights, 3); YesNo yn = PromptYesOrNo("Is this AI playing white? "); string opponentName = PromptForString("Enter the other player's name: "); Game game; if (yn == YesNo.Yes) { game = Game.GetNewGame(AI.Name, opponentName); } else { game = Game.GetNewGame(opponentName, AI.Name); } AI.BeginNewGame(yn == YesNo.Yes); do { Board currentBoard = game.GetCurrentBoard(); Move move; if (game.whiteToPlay == AI.playingWhite) { DateTime beginTimestamp = DateTime.Now; move = AI.MakeBestMove(game); TimeSpan timespan = DateTime.Now.Subtract(beginTimestamp); Console.WriteLine(string.Format("{0} seconds {1} Moved: {2}", timespan.TotalSeconds, AI.Name, Move.GetMoveWithNotation(move, currentBoard).notation)); } else { move = PromptForMove("Enter your move: ", game); Console.WriteLine(string.Format("{0} Moved: {1}", opponentName, Move.GetMoveWithNotation(move, currentBoard).notation)); } } while (game.gameResult == GameResult.Incomplete); Console.WriteLine(GetWinnerString(game)); if (PromptYesOrNo("Write out game transcript?") == YesNo.Yes) { string filename = Game.WriteGameTranscript(game); Console.WriteLine("Written to " + filename); } } while (PromptYesOrNo("Play again?") == YesNo.Yes); }