Example #1
0
        private List<Jump> GetAvailableJumps(Board board, Coordinate peg)
        {
            List<Jump> jumps = new List<Jump>();

            // check each direction
            for (int i = 0; i < xs.Length; i++)
            {
                var jumped = new Coordinate(peg.X + (xs[i] * 1), peg.Y + (ys[i] * 1));
                var target = new Coordinate(peg.X + (xs[i] * 2), peg.Y + (ys[i] * 2));

                // check that the next coord over and the one after that exist
                // and that next has a peg to jump and the one after is empty
                if (board.ContainsCoordinate(jumped) &&
                    board.ContainsCoordinate(target) &&
                    board[jumped].HasPeg == true &&
                    board[target].HasPeg == false)
                    jumps.Add(new Jump(peg, jumped, target));
            }

            return jumps;
        }
Example #2
0
 public Problem(Coordinate emptyPeg = null)
 {
     this.emptyPeg = emptyPeg;
 }