//Used for creating children
 public WallDiffNode(WallDiffNode n, string move)
 {
     MoveMade = move;
     Board    = new AIBoard(n.Board);
     Board.MakeMove(move);
     Depth        = n.Depth + 1;
     PreviousDiff = n.Diff;
 }
Exemple #2
0
        //If risk is very high will return 1, low risk is higher return value.
        private int GetMoveRisk(string move)
        {
            int     riskValue = 100;
            AIBoard tempBoard = new AIBoard(CurrentBoard);

            tempBoard.MakeMove(move);
            WallDiffNode rootNode = new WallDiffNode(tempBoard);

            List <string> wallPlacements = tempBoard.GetWallMoves();

            foreach (string wall in wallPlacements)
            {
                riskValue = Math.Min(riskValue, RiskIterate(new WallDiffNode(rootNode, wall), 0));
            }

            return(riskValue);
        }
Exemple #3
0
        private int RiskIterate(WallDiffNode node, int depth, int maxDepth = 4)
        {
            //NumMoves is the number of moves it takes before a significant change in shortest path is found.
            int changeInDiff = node.CalcChangeInDiff();
            int numMoves     = 1000;

            if (changeInDiff > changeThreshhold)
            {
                numMoves = depth;
            }
            else if (depth > maxDepth)
            {
                numMoves = depth;
            }
            else
            {
                List <WallDiffNode> children = node.GetChildren();
                foreach (WallDiffNode child in children)
                {
                    numMoves = Math.Min(numMoves, RiskIterate(child, depth + 1));
                }
            }
            return(numMoves);
        }