public void MakeMove() { List <Tuple <int, int> > availablePoints = gameProcessor.GetAvailablePoints(); //pass if there is no available moves if (availablePoints.Count == 0) { gameProcessor.Pass(); return; } //set dafault values Tuple <int, int> bestMove = availablePoints[0]; int bestScore = int.MaxValue; //get the best move from all foreach (var move in availablePoints) { List <List <Point> > pointsBeforeMove = CloneGameState(gameProcessor.GetPoints()); gameProcessor.MakeMove(move); int score = MiniMax(3, int.MinValue, int.MaxValue, true); if (score < bestScore) { bestScore = score; bestMove = move; } gameProcessor.UndoMove(pointsBeforeMove); } //make move Console.WriteLine(ConvertCoords(bestMove)); gameProcessor.MakeMove(bestMove); }
/// <summary> /// Make move from console /// </summary> /// <returns></returns> public Tuple <int, int> MakeMove() { List <Tuple <int, int> > availablePoints = gameProcessor.GetAvailablePoints(); string move; Tuple <int, int> moveCoords = new Tuple <int, int>(-1, -1); //read from console white input isn`t correct do { move = Console.ReadLine(); move = move.Trim().ToLower(); if (!IsCorrectMove(move)) { //if this is word "pass" - make move pass if (move == "pass") { gameProcessor.PassWithoutMassage(); break; } continue; } //make correct and available move moveCoords = ConsoleInput.ConvertToIntCoords(move); if (availablePoints.Contains(moveCoords)) { gameProcessor.MakeMove(moveCoords); break; } }while (true); return(moveCoords); }