private JavaList <object> GetComputerMinimaxMovements(CheckersBoardGameEngine boardGameEngine) { JavaList <object> bestMove = null; int maxValue = int.MinValue; var sucessors = boardGameEngine.FindAllLegalMovesForCurrentPlayer(); while (IsValidMove(sucessors)) { var move = (JavaList <object>)sucessors.pop_front(); var nextBoard = boardGameEngine.Clone(); nextBoard.ApplyMove(move); var value = PlayerMinMove(nextBoard, 1, maxValue, int.MaxValue); if (value > maxValue) { Debug.WriteLine("Max value : " + value + " at depth : 0"); maxValue = value; bestMove = move; } } Debug.WriteLine("Move value selected : " + maxValue + " at depth : 0"); return(bestMove); }
public CheckersBoardView() { _selectedPositions = new JavaList <object>(); _boardGameEngine = new CheckersBoardGameEngine(); _checkersMinimax = new CheckersMinimax(_boardGameEngine); ResetBoard(); }
public void AppendToTail(JavaList <TElement> other) { var node = other._head; while (node != null) { push_back(node.Value); node = node.Next; } }
public JavaList <TElement> Clone() { var temp = new JavaList <TElement>(); var node = _head; while (node != null) { temp.push_back(node.Value); node = node.Next; } return(temp); }
private bool IsValidMove(JavaList <object> moves) { return(!moves.IsEmpty() && !((JavaList <object>)moves.peek_head()).IsEmpty()); }