Ejemplo n.º 1
0
        protected List <PawnMove> GetNoneCaptureList(Dot pos, BoardState boardState, Dot dir)
        {
            var result = new List <PawnMove>();

            pos = pos.GetMoved(dir);
            while (boardState.IsOnBoard(pos) && boardState.GetColor(pos) == PawnColor.NONE)
            {
                result.Add(new PawnMove(pos, this, false));
                pos = pos.GetMoved(dir);
            }
            return(result);
        }
Ejemplo n.º 2
0
        protected override bool CanCapture(Dot pos, BoardState boardState, Dot dir)
        {
            var cap       = pos.GetMoved(dir);
            var dest      = pos.GetMoved(dir.X * 2, dir.Y * 2);
            int boardSize = boardState.GetBoardSize();

            if (boardState.IsOnBoard(dest) == false)
            {
                return(false);
            }
            if (IsOponentColor(boardState.GetColor(cap)) == false)
            {
                return(false);
            }
            return(boardState.GetColor(dest) == PawnColor.NONE);
        }
Ejemplo n.º 3
0
        protected override List <PawnMove> GetNoneCaptureList(Dot pos, BoardState boardState)
        {
            Func <Dot, bool> emptyFunc = ((x) => boardState.GetColor(x) == PawnColor.NONE);
            var result = new List <PawnMove>();
            var move1  = pos.GetMoved(moveDir, 1);
            var move2  = pos.GetMoved(moveDir, -1);

            if (boardState.IsOnBoard(move1) && emptyFunc(move1))
            {
                result.Add(GetNoneCaptureMove(move1, boardState));
            }
            if (boardState.IsOnBoard(move2) && emptyFunc(move2))
            {
                result.Add(GetNoneCaptureMove(move2, boardState));
            }
            return(result);
        }
Ejemplo n.º 4
0
        protected override List <PawnMove> GetCaptureList(Dot pos, BoardState bState, Dot dir, PawnMove pMove)
        {
            if (CanCapture(pos, bState, dir) == false)
            {
                return(new List <PawnMove>());
            }
            var capPawn = bState.GetPawn(pos.GetMoved(dir));

            if (pMove.GetCapturedList().Contains(capPawn))
            {
                return(new List <PawnMove>());
            }
            var  destPos   = pos.GetMoved(dir.X * 2, dir.Y * 2);
            bool isDamePos = IsDameLanePos(destPos, bState);
            var  destMove  = pMove.CreateIncrMove(destPos, capPawn, isDamePos);

            return(GetCaptureList(destPos, bState, destMove));
        }
Ejemplo n.º 5
0
        protected Pawn GetCapturedPawn(Dot pos, BoardState boardState, Dot dir)
        {
            pos = pos.GetMoved(dir);
            while (boardState.IsOnBoard(pos) && boardState.GetColor(pos) == PawnColor.NONE)
            {
                pos = pos.GetMoved(dir);
            }
            if (boardState.IsOnBoard(pos) == false || IsOponentColor(boardState.GetColor(pos)) == false)
            {
                return(null);
            }
            var dest = pos.GetMoved(dir);

            if (boardState.IsOnBoard(dest) == false || boardState.GetColor(dest) != PawnColor.NONE)
            {
                return(null);
            }
            return(boardState.GetPawn(pos));
        }
Ejemplo n.º 6
0
        protected override List <PawnMove> GetCaptureList(Dot pos, BoardState bState, Dot dir, PawnMove pMove)
        {
            var capPawn = GetCapturedPawn(pos, bState, dir);

            if (capPawn == null)
            {
                return(new List <PawnMove>());
            }
            pos = capPawn.GetPosition();
            if (pMove.GetCapturedList().Contains(capPawn))
            {
                return(GetCaptureList(pos, bState, dir, pMove));
            }
            pos = pos.GetMoved(dir);
            var result = new List <PawnMove>();

            while (bState.IsOnBoard(pos) && bState.GetColor(pos) == PawnColor.NONE)
            {
                var destMove = pMove.CreateIncrMove(pos, capPawn, false);
                result.AddRange(GetCaptureList(pos, bState, destMove));
                pos = pos.GetMoved(dir);
            }
            return(result);
        }