Ejemplo n.º 1
0
        private void BuildJumpSequences(Figure figure, MoveSequence sequence, List <MoveSequence> builder)
        {
            if (ShouldPromoteKing(figure, board.Size))
            {
                sequence.Add(MoveStep.King());
                builder.Add(sequence); //abort sequence traversing
                return;
            }

            var endOfSequence = true;

            foreach (var direction in GetDirections(figure))
            {
                var position = GetJumpPoint(figure, direction, out var neighbour);
                if (position == Point.Nop)
                {
                    continue;
                }
                if (sequence.Contains(position))
                {
                    continue;
                }

                endOfSequence = false;
                var figureAfterJump = new Figure(position, figure.Side, figure.IsKing);
                var newSequence     = new MoveSequence(sequence);
                newSequence.Add(MoveStep.Jump(figureAfterJump.Point));
                BuildJumpSequences(figureAfterJump, newSequence, builder);
            }
            if (endOfSequence && !sequence.IsEmpty)
            {
                builder.Add(sequence);
            }
        }
Ejemplo n.º 2
0
 private void BuildSimpleMoves(Figure figure, List <MoveSequence> simpleMoves)
 {
     foreach (var direction in GetDirections(figure))
     {
         var jump = GetJumpPoint(figure, direction, out var neighbour);
         if (jump == Point.Nop && neighbour.Side == Side.Empty)
         {
             var sequence = new MoveSequence(MoveStep.Move(neighbour.Point));
             if (!figure.IsKing && ShouldPromoteKing(new Figure(neighbour.Point, figure.Side, figure.IsKing), board.Size))
             {
                 sequence.Add(MoveStep.King());
             }
             simpleMoves.Add(sequence);
         }
     }
 }
Ejemplo n.º 3
0
 public bool Equals(MoveSequence other) => _set.SetEquals(other._set);
Ejemplo n.º 4
0
 internal MoveSequence(MoveSequence sequence) : this()
 {
     _set      = new HashSet <Point>(sequence._set);
     _sequence = new LinkedList <MoveStep>(sequence._sequence);
 }