Exemplo n.º 1
0
        private TurnNode KillingRecurcion(TurnNode currentNode, Lib.PlayersSide whoseTurn, IChecker checker, Coord destination, int level)
        {
            int killingValue = (whoseTurn == Lib.PlayersSide.BLACK) ? 100 : 0;

            IChecker[][] state   = CreateStateCopy(currentNode.state);
            TurnNode     newNode = new TurnNode(state, killingValue, level);//чем больше уровень рекурсии, тем меньше

            if (checker.CurrentCoord.Row == 4 && checker.CurrentCoord.Column == 3 && level == 0)
            {
            }

            bool a = (side == Lib.PlayersSide.BLACK && checker is BlackChecker) || (side == Lib.PlayersSide.WHITE && checker is WhiteChecker);

            if (level == 0 && a)
            {
                KillingCommand command = new KillingCommand(game, checker, checker.GetVictim(destination, gameField), destination);
                newNode.turnCommand = command; //присваеваем команду на первом уровне рекурсии
                TurnNodes.Add(newNode);
            }
            state = ExecuteOperationToKill(state, state[checker.CurrentCoord.Row][checker.CurrentCoord.Column], checker.GetVictim(destination, gameField), destination);
            MakeTurnNodes(newNode, AnotherPlayer(whoseTurn), level + 1);
            return(newNode);
        }
Exemplo n.º 2
0
 public IChecker GetVictim(Coord newCoord, IChecker checker)
 {
     return(checker.GetVictim(newCoord, this));
 }