Beispiel #1
0
        public void GenerateMovePositions()
        {
            Console.WriteLine("Vanga: GenerateMovePositions");
            var cells = _desk.Cells;

            _desk.CheckIfNeedBeate();
            if (_desk.NeedBeat)
            {
                CellPosition cellPosition = null;
//                var thread = new Thread(() =>
//                {
                cellPosition = SelectBestBeatCombination(_desk);
//                }, 2000000000);
//                thread.Start();
//                thread.Join();
                if (cellPosition == null)
                {
                    return;
                }
                Console.WriteLine($@"Vanga: Click = r:{cellPosition.Get_row()} c:{cellPosition.Get_column()}");
                _desk.GetCell(cellPosition).Click(true);
                _vangaMadeTurn = true;
            }
            else
            {
                foreach (var cell in cells)
                {
                }
            }
        }
Beispiel #2
0
        private int GetScore(Desk loadedDesk, CellPosition loadedCheckerCellPosition)
        {
            var score = 0;
            var desk  = new Desk(loadedDesk.ReturnDeskAsRawText());

            desk.StartBotSimulation();
            desk.CheckIfNeedBeate();
            if (!desk.NeedBeat)
            {
                return(score);
            }
            var checkerCell = desk.GetCell(loadedCheckerCellPosition);

            var          battleCells         = checkerCell.GetBattleCells();
            CellPosition currentCellPosition = null;

            foreach (var battleCell in battleCells)
            {
                var selectedScore = GetScore(desk, checkerCell.GetCellPosition(), battleCell.GetCellPosition(), score);
                if (currentCellPosition != null && selectedScore <= score)
                {
                    continue;
                }
                currentCellPosition = battleCell.GetCellPosition();
                score = selectedScore;
            }

            return(score);
        }
Beispiel #3
0
        private int GetScore(Desk loadedDesk, CellPosition loadedCheckerCellPosition, CellPosition loadedNextCellPosition, int currentScore)
        {
            var score = currentScore;
            var desk  = new Desk(loadedDesk.ReturnDeskAsRawText());

            if (desk.IsGameFinished)
            {
                return(score);
            }
            desk.StartBotSimulation();
            var side        = desk.CurrentWhiteTurn;
            var checkerCell = desk.GetCell(loadedCheckerCellPosition);
            var nextCell    = desk.GetCell(loadedNextCellPosition);

            checkerCell.Click(false);
            if (desk.IsGameFinished)
            {
                return(score);
            }
            nextCell.Click(false);
            if (desk.IsGameFinished)
            {
                return(score);
            }
            var lastShotDownCell = desk.Get_lastShotDownCheckerCell();

            if (lastShotDownCell == null) //debug
            {
                throw new Exception("Muuuuu!");
            }
            score += GetCeckerScore(lastShotDownCell.Checker, side);
            Cell currentShotDownCell;

            while (side == desk.CurrentWhiteTurn)
            {
                var cellPosition = SelectBestBeatCombination(desk);
                desk.GetCell(cellPosition).Click(false);
                if (desk.IsGameFinished)
                {
                    return(score);
                }
                currentShotDownCell = desk.Get_lastShotDownCheckerCell();
                if (!lastShotDownCell.GetCellPosition().Equals(currentShotDownCell.GetCellPosition()))
                {
                    score += GetCeckerScore(currentShotDownCell.Checker, side);
                }
            }

            // beat if need and compute score
            desk.CheckIfNeedBeate();
            if (!desk.NeedBeat)
            {
                return(score);
            }


            var anotherSideDesk = new Desk(desk.ReturnDeskAsRawText());

            anotherSideDesk.StartBotSimulation();
            anotherSideDesk.CheckIfNeedBeate();
            if (!anotherSideDesk.NeedBeat)
            {
                return(score);
            }
            while (side != anotherSideDesk.CurrentWhiteTurn)
            {
                var cellPosition = SelectBestBeatCombination(anotherSideDesk);
                anotherSideDesk.GetCell(cellPosition).Click(false);
                if (desk.IsGameFinished)
                {
                    return(score);
                }
                currentShotDownCell = anotherSideDesk.Get_lastShotDownCheckerCell();
                if (currentShotDownCell != null && !lastShotDownCell.GetCellPosition().Equals(currentShotDownCell.GetCellPosition()))
                {
                    score += GetCeckerScore(currentShotDownCell.Checker, side);
                }
            }

            currentShotDownCell = anotherSideDesk.Get_lastShotDownCheckerCell();
            if (!lastShotDownCell.GetCellPosition().Equals(currentShotDownCell.GetCellPosition()))
            {
                score += GetCeckerScore(currentShotDownCell.Checker, side);
            }
            return(score);
        }