Exemplo n.º 1
0
        private void FillTree(ChipNode chipNode, int level)
        {
            if (level >= Deep)
            {
                return;
            }

            BoardService boardService = new BoardService();

            boardService.InitBoard(new Board(chipNode.Board));
            boardService.FlipChips(new Chip(chipNode.Chip), chipNode.Chip.OwnerId);
            List <Chip> availableChips = boardService.GetAvailableSteps(Players.
                                                                        Where(player => player.Id != chipNode.Chip.OwnerId).
                                                                        Select(player => player.Id).FirstOrDefault());

            if (availableChips.Count == 0)
            {
                return;
            }

            foreach (Chip chip in availableChips)
            {
                ChipNode nextChipNode = new ChipNode(new Board(boardService.Board),
                                                     new Chip(chip), level);
                chipNode.NextChips.Add(nextChipNode);
                FillTree(nextChipNode, level + 1);
                nextChipNode.SetCoefficient();
            }
        }