private int FindMove(int depth, int alpha, int beta) { if (depth == 0 || GameOver) { return(StaticScore()); } int[] best = null; int score = 0; List <int[]> mymoves = GetMoves(ConvertBoard()); int bestsofar = int.MinValue; foreach (int[] move in mymoves) { board.MoveBitBoard(move[0], move[1]); int response = FindMin(depth - 1, alpha, beta); if (response >= bestsofar) { best = move; score = StaticScore(); bestsofar = response; alpha = Math.Max(alpha, bestsofar); if (beta <= alpha) { board.UndoLastMoveBitBoard(); break; } } board.UndoLastMoveBitBoard(); } currentmove = best; return(score); }
private void HandleAI() { if (game.isAI && !game.GameOver && game.AIColor == game.Turn) { int[] AImove = myAI.GetMove(); board.MoveBitBoard(AImove[0], AImove[1]); board.MoveCharBoard(AImove[0], AImove[1]); Move(_00); } }