Ejemplo n.º 1
0
        public int ScoreBoard(BoardPosition[,] currentBoard, TeamName team)
        {
            _currentBoard = currentBoard;
            _myTeam       = team;
            _enemy        = team.GetOppositeTeam();
            int totalScore = CheckForWin();

            if (totalScore != 0)
            {
                return(totalScore);
            }
            totalScore = OneMoveWinScore();
            if (totalScore != 0)
            {
                return(totalScore);
            }
            int enemyScore = CalculateScore(currentBoard, _enemy);
            int myScore    = CalculateScore(currentBoard, _myTeam);

            totalScore += myScore - enemyScore;
            if (Mathf.Abs(totalScore) > 100)
            {
                Debug.Log("Score greater than 100");
            }
            return(totalScore);
        }
Ejemplo n.º 2
0
        public void BuildChildren(Position parent, BoardPosition[,] currentBoardState, TeamName teamName, int depth)
        {
            List <Position> children = new List <Position>();

            if (depth <= 0 || Mathf.Abs(parent.Score) == 100)
            {
                return;
            }
            List <BoardPosition> availableMoves = parent.BoardAtThisState.GetAvailableMoves();

            foreach (var move in availableMoves)
            {
                var tempBoard = parent.BoardAtThisState.CloneBoard();
                UpdateBoard(tempBoard, move, teamName);
                Position pos = nodes[childCounter];
                pos.Parent           = parent;
                pos.StaticPosition   = move;
                pos.BoardAtThisState = tempBoard;
                // pos.Score = boardScorer.ScoreBoard(tempBoard, _myTeam);
                childCounter++;
                pos.ChildNumber = childCounter;
                children.Add(pos);
            }
            foreach (var child in children)
            {
                BuildChildren(child, child.BoardAtThisState, teamName.GetOppositeTeam(), depth - 1);
            }
            parent.Children = children;
        }