public override void onMyTurn() { base.onMyTurn(); if (Model.PrepareCheckedChessType == MyChessType) { if (ConnectStrategy.IsWin(MyChessType)) { View.ShowMsg($"{Name.Split('_')[0]} ({Name.Split('_')[3]}) WIN !!!"); System.Console.WriteLine($"{Name.Split('_')[0]} ({Name.Split('_')[3]}) WIN !!!"); } else if (ConnectStrategy.IsTie()) { System.Console.WriteLine($"It's tie !!!"); View.ShowMsg($"It's tie !!!"); } else { RoleMgr.ChangeNextRole(); } } else { System.Console.WriteLine($"{Name} judge error type"); } }
public override void onMyTurn() { base.onMyTurn(); if (TotalTurn == 0) { System.Console.WriteLine($"AI Turn 1"); bool isPutSuccessful = PutChess(GameDef.board_cell_length / 2, GameDef.board_cell_length / 2); RoleMgr.ChangeNextRole(); } else { MinMaxSearchCount = 0; MinMaxSearchInfo bestPosInfo = MinMaxSearch(Model, MyChessType, true, 0, int.MinValue, int.MaxValue); System.Console.WriteLine($"MinMaxSearchCount = {MinMaxSearchCount.ToString()}"); System.Console.WriteLine($"SearchHasResultCount = {SearchHasResultCount.ToString()}"); System.Console.WriteLine($"Turn: {(TotalTurn + 1).ToString()} {Name} Y = {bestPosInfo.Y.ToString()} X = {bestPosInfo.X.ToString() } Score = {bestPosInfo.Score.ToString()}"); bestPosInfo.Model.PrintBoard(); bool isPutSuccessful = PutChess(bestPosInfo.X, bestPosInfo.Y); RoleMgr.ChangeNextRole(); } }
private bool onClickCommand(CommandBase command) { if (command is ClickCommand) { ClickCommand clickCommand = command as ClickCommand; if (clickCommand.IsValid) { bool isPutSuccessful = PutChess(clickCommand.Board_X, clickCommand.Board_Y); //Model.PrintBoard(); RoleMgr.ChangeNextRole(); int boardScore = DebugEvaluation.GetScore(Model, MyChessType); Console.WriteLine($"ChessType = {MyChessType.ToString()} Board Score = {boardScore.ToString()}"); return(true); } else { Console.WriteLine($"Not valid position"); return(false); } } else { Console.WriteLine("command is not ClickCommand"); return(false); } }
private bool onComputerNextCommand(CommandBase command) { if (command is ComputerNextCommand) { RoleMgr.ChangeNextRole(); return(true); } else { Console.WriteLine("command is not ComputerNextCommand"); return(false); } }
public override void onMyTurn() { Random random = new Random(); int x, y; do { x = random.Next(GameDef.board_cell_length); y = random.Next(GameDef.board_cell_length); } while (Model.GetBoardByCopy()[y][x] != ChessType.None); bool isPutSuccessful = PutChess(x, y); RoleMgr.ChangeNextRole(); }
public override void onMyTurn() { base.onMyTurn(); int bestScore = int.MinValue; int bestX = -1; int bestY = -1; if (TotalTurn == 0) { System.Console.WriteLine($"AI Turn 1"); bool isPutSuccessful = PutChess(GameDef.board_cell_length / 2, GameDef.board_cell_length / 2); RoleMgr.ChangeNextRole(); } else { for (int y = 0; y < GameDef.board_cell_length; y++) { for (int x = 0; x < GameDef.board_cell_length; x++) { var board = Model.GetBoardByCopy(); if (board[y][x] == ChessType.None) { Model cloneModel = Model.Clone() as Model; int score = MyEvaluation.GetScore(cloneModel, y, x, MyChessType); if (score > bestScore) { bestScore = score; bestX = x; bestY = y; } } } } bool isPutSuccessful = PutChess(bestX, bestY); RoleMgr.ChangeNextRole(); } }