示例#1
0
        // TODO make method less repetitive
        public static void generateLarvaChildren(ref BCTree <BoardConfig> parentNode, int lvl, Board Board)
        {
            //Console.Write("ParentNode Larva = " + GetScoreForPos(parentNode.data.LarvaPos));
            for (int i = 0; i < parentNode.data.BirdsPos.Length; ++i)
            {
                //Console.Write(", Bird " + (i + 1) + " = " + GetScoreForPos(parentNode.data.BirdsPos[i]));
            }
            //Console.WriteLine();

            Position topLeftPosition = new Position(parentNode.data.LarvaPos.Row - 1, parentNode.data.LarvaPos.Col - 1);

            if (Board.IsValidPosition(topLeftPosition) && parentNode.data.IsCellEmpty(topLeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level    = lvl;
                tempBC.LarvaPos = topLeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Top left position = " + GetScoreForPos(topLeftPosition));
            }

            Position topRightPosition = new Position(parentNode.data.LarvaPos.Row - 1, parentNode.data.LarvaPos.Col + 1);

            if (Board.IsValidPosition(topRightPosition) && parentNode.data.IsCellEmpty(topRightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level    = lvl;
                tempBC.LarvaPos = topRightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Top right position = " + GetScoreForPos(topRightPosition));
            }

            Position bottomLeftPosition = new Position(parentNode.data.LarvaPos.Row + 1, parentNode.data.LarvaPos.Col - 1);

            if (Board.IsValidPosition(bottomLeftPosition) && parentNode.data.IsCellEmpty(bottomLeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level    = lvl;
                tempBC.LarvaPos = bottomLeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bottom left position = " + GetScoreForPos(bottomLeftPosition));
            }

            Position bottomRightPosition = new Position(parentNode.data.LarvaPos.Row + 1, parentNode.data.LarvaPos.Col + 1);

            if (Board.IsValidPosition(bottomRightPosition) && parentNode.data.IsCellEmpty(bottomRightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level    = lvl;
                tempBC.LarvaPos = bottomRightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bottom right position = " + GetScoreForPos(bottomRightPosition));
            }
        }
示例#2
0
        // TODO make method less repetitive
        public static void generateBirdsChildren(ref BCTree<BoardConfig> parentNode, int lvl, Board Board)
        {
            //Console.Write("ParentNode Larva = " + GetScoreForPos(parentNode.data.LarvaPos));
            for (int i = 0; i < parentNode.data.BirdsPos.Length; ++i)
            {
                //Console.Write(", Bird " + (i + 1) + " = " + GetScoreForPos(parentNode.data.BirdsPos[i]));
            }
            //Console.WriteLine();

            Position bird1LeftPosition = new Position(parentNode.data.BirdsPos[0].Row - 1, parentNode.data.BirdsPos[0].Col - 1);
            if (Board.IsValidPosition(bird1LeftPosition) && parentNode.data.IsCellEmpty(bird1LeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.BirdsPos[0] = bird1LeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 1 left position = " + GetScoreForPos(bird1LeftPosition));
            }

            Position bird1RightPosition = new Position(parentNode.data.BirdsPos[0].Row - 1, parentNode.data.BirdsPos[0].Col + 1);
            if (Board.IsValidPosition(bird1RightPosition) && parentNode.data.IsCellEmpty(bird1RightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.BirdsPos[0] = bird1RightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 1 right position = " + GetScoreForPos(bird1RightPosition));
            }

            Position bird2LeftPosition = new Position(parentNode.data.BirdsPos[1].Row - 1, parentNode.data.BirdsPos[1].Col - 1);
            if (Board.IsValidPosition(bird2LeftPosition) && parentNode.data.IsCellEmpty(bird2LeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.BirdsPos[1] = bird2LeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 2 left position = " + GetScoreForPos(bird2LeftPosition));
            }

            Position bird2RightPosition = new Position(parentNode.data.BirdsPos[1].Row - 1, parentNode.data.BirdsPos[1].Col + 1);
            if (Board.IsValidPosition(bird2RightPosition) && parentNode.data.IsCellEmpty(bird2RightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.BirdsPos[1] = bird2RightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 2 right position = " + GetScoreForPos(bird2RightPosition));
            }

            Position bird3LeftPosition = new Position(parentNode.data.BirdsPos[2].Row - 1, parentNode.data.BirdsPos[2].Col - 1);
            if (Board.IsValidPosition(bird3LeftPosition) && parentNode.data.IsCellEmpty(bird3LeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.BirdsPos[2] = bird3LeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 3 left position = " + GetScoreForPos(bird3LeftPosition));
            }

            Position bird3RightPosition = new Position(parentNode.data.BirdsPos[2].Row - 1, parentNode.data.BirdsPos[2].Col + 1);
            if (Board.IsValidPosition(bird3RightPosition) && parentNode.data.IsCellEmpty(bird3RightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.BirdsPos[2] = bird3RightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 3 right position = " + GetScoreForPos(bird3RightPosition));
            }

            Position bird4LeftPosition = new Position(parentNode.data.BirdsPos[3].Row - 1, parentNode.data.BirdsPos[3].Col - 1);
            if (Board.IsValidPosition(bird4LeftPosition) && parentNode.data.IsCellEmpty(bird4LeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.BirdsPos[3] = bird4LeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 4 left position = " + GetScoreForPos(bird4LeftPosition));
            }

            Position bird4RightPosition = new Position(parentNode.data.BirdsPos[3].Row - 1, parentNode.data.BirdsPos[3].Col + 1);
            if (Board.IsValidPosition(bird4RightPosition) && parentNode.data.IsCellEmpty(bird4RightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.BirdsPos[3] = bird4RightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 4 right position = " + GetScoreForPos(bird4RightPosition));
            }
        }
示例#3
0
        // TODO make method less repetitive
        public static void generateLarvaChildren(ref BCTree<BoardConfig> parentNode, int lvl, Board Board)
        {
            //Console.Write("ParentNode Larva = " + GetScoreForPos(parentNode.data.LarvaPos));
            for (int i = 0; i < parentNode.data.BirdsPos.Length; ++i)
            {
                //Console.Write(", Bird " + (i + 1) + " = " + GetScoreForPos(parentNode.data.BirdsPos[i]));
            }
            //Console.WriteLine();

            Position topLeftPosition = new Position(parentNode.data.LarvaPos.Row - 1, parentNode.data.LarvaPos.Col - 1);
            if (Board.IsValidPosition(topLeftPosition) && parentNode.data.IsCellEmpty(topLeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.LarvaPos = topLeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Top left position = " + GetScoreForPos(topLeftPosition));
            }

            Position topRightPosition = new Position(parentNode.data.LarvaPos.Row - 1, parentNode.data.LarvaPos.Col + 1);
            if (Board.IsValidPosition(topRightPosition) && parentNode.data.IsCellEmpty(topRightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.LarvaPos = topRightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Top right position = " + GetScoreForPos(topRightPosition));
            }

            Position bottomLeftPosition = new Position(parentNode.data.LarvaPos.Row + 1, parentNode.data.LarvaPos.Col - 1);
            if (Board.IsValidPosition(bottomLeftPosition) && parentNode.data.IsCellEmpty(bottomLeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.LarvaPos = bottomLeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bottom left position = " + GetScoreForPos(bottomLeftPosition));
            }

            Position bottomRightPosition = new Position(parentNode.data.LarvaPos.Row + 1, parentNode.data.LarvaPos.Col + 1);
            if (Board.IsValidPosition(bottomRightPosition) && parentNode.data.IsCellEmpty(bottomRightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level = lvl;
                tempBC.LarvaPos = bottomRightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bottom right position = " + GetScoreForPos(bottomRightPosition));
            }
        }
示例#4
0
        // TODO make method less repetitive
        public static void generateBirdsChildren(ref BCTree <BoardConfig> parentNode, int lvl, Board Board)
        {
            //Console.Write("ParentNode Larva = " + GetScoreForPos(parentNode.data.LarvaPos));
            for (int i = 0; i < parentNode.data.BirdsPos.Length; ++i)
            {
                //Console.Write(", Bird " + (i + 1) + " = " + GetScoreForPos(parentNode.data.BirdsPos[i]));
            }
            //Console.WriteLine();

            Position bird1LeftPosition = new Position(parentNode.data.BirdsPos[0].Row - 1, parentNode.data.BirdsPos[0].Col - 1);

            if (Board.IsValidPosition(bird1LeftPosition) && parentNode.data.IsCellEmpty(bird1LeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level       = lvl;
                tempBC.BirdsPos[0] = bird1LeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 1 left position = " + GetScoreForPos(bird1LeftPosition));
            }

            Position bird1RightPosition = new Position(parentNode.data.BirdsPos[0].Row - 1, parentNode.data.BirdsPos[0].Col + 1);

            if (Board.IsValidPosition(bird1RightPosition) && parentNode.data.IsCellEmpty(bird1RightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level       = lvl;
                tempBC.BirdsPos[0] = bird1RightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 1 right position = " + GetScoreForPos(bird1RightPosition));
            }

            Position bird2LeftPosition = new Position(parentNode.data.BirdsPos[1].Row - 1, parentNode.data.BirdsPos[1].Col - 1);

            if (Board.IsValidPosition(bird2LeftPosition) && parentNode.data.IsCellEmpty(bird2LeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level       = lvl;
                tempBC.BirdsPos[1] = bird2LeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 2 left position = " + GetScoreForPos(bird2LeftPosition));
            }

            Position bird2RightPosition = new Position(parentNode.data.BirdsPos[1].Row - 1, parentNode.data.BirdsPos[1].Col + 1);

            if (Board.IsValidPosition(bird2RightPosition) && parentNode.data.IsCellEmpty(bird2RightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level       = lvl;
                tempBC.BirdsPos[1] = bird2RightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 2 right position = " + GetScoreForPos(bird2RightPosition));
            }

            Position bird3LeftPosition = new Position(parentNode.data.BirdsPos[2].Row - 1, parentNode.data.BirdsPos[2].Col - 1);

            if (Board.IsValidPosition(bird3LeftPosition) && parentNode.data.IsCellEmpty(bird3LeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level       = lvl;
                tempBC.BirdsPos[2] = bird3LeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 3 left position = " + GetScoreForPos(bird3LeftPosition));
            }

            Position bird3RightPosition = new Position(parentNode.data.BirdsPos[2].Row - 1, parentNode.data.BirdsPos[2].Col + 1);

            if (Board.IsValidPosition(bird3RightPosition) && parentNode.data.IsCellEmpty(bird3RightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level       = lvl;
                tempBC.BirdsPos[2] = bird3RightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 3 right position = " + GetScoreForPos(bird3RightPosition));
            }

            Position bird4LeftPosition = new Position(parentNode.data.BirdsPos[3].Row - 1, parentNode.data.BirdsPos[3].Col - 1);

            if (Board.IsValidPosition(bird4LeftPosition) && parentNode.data.IsCellEmpty(bird4LeftPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level       = lvl;
                tempBC.BirdsPos[3] = bird4LeftPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 4 left position = " + GetScoreForPos(bird4LeftPosition));
            }

            Position bird4RightPosition = new Position(parentNode.data.BirdsPos[3].Row - 1, parentNode.data.BirdsPos[3].Col + 1);

            if (Board.IsValidPosition(bird4RightPosition) && parentNode.data.IsCellEmpty(bird4RightPosition))
            {
                BoardConfig tempBC = new BoardConfig(parentNode.data);
                tempBC.Level       = lvl;
                tempBC.BirdsPos[3] = bird4RightPosition;
                parentNode.AddChild(tempBC);
                //Console.WriteLine("Bird 4 right position = " + GetScoreForPos(bird4RightPosition));
            }
        }