예제 #1
0
파일: Table.cs 프로젝트: garayzuev/draughts
        public void moveTo(Position to)
        {
            Position from   = select.getPosition();
            bool     isKing = select.isKing();

            if (Arbiter.isAttack(select, to, draughts))
            {
                attack(to);
            }
            else
            {
                select.moveTo(to);
            }

            if (isKing != select.isKing())
            {
                mw.setKing(from.x, from.y);
            }
            mw.turnOn(from.x, from.y, to.x, to.y);
        }
예제 #2
0
파일: AI.cs 프로젝트: garayzuev/draughts
        private int attack(Draught d, List <Draught> list)
        {
            List <Position> pos = d.getAttackMoves();

            foreach (Position p in pos)
            {
                if (Arbiter.canAttack(d, p, list))
                {
                    Position to = new Position();
                    to.x = p.x - d.getPosition().x > 0 ? p.x + 1 : p.x - 1;
                    to.y = p.y - d.getPosition().y > 0 ? p.y + 1 : p.y - 1;

                    List <Draught> newList = copyList(list);
                    newList.Remove(Arbiter.findDraught(p, newList));
                    Arbiter.findDraught(d.getPosition(), newList).moveTo(to);
                    return(POINTS_FOR_EAT + (Arbiter.findDraught(to, newList).isKing() != d.isKing()?POINTS_FOR_KING:0) + attack(Arbiter.findDraught(to, newList), newList));
                }
            }
            return(checkDraught(d.getPosition(), list));
        }