コード例 #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));
        }